fjgjjvgg 2020-05-29 19:21 采纳率: 0%
浏览 118
已结题

求下面汇编程序的代码注释和程序流程图

这是一个显示键盘扫描码的汇编程序
.model small
.stack
.data
old_ip09 dw ?
old_cs09 dw ?
old_ip0f dw ?
old_cs0f dw ?
count dw ?
buffer db 20h dup('?')
buf_p dw ?
start_msg db 0ah,0dh,'RUN!'0ah,0dh,'$'
end_msg db 0ah,0dh,'end!'0ah,0dh,'$'
full_msg db 'buffer full !'0ah,0dh,'$'

.code
main proc far
start:
mov ax,@data
mov ds,ax

lea ax,buffer
mov buf_p ,ax
mov count,0

;save old interrupt 09h
mov al,09h
mov ah,35
int 21h
mov old_cs09,es
mov old_ip09,bx
push ds

;set new interrupt
lea dx,kdbint
mov ax,seg kdbint
mov ds,ax
mov al,09h
mov ah,25h
int 21h
pop ds

;set keyboard interrupt mask bits
in al,21h
and al,0fdh
out 21h,al

sti

mov di,20000
delay: mov si,30000
delay1: dec si
jnz delay1
dec di
jnz delay

mov di,20000
dey: mov si,30000
dey1: dec si
jnz dey1
dec di
jnz dey

mov di,20000
de: mov si,30000
de1: dec si
jnz de1
dec di
jnz de

mov di,20000
d: mov si,30000
d1: dec si
jnz d1
dec di
jnz d

cli
;save old
push ds
mov dx,old_ip09
mov ax,old_cs09
mov ds,ax
mov al,09h
mov ah,25h
int 21h
pop ds

;enable
in al,21h
and al,0fdh
out 21h,al
sti
mov ax,4c00h
int 21h
main endp
;...................

kdbint proc near
push ax
push bx
cld
in al,60h
push ax
in al,61h
mov ah,al
or al,80h
out 61h,al
xchg ah,al
out 61h,al
pop ax
test al,80h
jnz return1
mov bx,buf_p
mov [bx] ,al
call display_hex
inc bx
inc count
mov buf_p,bx
check:
cmp count ,20h
jb return1

return1:
cli
mov al,20h
out 20h,al
pop bx
pop ax
iret
kdbint endp

display_hex proc near
push ax
push cx
push dx
mov ch,2
mov cl,4
nextb:
rol al,cl
push ax
mov dl,al
and dl,0fh
or dl,30h
cmp dl,3ah
jl dispit
add dl,7h
dispit:
mov ah,2
int 21h
pop ax
dec ch
jnz nextb
mov ah,2
mov dl,','
int 21h
pop dx
pop cx
pop ax
ret
display_hex endp
end start

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2020-05-30 09:45
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?