Source program :
- MVI E, 00 : Quotient = 0
- LHLD 2200H : Get dividend
- LDA 2300 : Get divisor
- MOV B, A : Store divisor
- MVI C, 08 : Count = 8
- NEXT: DAD H : Dividend = Dividend x 2
- MOV A, E
- RLC
- MOV E, A : Quotient = Quotient x 2
- MOV A, H
- SUB B : Is most significant byte of Dividend > divisor
- JC SKIP : No, go to Next step
- MOV H, A : Yes, subtract divisor
- INR E : and Quotient = Quotient + 1
- SKIP:DCR C : Count = Count - 1
- JNZ NEXT : Is count =0 repeat
- MOV A, E
- STA 2401H : Store Quotient
- Mov A, H
- STA 2410H : Store remainder
- HLT : End of program.
|
Flowchart for program
|
0 Comments