ArthurSAS 2015-06-11 15:39 采纳率: 33.3%
浏览 1738

求帮忙注释下汇编程序代码

len equ 10
.model small
.stack 100h

.data
input_msg db 0dh,0ah,'Input Number '

Num_no db '00 (0-255):$'

no_str db 'Nothing, NO ODD NUMBER !','$'
buf db 4,0,4 dup (0)
input_data db 10 dup (0)
result_str db 0dh,0ah,'The minimum odd number is $'
first_lo dw 0
first_hi dw 0

.code
start:
MOV AX,@DATA
MOV DS,AX
mov es,ax
cld
call cls
mov cx,10
mov di,offset input_data

s10:
push cx
push di
mov buf + 1,0 ;clear
inc Num_no + 1
cmp Num_no + 1,'9'
jbe s20
mov Num_no + 1,'0'
inc Num_no

s20:
lea dx,input_msg
call get_input
cmp first_hi,0
jnz s20
mov ax,first_lo
cmp ax,255
ja s20

pop di
stosb ;save result
pop cx
loop s10

mov ah,09
mov dx,offset result_str
int 21h

LEA si,input_data
mov bl,255
MOV CX,Len
xor dx,dx

next1:
lodsb
test al,1
jz next2
cmp al,bl
ja next2
inc dx
xchg al,bl
next2:
loop next1
cmp bl,255
jz next3
mov al,bl
call BCD_output
next3:
cmp dx,0
jnz quit
mov dx,offset no_str
mov ah,9
int 21h
quit:
MOV AH,4CH
INT 21H
;-------------------------
; output Al (0-255) BCD output
BCD_output:
push dx
push cx
xor cx,cx
bcd5:
add al,0
aam
bcd7:
push ax
inc cx
or ah,ah
jz bcd20
cmp ah,0Ah
jb bcd10
mov al,ah
xor ah,ah
jmp short bcd5
bcd10:
mov al,ah
xor ah,ah
jmp short bcd7
bcd20:
pop dx
or dl,'0'
mov ah,2
int 21h
loop bcd20
pop cx
pop dx
ret
;-------------------------
cls:
mov ah,0fh
int 10h
mov ah,0
int 10h
ret
;-------------------------
get_input:
xor ax,ax
mov first_lo,ax
mov first_hi,ax
mov ah,9
int 21h
mov buf+1,0 ;clear
lea dx,buf
mov ah,10
int 21h
mov cl,buf+1
xor ch,ch
xor bx,bx ; clear
xor dx,dx ;clear
lea si,buf + 2 ;offset
call dtoh
jc get_input
ret
;-------------------------
;si = string offset
;calc dec to hi-lo buffer
dtoh:
push ax
push bx
push cx
push dx
push si
push bp
lea si,buf + 2
xor dx,dx
mov bx,10
d10:
lodsb
cmp al,0dh
jz d20
jz d20
cmp al,'0'
jae d15

d12:
stc
jmp short d20

d15:
cmp al,'9'
ja d12
sub al,30h
cbw
mov bp,ax ;store to bp
mov ax,first_hi ;get first_hi
mul bx ;x 10
mov first_hi,ax ;store to key hi
mov ax,bp ;restore from bp
xchg ax,first_lo ;get key lo
mul bx ;x 10
xchg ax,first_lo ;store to key lo
add first_lo,ax ;add low byte to key lo
adc first_hi,dx ;add to key hi
jnc d10
jmp short d12
d20:
pop bp
pop si
pop dx
pop cx
pop bx
pop ax
ret
;--------------------------------
END START

  • 写回答

2条回答

  • lx624909677 2015-06-12 02:00
    关注

    下载一个汇编指令查询器,然后一个一个的查指令自己翻译吧

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮