MASM

Masm assembly 8086 carry flag between data word addition

不羁岁月 提交于 2019-12-20 05:09:33
问题 So I have this problem I'm supposed to solve and I've spent hours trying to figure out the best way to do this, google hasn't been of much help. The problem is to create a subroutine that is given a list of words that you then add with another list that becomes the output. Its basically a method of working with large numbers. My code works fine for carry flags within words, but for carry flag from one full word to another it does not work. The first 16 bit word (0005 in the example below) is

Assembly x86 division with DX:AX

試著忘記壹切 提交于 2019-12-20 04:53:37
问题 I'm working with masm and I've encountered a scenario I do not readily understand how to solve, for example: X = (A)/(C*D) If I multiple C*D first, my value is DX:AX and to my knowledge, I cannot use that as a divisor. If I do division separately as A/C and A/D, I run the risk of losing precision (from the reminders, etc.). What's the best way to implement this? 回答1: As you correctly note, you can't use a 32-bit number as the divisor in a 16-bit division, but since we're only interested in

how to use a library in masm or more specifcally a .lib file?

孤街醉人 提交于 2019-12-20 04:47:19
问题 I have made a .lib file using visual studio 2010 and now I want to use it in masm. How can I do that? need help. I tried to look it on the internet but couldn't find any precise answer on how to do this. here is the link to .lib file that I created using Visual C++ 2010. https://www.dropbox.com/s/pzdd35ktolfl48x/MathFuncsLib.lib This file contains only a function that takes two integers as arguments and returns their sum. I need to use this function in one of my program written in intel

Summing an array in assembly x86. On the inputted indexes

笑着哭i 提交于 2019-12-20 04:26:12
问题 Im having some trouble adding an array but on the inputted indexes. For example, the user inputs 4 as starting and 6 as ending array so I will have to loop through array[4] to array[6] and add the numbers inclusively. I'm not sure if i can use my array in .data in the my ArraySum procedure. Do i have to push it into the procedure somehow? I am using Kip Irvine's external library for this. My code is here: TITLE Assignment 7 INCLUDE Irvine32.inc .data str1 BYTE "The array sum is: ",0 start

How can I convert a number in a string to any base in assembly?

无人久伴 提交于 2019-12-20 04:16:33
问题 How can I convert a number contained in a string from any base to any other base? Bases can be anything i.e.: 2, 16, 10, 4, 8, 9. I'm expecting the user to enter the base number. The user will enter the output base (the base to be converted to). The user will enter the number he wants to convert. Pre thoughts: I will save the input base and the output base in variables. Then I'll save the number he enters in a string (because he could enter any kind of number (hex, binary, base-5..). I'm just

source BYTE “This is the source string”,0 target BYTE SIZEOF source DUP(0),0

旧城冷巷雨未停 提交于 2019-12-20 04:09:21
问题 What is SIZEOF referring to? Is it referring to the size of the source (lengthOf * TYPE which is equal to number of elements in the array * the size of each element)? Also, can someone explain DUP(0),0? This is referring to Assembly x86 MASM. Thank you 回答1: SIZEOF simply denotes the size of a type or structure. It refers to whatever you put after the SIZEOF keyword. SIZEOF element ; refers to a single element in the array. SIZEOF wholearray ; sizeof(element) * number_of_elements_in_array.

Assembly bit memory limit in arithmetic

℡╲_俬逩灬. 提交于 2019-12-20 04:05:32
问题 I wanted to add the following numbers: 40, 90, 50 and 155 and I get a total of 355. I wanted to experiment and test out whether the register AL will have a bit limit of (2^8) - 1, and when I compiled the code and execute the code, I get decimal of 1376331855. How did that happen? Also, I thought 355 is greater than 255, and as a result should display an overflow exception. I understand if I use MOVZX I will be able to carry the calculation into the higher register of AX. Also, I am very

LEA & MOV instruction comparision

不羁岁月 提交于 2019-12-20 03:48:07
问题 Instruction 1: LEA DX, MESSAGE ; Move the address of MESSAGE in register DX Instruction 2: MOV DX, OFFSET MESSAGE ; Move the address of MESSAGE in register DX Questions: Are the above instructions equal? They seem to work similarly, but I have just started programming assembly so I can not say. If both of them are similar, then which one of above is the better way to do the above task? Note: I have already read this question 回答1: On my 32-bit system, the instructions match opcodes like this:

How to see the memory occupied by initialised array vs uninitialised array

為{幸葍}努か 提交于 2019-12-20 02:26:16
问题 I'm currently learning assembly programming by following Kip Irvine's "Assembly Language for x86 Processor". In section 3.4.12, the author states: The .DATA? directive declares uninitialized data. When defining a large block of uninitialized data, the .DATA? directive reduces the size of a compiled program. For example, the following code is declared efficiently: .data smallArray DWORD 10 DUP(0) ; 40 bytes .data? bigArray DWORD 5000 DUP(?) ; 20,000 bytes, not initialized The following code,

Assembly language - masm32 - multiplying

本小妞迷上赌 提交于 2019-12-19 11:59:55
问题 I am multiplying 3 numbers which works good even with a carry. I want to add a 4th number to multiply just for learning purposes. After i multiply 3 numbers i shift into EDX and print. Works great. After i add a 4th number i think i am multiplying 32bit x 32bit? So it stores into EDX:EAX? Would i then need to shift EAX into EDX so they are together to print? Im not sure if i am doing it right for the 4th number? .data? num1 dd ? num2 dd ? num3 dd ? num4 dd ? .data sum dd 0 prod dd 0 prod2 dd