使用匯編實現字串的大小寫轉換
阿新 • • 發佈:2019-02-10
使用匯編程式設計,可以直接訪問記憶體中的資料,對資料進行相關操作,現在需要通過彙編指令and,or對字串資料進行大小寫轉換。如下例,將BaSiC轉換成大寫,將iNforMaTiOn轉換成小寫。
例子:
assume cs:codesg,ds:datasg datasg segment db 'BaSiC' db 'iNforMaTiOn' datasg ends codesg segment start: mov ax,datasg mov ds,ax mov cx,5 mov bx,0 s1: mov al,ds:[bx] and al,11011111b mov ds:[bx],al inc bx loop s1 mov cx,11 mov bx,5 s2: mov al,ds:[bx] or al,00100000b mov ds:[bx],al inc bx loop s2 mov ax,4c00h int 21h codesg ends end start