0

i'm a beginner here, my div.asm on division does not work. multiplication works when i change div to mul. which part should i edit? and how to make it display remainders? besides, i have another assignment about converting lower to uppercase and if there is no uppercase of a character, display the original character. i could not make the display original character work with the 1st part which is convert lowercase to uppercase.

mov ax,@data
mov ds,ax

lea dx,msg      ;print msg
mov ah,9
int 21h

mov ah,1        ;save input to num2
int 21h
sub al,30h
mov num2,al

lea dx,msg2     ;print msg2
mov ah,9
int 21h

mov ah,1        ;save input to num1
int 21h
sub al,30h
mov num1,al

div num2        ;divide num1 using num2

mov result,al   ;store answer to result
aam             ;aam converts the result into BCD form and 1st digit save in ah and 2nd digit save in al

add ah,30h      ;print data storess in ah and al which is in ascii code, 30h convert to decimal
add al,30h 

mov bx,ax       ;stores the result in ah and al register to bx

lea dx,msg3     ;print msg3
mov ah,9
int 21h

mov ah,2        ;print data in bh
mov dl,bh
int 21h

mov ah,2        ;write character on console present in bl register
mov dl,bl
int 21h

mov ah,4ch      ;exit
int 21h
  • You're apparently only doing 8-bit division, so instead of zeroing EDX, you just need to zero AH. ([`div r/m8`](http://www.felixcloutier.com/x86/DIV.html) is special, and takes AX as the dividend, not two registers combined (DX:AX or EDX:EAX), but it's still double the width of the divisor so everything in the answer on the duplicate applies, except read AH instead of EDX) – Peter Cordes Oct 30 '16 at 07:03
  • Also, use a debugger, and look up any instructions that don't seem to do what you want in the instruction reference manual. Links in the [x86 tag wiki](http://stackoverflow.com/tags/x86/info) – Peter Cordes Oct 30 '16 at 07:05

0 Answers0