I also want to be able to print the base addresses and limits to the screen to confirm the values that I get.
I have written a procedure in ASM to print the number it finds in EAX, which works up until the number is larger than 1073741824. Numbers lower seem fine (not that i've tested them all of course), but anything larger prints the wrong values.
My procedure gets the number and reverses the digits first, then prints each number by dividing it by 10. The code is below.
My thought at this stage is that I must be doing something wrong with the division that's messing up a register.
Any thoughts?
Code: Select all
MOV EDX, EAX ; The number is passed in EAX, and 'saved' temporarily in EDX
XOR EBX, EBX ; EBX is the 'storage' register
XOR ECX, ECX
Reverse:
MOV EAX, EBX ; Shift one decimal place left
PUSH ECX
MOV ECX, 10
PUSH EDX
MUL ECX
POP EDX
MOV EBX, EAX
MOV EAX, EDX ; Get the last digit of the number by dividing and taking the remainder
XOR EDX, EDX
DIV ECX
POP ECX
ADD EBX, EDX
MOV EDX, EAX
INC ECX ; Counts the digits to print
CMP EAX, 0
JNZ Reverse
MOV EAX, EBX
Print:
XOR EDX, EDX ; Divide by 10 to get last digit
PUSH ECX
MOV ECX, 10
DIV ECX
POP ECX
MOV EBX, EAX ; Quotient: EAX -> EBX
MOV EAX, EDX ; Remainder: EDX -> EAX
ADD AL, 48 ; Print ASCII
MOV AH, 0Eh
INT 10h
MOV EAX, EBX
DEC ECX
CMP ECX, 0 ; Loop until all digits are printed
JNZ Print