.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_:
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
我试图找出数字 54 的因数,但它只给出一个因数 6。我需要帮助,以便可以使用程序集 8086 将多个数字因数显示为屏幕上的输出。
来自旧的 Masm 6.11 代码:
.model small,c
.stack 100
.data
number dw 54
.code
main proc
mov ax,@data
mov ds,ax
mov bx,2
mov ax,number
main0: mov dx,0 ;test a number
div bx
cmp dx,0
jne main2
main1: mov number,ax ;found a factor
mov ax,bx ;display 2 digit factor
mov dx,0
mov cx,10
div cx
mov cx,dx
mov dx,ax
mov ah,2
add dx,030h
int 21h
mov dx,cx
mov ah,2
add dx,030h
int 21h
mov ah,2
mov dx,020h
int 21h
dec bx ;test this factor again
main2: inc bx ;try next factor
mov ax,number
cmp bx,ax
jl main0
mov ax,4c00h
int 21h
main endp
end main