(組合語言)實驗11 編寫子程式
阿新 • • 發佈:2018-12-18
編寫一個子程式,將包含任意字元,以0結尾的字串中的小寫轉大寫
首先先用不是子程式的方法來解決一下:
assume cs:code data segment db "ZouZeBin is a handsome boy!!",0 data ends code segment start: mov ax,data mov ds,ax mov si,0 s: mov al,[si] cmp al,0 je ok cmp al,'A' jb next cmp al,'z' ja next cmp al,'Z' ja ltoh or byte ptr [si],00100000b jmp short next ltoh: and byte ptr [si],11011111b next: inc si jmp short s ok: mov ax,4c00h int 21h code ends end start
截圖:
接下來實現一種用子程式來解決的方法:
assume cs:code data segment db "ZouZeBin is a handsome boy!!",0 data ends code segment start: mov ax,data mov ds,ax mov si,0 call letterc mov ax,4c00h int 21h letterc: push ax push ds push si s: mov al,[si] cmp al,0 je ok cmp al,'A' jb next cmp al,'z' ja next cmp al,'Z' ja ltoh or byte ptr [si],00100000b jmp short next ltoh: and byte ptr [si],11011111b next: inc si jmp short s ok: pop si pop ds pop ax ret code ends end start