【汇编 题目】48 如何判断一个不超过65535的整数是否为质数

汇编指令英文全称

注意事项

  1. 注意使用的跳转指令je(jump when equal)

源代码

assume cs:codes,ds:datas

;description
datas SEGMENT 
    yes db 'Yes','$'
    no db 'No','$'
    buf dw 60000
datas ENDS


;description
codes SEGMENT 
start:
    mov ax,datas
    mov ds,ax

    mov bx,buf
    dec bx
next:
    cmp bx,1
    je yes0             ;if bx=1, then jump 
    mov ax,buf          
    mov dx,0
    div bx              ;buf/bx,余数存在dx中
    cmp dx,0            
    je no0              ;如果余数为0,跳转并输出No
    dec bx              ;bx自减一
    jmp next            ;继续循环
no0:
    lea dx,no
    mov ah,09h
    int 21h
    jmp exit
yes0:
    lea dx,yes
    mov ah,09h
    int 21h
    jmp exit
exit:
    mov ah,4ch
    int 21h
codes ENDS
    end start

猜你喜欢

转载自blog.csdn.net/qq_43874964/article/details/109723109