字母大小写转换
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
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.
三、运行结果