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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题