当前位置:网站首页>Compile homework after class
Compile homework after class
2022-07-06 17:02:00 【My71】
Homework 1: Letter conversion
demand
- prompt # No. end procedure .
- Prompt for a character .
- Judge whether the character is legal (a~z A~Z)
- Legal input : Prompt the conversion result : Enter the conversion result .
- illegal input : Count , End the program more than three times .
- Input # No. end procedure .
flow chart

Code implementation
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: ; 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: ; Handle capitalization
cmp al,41h
jl error
add al,20h
jmp print
lower: ; Handle lowercase
cmp al,7ah
jg error
sub al,20h
jmp print
print: ; Output
mov dx,offset result
call ah09
mov dl,al
call ah02
call br
jmp start
error: ; Error handling
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
Homework 2: Timer effect
demand
- 00 ~ 99 Cycle show .
- Print a number every time .
- Clear the last output number before printing the current number .
- Press any key to exit the program
flow chart

Code implementation
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
Homework 3: Analog hexadecimal conversion
demand
- Put the value to be converted into BL In the register ( Advanced version : Input from keyboard )
- Output BL Binary and hexadecimal data stored in .
flow chart

Code
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
边栏推荐
猜你喜欢

谢邀,人在工区,刚交代码,在下字节跳动实习生

字节跳动技术面试官现身说法:我最想pick什么样的候选人

Description of project structure configuration of idea

Shell_ 02_ Text three swordsman

Activiti directory (III) deployment process and initiation process

Activit零零碎碎要人命的坑

Activiti directory (V) reject, restart and cancel process

7-5 blessing arrived

程序员定位解决问题方法论

这116名学生,用3天时间复刻了字节跳动内部真实技术项目
随机推荐
README. txt
Shell_ 00_ First meeting shell
TCP的三次握手和四次挥手
字节跳动春招攻略:学长学姐笔经面经,还有出题人「锦囊」
Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment
唯有学C不负众望 TOP3 Demo练习
js垃圾回收机制和内存泄漏
~84 form supplement
7-12 inventory code base
字节跳动技术面试官现身说法:我最想pick什么样的候选人
搭建flutter环境入坑集合
Cartesian tree (modified)
LeetCode 1637. The widest vertical area between two points without any point
How to generate six digit verification code
Introduction to microservices
MySQL字符串函数
唯有学C不负众望 TOP4 S1E6:数据类型
7-5 blessing arrived
~73 other text styles
[unsolved] 7-15 shout mountain