把下面 简单 汇编程序 加上详细注释

来源:百度知道 编辑:UC知道 时间:2024/09/22 08:27:45
1.程序功能 输入字符 按'q'退出
program segment
main proc far
assume cs:program
start:push ds
sub ax,ax
push ax
input:mov ah,01
;mov ah,07
int 21h
cmp al,'q'
je quit
mov dl,al
mov ah,02
int 21h
jmp input
quit:ret
main endp
program ends
end start
2.输出十六进制1EC8

data_seg segment
DATAX dw 1CE8H
data_seg ends

code_seg segment

main proc far
assume cs:code_seg,ds:data_seg
start:
push ds
sbb ax,ax
push ax
mov ax,data_seg
mov ds,ax
mov bx,DATAX
mov ch,4
rotate:
mov cl,4
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl print_it
add al,7h
print_it:
mov dl,al
mov ah,02h
int 21h
dec ch
jnz rotate

program segment
main proc far
assume cs:program
start:push ds ;这三条指令是为了能正确返回操作系统
sub ax,ax
push ax

input:mov ah,01 ;调用中断从键盘输入一个字符,字符的ASCII码在AL中
;mov ah,07
int 21h
cmp al,'q' ;比较输入的字符是否为'q',是则跳到标号quit
je quit
mov dl,al
mov ah,02 ;如果不是'q'则调用中断输出到屏幕
int 21h
jmp input ;跳到标号input继续输入字符
quit:ret ;退出程序
main endp
program ends
end start
2.输出十六进制1EC8

data_seg segment
DATAX dw 1CE8H
data_seg ends

code_seg segment

main proc far
assume cs:code_seg,ds:data_seg
start:
push ds ;这三条指令是为了能正确返回操作系统
sbb ax,ax
push ax

mov ax,data_seg ;将数据段的段地址放入DS中
mov ds,ax

mov bx,DATAX ;将变量DATAX中的数放入BX中
mov ch,4
rotate:
mov cl,4 ;CL中的数是为了使用移位指令,大小为移