汇编借助于条件转移实现循环判断是否为平方数
程序员文章站
2022-03-11 18:37:52
...
已知一个两位十进制数存于字类型变量x中,请判断是不是平方数
data segment
x dw 36
data ends
code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov cx,0
mov bx,x
L1:
mov dx,0
mov ax,bx
inc cx
div cx
cmp cx,9
ja L2
cmp cx,ax
jnz L1
cmp dx,0
jnz L1
L3:
mov dl,'y'
jmp L4
L2:
mov dl,'n'
L4:
mov ah,02h
int 21h
mov ax,4c00h
int 21h
main endp
code ends
end start