Advertisements
Advertisements
प्रश्न
‘Write an Assembly Language program to divide the data at location 9900H by the data stored at location 9901H. Storc thc quotient and remainder in 9902H and 9903H memory locations respectively.
कोड लेखन
Advertisements
उत्तर
; 8085 Program to Divide two 8-bit numbers
; Dividend is stored at 9900H, Divisor is at 9901H
; Result: Remainder at 9902H, Quotient at 9903H
Label Instructions Comments
LXI H, 9900H ; Load HL pair with address 9900H (Address of Dividend)
MOV A, M ; Move Dividend from memory to Accumulator (A)
INX H ; Increment HL to 9901H (Address of Divisor)
MOV B, M ; Move Divisor from memory to Register B
MVI C, 00H ; Initialize Register C to 00H (To store Quotient)
UP: CMP B ; Compare Register B with Accumulator A (A - B)
JC DOWN ; If A < B (Carry is set), Jump to DOWN (Division finished)
SUB B ; Subtract B from A (A = A - B)
INR C ; Increment C by 1 (Count the number of subtractions)
JMP UP ; Jump back to UP to repeat the subtraction
DOWN: INX H ; Increment HL to 9902H
MOV M, A ; Store the Remainder (Leftover value in A) at 9902H
INX H ; Increment HL to 9903H
MOV M, C ; Store the Quotient (Value in C) at 9903H
HLT ; Stop the program
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (July) Official Board Paper
