字母大小写转换
8086汇编字母大小写转换
一、 要求
从键盘输入字母,将大写字母转化为小写字母,将小写字母转化为大写字母,
然后在字幕上显示转换后的结果。(键盘输入在所有大小写字母的ASCLL范围内
则转换,否则报错)
二、 汇编代码
; multi-segment executable file template.
data segment
; add your data here!
letterdb 0
pkeydb 0dh,0ah,'please input your letter...',0dh,0ah,'$'
pkey1db 0dh,0ah,'are you contine...',0dh,0ah,'$' pkey2db 0dh,0ah,'your letter is wrong!',0dh,0ah,'$'
pkey3db 0dh,0ah,'the transformational letter is',0dh,0ah,'$'
ends
stack segment
dw 128 dup(0)
ends
code segment
assumecs:code,ds:data,ss:stack
start:
; set segment registers:
mov ax, data
mov ds, ax
moves, ax
; add your code here
cnt:
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
movletter,al cmp al,'@'
jcless_than
jncgreater_than
greater_than: cmp al,'{'
jc less_than1 jnc greater_than1
less_than:
lea dx, pkey2 mov ah, 9
int 21h
jmp quit
greater_than1: lea dx, pkey2 mov ah, 9
int 21h
jmp quit
less_than1:
cmpal,'a'
jc less_than2 jnc greater_than2
greater_than2: lea dx, pkey3 mov ah, 9
int 21h
moval,letter sub al,32
movletter,al movdl,letter mov ah,2
int 21h
lea dx, pkey1 mov ah, 9
int 21h
mov ah,1
int 21h
cmpal,'n' je quit cmpal,'N' je quit
jmpcnt
less_than2: lea dx, pkey3 mov ah, 9
int 21h
moval,letter add al,32
movletter,al movdl,letter mov ah,2
int 21h
lea dx, pkey1 mov ah, 9
int 21h
mov ah,1
int 21h
cmpal,'n' je quit cmpal,'N' je quit
jmpcnt
quit:mov ax, 4c00h ; exit to operating system.
int 21h ends
end start ; set entry point and stop the assembler.
三、 运行结果
本文档为【字母大小写转换】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。