汇编语言将字符串中小写字母转为大写

代码解释如下:

;问题:将字符串中的小写字母转换为大写
assume cs:code
data segment
	db 'I Like Coding use Assembly Language',0
data ends

stack segment
	db 128 dup(0)
stack ends

code segment
start:			mov ax,data
				mov ds,ax
				mov ax,0B800H
				mov es,ax
				mov ax,stack
				mov ss,ax
				mov sp,128
				call init_data
				call show_str
				mov ax,4c00h
				int 21h
;============================================================
init_data:		mov si,0
				mov di,160*10 + 64
				mov cx,10
				ret
;============================================================
show_str:		mov dl,ds:[si]
				cmp dl,0			;下面这两句代码不能写到cmp dl,'a'的后面
				je showStrRet
				cmp dl,'a'
				jb next
				cmp dl,'z'
				ja next
				and dl,11011111B	;andl操作将该字符转为大写
next:			mov es:[di],dl
				inc si
				add di,2
				jmp show_str
				
showStrRet:		ret
;============================================================				
code ends
end start


你可能感兴趣的:(汇编语言装X之路)