Search code examples
assemblymasm

How to print remainder in assembly language


I'm trying to get the remainder of 2013/10 and add 1 to it

this is what I did so far, however, I'm only getting the quotient even though I've added 1 to edx (which is the remainder) and I've also moved A to eax so I can print it using call writedec

Can anyone tell me what's wrong with this code? how can I get the remainder and add 1 to it? I am using MASM assembler

.data
    N dword 2013
    A dword 0
    str1 byte " A is =",0

.code
     main proc
     lea edx, str1
     call writestring
     mov edx, 0
     mov eax, N
     mov ebx, 10
     div ebx
     Add edx, 1
     add A, edx
     mov eax, A
     call writedec
     call crlf

Solution

  • Replace this two line

     add A, edx
     mov eax, A
    

    with this line :

    mov eax,edx