汇编语言随笔(9)-实验11(用条件转移指令来编写子程序)

      编写一个子程序,将包含任意字符、以0结尾的字符串中的小写字母转变为大写字母
子程序名称:letterc      参数:ds:si指向字符串首地址。

      因为字符串中包含有任意字符,所以不能采用and操作,而需要采用条件转移指令。

	assume cs:codesg
	data segment
		db "Beginner's All-purpose Symbolic Instruction Code.",0
	data ends
	codesg segment
	begin: mov ax,data
		   mov ds,ax
		   mov si,0
		   call letterc

		   mov ax,4c00h
		   int 21h
	
 letterc: push ds
 		  push si
 		  push ax
 		  push bx

	   s: mov al,[si]
		  cmp al,0
		  je done
		  cmp al,'a'
		  jb next
		  cmp al,'z'
		  ja next
		  sub al,20h		也可以写成sub byte ptr [si],20h
		  mov [si],al
    next: inc si
    	  jmp short s

	 done:pop bx
	 	  pop ax
	 	  pop si
	 	  pop ds
	 	  ret
	 	  
	codesg ends
	end start

Guess you like

Origin blog.csdn.net/Little_ant_/article/details/108345209