王爽《汇编语言》实验11:编写子程序letterc 解答

时间:2021-02-15 01:15:18
assume cs:codesg

datasg segment
	db "Beginner's All-purpose Symbolic Instruction Code.",0
datasg ends

codesg segment
begin:
	mov ax,datasg
	mov ds,ax
	mov si,0

	call letterc

	mov ax,4c00h
	int 21h

letterc:
	push si

	s0:     
	mov al,[si]
	cmp al,0
	je exitsub ;如果到底结束符,跳转到exitsub
	
	mov ah,'a'
	cmp al,ah
	jb next
	
	mov ah,'z'
	cmp al,ah
	ja next

	and al,11011111B    ;或使用sub al,20h
	mov [si],al

	next:   
	inc si
	jmp short s0

	exitsub:
	pop si
	ret
codesg ends

end begin