0

I am trying to get the remainder and quotient of a number divided by 10.

I have this code block right here, is this correct? I can't seem to have an output from the variables when I try to print them

mov al, [dividend]
mov ah, 0
mov byte[dividend], 10
mov byte[quotient], al
mov byte[remainder], ah

Given that I have these variables:

dividend resb 1
quotient resb 1
remainder resb 1

I'm using Ubuntu 13 x86. Thanks!

phuclv
  • 32,499
  • 12
  • 130
  • 417
Kevin Lloyd Bernal
  • 345
  • 3
  • 8
  • 23

1 Answers1

2

You will need to use the div instruction, like so:

mov al,[dividend]
mov ah,0
mov cl,10            ; divisor is stored here
div cl               ; division is performed here
mov [quotient],al
mov [remainder],ah
Drew McGowen
  • 11,186
  • 1
  • 29
  • 57