assume cs:codesgdatasg segment
db 'beginnner`s all-purpose symbolic instruction code.',0
datasg ends
codesg segment
begin: mov ax,datasg
mov ds,ax
mov si,0
;轉換前回顯字串
call showstr
;執行轉換函式
call letterc
;換行mov dl, 10
mov ah,6
int 21h
mov dl, 13
mov ah,6
int 21h
;轉換後回顯字串
call showstr
mov ax,4c00h
int 21h
;把小寫字母轉換為大小字母的函式
letterc:
;儲存現場
push ax
push cx
push si
start: ;判斷讀取到的字元是否為0
;若為0就跳轉到返回功能塊
mov ch,0
mov cl,[si]
jcxz endfunc
;若不是0就繼續
;判斷讀取到的字元是否為小寫字元
mov al,61h
cmp cl,al
jb continue ;如果ascii碼小於97(a)跳過轉換步驟繼續遍歷字串
mov al,7ah
cmp cl,al
ja continue ;如果ascii碼大於122(z)跳過轉換步驟繼續遍歷字串
;如果經歷這麼多困難還執行到這一步,那麼呵呵,你就肯定要變大咯!!
and cl,11011111b
mov [si],cl
continue:
inc si
jmp short start
endfunc:
;函式結束恢復現場
pop si
pop cx
pop ax
ret;回顯ds:[si]中的字串,以0作為結束標誌
showstr:
;儲存現場
push ax
push cx
push si
;判斷讀取到的字元是否為0
;若為0就跳轉到返回功能塊
strbegin: mov ch,0
mov cl,[si]
jcxz strend
mov dl, [si]
mov ah,02
int 21h
inc si
loop strbegin
strend:
;恢復現場
pop si
pop cx
pop ax
retcodesg ends
end begin
1125 小寫字母變為大寫字母
小寫字母變為大寫字母 time limit 2000ms memory limit 65536k total submit 225 accepted 171 description 寫乙個程式把乙個字串 可能含有空格,長度最長不超過1000 中的小寫字母轉化為大寫字母。input 輸入只有一行,可以...
akoj 1125 小寫字母變為大寫字母
小寫字母變為大寫字母 time limit 2000ms memory limit 65536k total submit 149 accepted 114 description 寫乙個程式把乙個字串 可能含有空格,長度最長不超過1000 中的小寫字母轉化為大寫字母。input 輸入只有一行,可以...
AKOJ 1125小寫字母變為大寫字母
小寫字母變為大寫字母 time limit 2000ms memory limit 65536k total submit 310 accepted 230 原題鏈結 description 寫乙個程式把乙個字串 可能含有空格,長度最長不超過1000 中的小寫字母轉化為大寫字母。input 輸入只有...