I have a problem using NASM assembly.
I can't figure out how to multiply 2 numbers and print them to the screen.
The problem is that we are only allowed to use a function which only prints 32-bit length number; not 64-bit length numbers.
So my problem is probably with the math, I think I need to use Horner's method to get the the decimal number; like I indicate below.
If I have
AF / A = 11 remaining 5
11 / A = 1 remaining 7
1 / A = 0 remaining 1
-> 175 which is the right result
but when I split it up in two registers here each 4 byte just as an example
A | F A / A = 1 remaining 0 and F / A = 1 remaining 5
1 / A = 0 remaining 1
->150 which is wrong
Here is my assembly code
mov eax, [Zahl1]
mul dword [Zahl2]
mov [High], edx
;---- low-----
mov ebx, 10
loopbegin:
;dividing by 10
xor edx, edx
div ebx
;counting
inc dword [counter]
;saving the number
push edx
cmp eax, 0
jne loopbegin
mov ebx, 10
; --- high ----
mov eax, [High]
highloop:
xor edx, edx
div ebx
inc dword [counter]
push edx
cmp eax, 0
jne highloop
<note>
here follows the loop that prints the numbers from the stack