Example write instructions to divide the unsigned 16bit numb
Example: write instructions to divide the unsigned 16-bit number 0794h by 8. The number is stored in data registers REG11 (MSB) and REG10 (LSB) with the register addresses 10h and 11 h respectively. (Make sure to use conditional looping) The 16-bit number should be rotated right three times starting from MSB to divide the number by 8. The carry flag should be cleared before the rotation because in the first rotation the carry flag is shifted into Bit7 which should be at logic 0. In the first rotation of REG10, Bit0 of REG11, which is shifted into carry flag previously, becomes Bit7 of REG10 and Bit0 of REG10 shifts into carry flag.
Solution
In 16 bit register representation , h stands for 15
so the number becomes 0794h ~ 079415
First convert this hexadecimal number to octa decimal number
079415 ~0000 0111 1001 0100 0001 0101
Now divide in group of 3 from left side
000 001 111 001 010 000 010 101
Now give the numbering
0 1 7 1 2 0 2 5
~01712025 ~1712025
divide by 8 , now
1712025 / 8
214003
Her MSB is 2 and LSB is 3
2 is stored in REG11 ~ register address at 10h
3 is stored in REG10 ~register address at 11h
start
A 02
B 03
MOV A 02
MOV B 03
DIV C
MOV A 10H
MOV B 11H
END
