运用标志寄存器的比较指令

assume cs:codesg
datasg segment
        db "Beginner's All-purpose Symbolic Instruction Code." , 0
datasg ends
codesg segment
start:  mov ax , datasg
        mov ds , ax
        mov si , 0
        call letterc             ; 调用子程序
        mov ax , 4c00h
        int 21h
letterc:mov cl , [si]
        mov ch , 0
        jcxz finish               ; 如果读到最后的 0 就跳转
        cmp byte ptr[si] , 41h                         ; 和 A 的ascii比较,修改标志寄存器
        jb s                              ; 小于 A 就跳转,不用大小写转换
        cmp byte ptr[si] , 7Ah                         ; 和 z 的ascii比较,修改标志寄存器
        ja s                           ; 大于 z 就跳转
        and byte ptr[si] , 11011111b      ; 小写改大写
s:        inc si
        jmp short letterc
finish:        ret       ; 程序结束,跳转执行call后的指令
codesg ends
end start




 
原文地址:https://www.cnblogs.com/meihao1203/p/8023260.html