⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conver.asm

📁 从键盘输入一个字符串,先把它原样显示一遍 然后将其中的小写字母转换为大写显示,再将其中的大写字母转换为小写显示,最后将其中的大小写字母互换显示.显示字符串的功能调用采用宏,大写转换,小写转换和大小写互
💻 ASM
字号:
 cmdenter MACRO 
                    mov ah ,02h
                    mov dl ,0dh
                    int 21h
                    mov dl ,0ah
                    int 21h
          ENDM
dispmsg	macro  message	;显示message字符串
	mov dx,offset message
	mov ah,9
	int 21h
	endm
dispmsg1 macro name,length
	local again,quit
	lea si,name+2
	mov cl,length
again:	cmp cl,0
				je quit
				mov dl,[si]
				mov ah,02
				int 21h
				dec cl
				inc si
				jmp again
	quit:
	endm
.model small
.stack
.data
input db 'input a string ',0dh,0ah,'$'
sourstr db 50,0,50  dup(0)
highstr db 50, 0,50 dup(0)
lowstr db 50, 0,50 dup(0)
converstr db 50,0,50 dup(0)
.code
;----------------------------------------------
contohigh proc near
push si
push di
push cx
push ax
	lea si,[sourstr+2]
	lea di,[highstr+2]
	xor cx,cx
	mov cl,[si+1]
  again:cmp cl,0
      	je high_exit
      	mov al,[si]
      	mov [di],al
      	cmp al,'a'
      	jb high_con
      	cmp al,'z'
      	ja high_con
      	sub al,20h
      	mov [di],al
	high_con:
	
			inc di
       inc si
       dec cl
       jmp again
  high_exit:
  pop ax
  pop cx
  pop di
  pop si
     ret
contohigh endp
;----------------------------------------------------
contolow proc near
push si
push di
push cx
push ax
	lea si,[sourstr+2]
	lea di,[lowstr+2]
	xor cx,cx
	mov cl,[si+1]
low_again:cmp cl,0
      	je low_exit
      	mov al,[si]
      	mov [di],al
      	cmp al,'A'
      	jb low_con
      	cmp al,'Z'
      	ja low_con
      	add al,20h
      	mov [di],al
	low_con:
	
			inc di
       inc si
       dec cl
       jmp low_again
  low_exit:
  pop ax
  pop cx
  pop di
  pop si
     ret
contolow endp
;----------------------------------------------------
toconverse proc near
push si
push di
push cx
push ax
	lea si,[sourstr+2]
	lea di,[converstr+2]
	xor cx,cx
	mov cl,[si+1]
 conver_again:cmp cl,0
      	je conver_exit
      	mov al,[si]
      	mov [di],al
      	cmp al,'a'
      	jb hightolow
      	cmp al,'z'
      	ja c_com
      	sub al,20h
      	mov [di],al
      	jmp c_com
	hightolow:
			cmp al,'A'
			jb c_com
			cmp al,'Z'
			ja c_com
			add al,20h
			mov [di],al

	c_com:
			inc di
       inc si
       dec cl
       jmp conver_again
  conver_exit:
  pop ax
  pop cx
  pop di
  pop si
     ret

toconverse endp

.startup
dispmsg input
mov dx,offset sourstr
mov ah,0ah
int 21h
cmdenter
mov al,[sourstr+1]
mov [highstr+1],al
mov [lowstr+1],al
mov [converstr+1],al
dispmsg1 sourstr,al;显示输入字符串
cmdenter

call contohigh;把小写转成大写
dispmsg1 highstr,[highstr+1]
cmdenter

call contolow;把大写转成小写
dispmsg1 lowstr,[lowstr+1]
cmdenter
call toconverse;大小写互换
dispmsg1 converstr,[converstr+1]
.exit 0
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -