Use call and ret instructions to convert the c string ending in 0 to uppercase

assume cs:code, ss:stack

data segment
	db 'word', 0
	db 'unix', 0
	db 'wind', 0
	db 'good', 0
data ends

stack segment
dw 0,0,0,0,0,0,0,0
stack ends

code segment
start:	mov ax, stack
		mov ss, ax
		mov sp, 16
		mov ax, data
		mov ds, ax
		mov bx, 0
		
		mov cx, 4
		
	  s:push cx
		mov si, bx
		call capital
		add bx, 5
		pop cx
		loop s
		
		mov ax, 4C00H
		int 21H
		
capital:mov cl, [si]		;把ds:[si]中存的数据给cl
		mov ch, 0
		jcxz ok				;当cx为0时跳转,也就是一个字符串结尾时跳转
		and byte ptr [si], 11011111B
		inc si
		jmp short capital
	 ok:ret
code ends
end start
78 original articles published · Like 3 · Visits 5596

Guess you like

Origin blog.csdn.net/qq_43071318/article/details/105426319