Write an Assembly program that will produce all divisors for a 1-digit decimal number. For example, if the number is 6, then the outputs will be 1,2,3,6 which are the divisors of 6.
ASSEMBLY program
The Assembly Program will be as follows :
Try to understand it before implementing it will help you alot
.MODEL SMALL
.STACK 100
.DATA
NUMBER DW 54
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
MOV AX, NUMBER
MOV BX, 1
MOV CX, 0
WHILE
MOV DX, 0
DIV BX
CMP DX, 0
JE CHECK
MOV AX, NUMBER
INC BX
CMP BX, AX
JL WHILE_
JMP END_
CHECK:
CMP AX, BX
JG INC_
JE INC2_
JMP END_
INC:
ADD CX, 2
MOV AX, NUMBER
INC BX
CMP BX, AX
JL WHILE_:
JMP END_
INC2_:
INC CX
JMP END_
END_:
ADD CX, 48
MOV AH,2
MOV DX, CX
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
RET
Get Answers For Free
Most questions answered within 1 hours.