当前位置:网站首页>汇编课后作业
汇编课后作业
2022-07-06 09:29:00 【My71】
作业1:字母转换
需求
- 提示输入 # 号结束程序。
- 提示输入一个字符。
- 判断字符是否合法(a~z A~Z)
- 合法输入:提示转换结果:输入转换结果。
- 非法输入:计数,超过三次结束程序。
- 输入 # 号结束程序。
流程图

代码实现
data segment
count db 33h
input db "Input $"
program db " end of the program$"
prompt db "Please enter a character: $"
message db "Please enter the correct characters $"
result db "The results: $"
data ends
code segment
assume cs:code,ds:data
main:
mov ax,data
mov ds,ax
mov dx,offset input
call ah09
mov dl,23h
call ah02
mov dx,offset program
call ah09
call br
jmp start
start: ;开始
mov dx,offset prompt
call ah09
mov ah,01h
int 21h
call br
cmp al,23h
jz edit
cmp al,5bh
jl upper
cmp al,60h
jg lower
upper: ;处理大写
cmp al,41h
jl error
add al,20h
jmp print
lower: ;处理小写
cmp al,7ah
jg error
sub al,20h
jmp print
print: ;输出
mov dx,offset result
call ah09
mov dl,al
call ah02
call br
jmp start
error: ;错误处理
dec count
cmp count,30h
jz edit
mov dx,offset message
call ah09
call br
jmp start
edit:
mov ah,4ch
int 21h
ah09 proc near
push ax
mov ah,09h
int 21h
pop ax
ret
ah09 endp
ah02 proc near
push ax
mov ah,02h
int 21h
pop ax
ret
ah02 endp
br proc near
push dx
mov dl,0ah
call ah02
pop dx
ret
br endp
code ends
end main
作业2:计时器效果
需求
- 00 ~ 99 循环显示。
- 每个一段时间打印一个数字。
- 打印当前数字前清除上一次输出的数字。
- 按任意键退出程序
流程图

代码实现
data segment
ten db 30h
bis db 30h
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
fbis:
mov ah,0bh
int 21h
cmp al,00h
jnz exit
mov dl,ten
call d02
mov dl,bis
call d02
call timer
mov dl,0dh
call d02
inc bis
cmp bis,3ah
jb fbis
inc ten
mov bis,30h
cmp ten,3ah
jb fbis
mov ten,30h
mov bis,30h
jmp fbis
exit:
mov ah,4ch
int 21h
d02 proc near
mov ah,02h
int 21h
ret
d02 endp
timer proc near
push cx
push dx
mov cx,1000h
fori:
mov dx,50h
forj:
dec dx
cmp dx,0h
jg forj
dec cx
cmp cx,0h
jg fori
pop dx
pop cx
ret
timer endp
code ends
end start
作业3:模拟进制转换
需求
- 将需要转换的值放到 BL 寄存器中(高阶版本:从键盘输入)
- 输出 BL 中存放数据的二进制和十六进制。
流程图

代码
code segment
assume cs:code
start:
mov bl,0a1h
call toBinary
call toHexade
edit:
mov ah,4ch
int 21h
toBinary proc near
push bx
push cx
push dx
mov cx,8
loopi:
rol bl,1
mov dl,bl
and dl,01h
add dl,30h
call d02
loop loopi
mov dl,'B'
call d02
call br
pop dx
pop cx
pop bx
ret
toBinary endp
toHexade proc near
push bx
push cx
push dx
mov cx,2
loopj:
push cx
mov cl,4
rol bl,cl
pop cx
mov dl,bl
and dl,0fh
cmp dl,09h
jg letter
jng number
letter:
add dl,37h
jmp print
number:
add dl,30h
print:
call d02
loop loopj
mov dl,'H'
call d02
pop dx
pop cx
pop bx
ret
toHexade endp
d02 proc near
mov ah,02h
int 21h
ret
d02 endp
br proc near
push dx
mov dl,0ah
call d02
pop dx
ret
br endp
code ends
end start
边栏推荐
- Basic principles of video compression coding and audio compression coding
- ~Introduction to form 80
- Fdog series (VI): use QT to communicate between the client and the client through the server (less information, recommended Collection)
- Soft music -js find the number of times that character appears in the string - Feng Hao's blog
- 力扣leetcode第 280 场周赛
- Use JQ to realize the reverse selection of all and no selection at all - Feng Hao's blog
- After the subscript is used to assign a value to the string type, the cout output variable is empty.
- Audio and video development interview questions
- ~77 linear gradient
- 「博士毕业一年,我拿下 ACL Best Paper」
猜你喜欢

7-4 harmonic average

视频压缩编码和音频压缩编码基本原理

我走過最迷的路,是字節跳動程序員的腦回路

LeetCode 1641. Count the number of Lexicographic vowel strings

Soft music -js find the number of times that character appears in the string - Feng Hao's blog

字节跳动开源GAN模型压缩框架,算力最高节省97.8%丨ICCV 2021

SQL快速入门

redux使用说明

One hundred questions of image processing (1-10)

Submit several problem records of spark application (sparklauncher with cluster deploy mode)
随机推荐
Fdog series (III): use Tencent cloud SMS interface to send SMS, write database, deploy to server, web finale.
~Introduction to form 80
Solve the single thread scheduling problem of intel12 generation core CPU (II)
Chapter 6 datanode
视频压缩编码和音频压缩编码基本原理
LeetCode 1566. Repeat the pattern with length m at least k times
「博士毕业一年,我拿下 ACL Best Paper」
Design of DS18B20 digital thermometer system
DS18B20數字溫度計系統設計
The most lost road I have ever walked through is the brain circuit of ByteDance programmers
Eureka high availability
字节跳动海外技术团队再夺冠:高清视频编码已获17项第一
~82 style of table
~83 form introduction
ByteDance 2022 school recruitment R & D advance approval publicity meeting, students' top 10 issues
姚班智班齐上阵,竞赛高手聚一堂,这是什么神仙编程大赛?
LeetCode 1550. There are three consecutive arrays of odd numbers
Cmake error: could not create named generator visual studio 16 2019 solution
Educational Codeforces Round 122 (Rated for Div. 2)
[unsolved] 7-15 shout mountain