把这个汇编语言逐句翻译下

data segment
temp dw ?
data ends
decihex segment
assume cs:decihex,ds:data
main proc far
nexts:
call decibin
mov temp,bx
call decibin
mov ax,temp
add bx,ax
call hexibin
call crlf
call binihex
call crlf
jmp nexts
main endp
hexibin proc near
mov ax,bx
mov cx,1h
xor bx,bx
loop2:mov dl,10d
div dl

mov dl,ah
xor ah,ah
cbw
mov temp,ax

xor ax,ax
mov al,dl
cbw
mul cx
add bx,ax

mov ax,cx
mov dx,10h
mul dx
mov cx,ax

mov ax,temp
cmp ax,0d
je exit2
jne loop2
exit2:
ret
hexibin endp
binihex proc near
mov ch,4
rotate: mov cl,4
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl printit
add al, 7h
printit: mov dl, al
mov ah, 2
int 21h
dec ch
jnz rotate
ret
binihex endp
decibin proc near
mov bx,0
newchar:mov ah,1
int 21h
sub al,30h
jl exit
cbw
xchg ax,bx
mov cx,10d
mul cx
xchg ax,bx
add bx,ax
jmp newchar
exit: ret
decibin endp
crlf proc near
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
crlf endp
decihex ends
end main

这是一个并不十分规范的汇编程序
其功能是对输入的两个十进制数求和,并显示结果。程序没有按正常方式返回,但可以用CTRL+C结束。
“逐句翻译”实在没有必要,简要说明如下:
程序中含一个主程序(main proc far)和4个子程序(hexibin proc near ;binihex proc near ;decibin proc near;crlf proc near)

data segment ;数据段
temp dw ? ;定义一个字,保存输入的第一个数
data ends

decihex segment ;代码段
assume cs:decihex,ds:data
main proc far ;主程序开始
nexts:
call decibin ;调用输入子程序,输入第一个加数,结果在BX中
mov temp,bx ;保存输入的第一个数
call decibin ;调用输入子程序,输入第二个加数,结果在BX中
mov ax,temp ;将第一个加数放入AX
add bx,ax ;将两个数相加,结果在BX中
call hexibin ;调用将16进制数转换成10进制表示的数子程序
call crlf ;调用回车换行子程序
call binihex ;调用输出子程序
call crlf ;调用回车换行子程序
jmp nexts ;继续做下一个加法。。。
main endp ;主程序结束
;=====================
hexibin proc near ;将和转换成16进制表示的10进制数,如:13+24=37 在BX中表示的和为25(H),通过该子程序调用后,BX=0037(H). 该子程序主要算法是除10取余,但代

码太繁琐。。。 晕!
mov ax,bx
mov cx,1h
xor bx,bx
loop2:mov dl,10d
div dl

mov dl,ah
xor ah,ah
cbw
mov temp,ax

xor ax,ax
mov al,dl
cbw
mul cx
add bx,ax

mov ax,cx
mov dx,10h
mul dx
mov cx,ax

mov ax,temp
cmp ax,0d
je exit2
jne loop2
exit2:
ret
hexibin endp
;=====================
binihex proc near ;输出子程序。将BX中16进制表示的10进制数按10进制位逐位输出。 假如:BX=1234H
mov ch,4 ;循环数4次
rotate: mov cl,4 ;移位数
rol bx,cl ;BX循环左移4位,BX:1234H ==>> 2341H
mov al,bl ;将BL送AL,即:将41H送AL
and al,0fh ;只保留AL低4位 即:AL=01H
add al,30h ;转换成ASCII码以便输出 AL=31H
cmp al,3ah
jl printit
add al, 7h
printit: mov dl, al
mov ah, 2 ;调用DOS 2号功能输出一个字符 ,4次循环依次输出1 2 3 4
int 21h
dec ch ;减一次循环计数
jnz rotate ;转循环
ret
binihex endp
;======================
decibin proc near ;输入子程序,输入的最终数保存在BX中
mov bx,0 ;置BX初值位0
newchar:mov ah,1 ;调用DOS 1号功能输入一个字符,输入的结果在AL中
int 21h
sub al,30h ;将输入的ASCII码转换成数字
jl exit ;如果输入字符的ASCII码小于“0”则直接返回(主程序),如:"+ - / " 空格 等字符
cbw ;将AL的8位值扩展到16位的AX
xchg ax,bx ;将AX与BX交换,交换的目的是需将已输入的数(在BX中,且初值为0)进位(乘以10),而执行乘法时要用到AX寄存器
mov cx,10d ;执行BX*10 结果在 DX:AX中
mul cx
xchg ax,bx ;此指令完全多余!
add bx,ax ;将乘以10以后的值再加上这次的数。 比如:第一次输入2,第二次输入8,结果是2*10+8=18;若再输入3,则结果是18*10+3=183.
jmp newchar ;输入下一个字符
exit: ret
decibin endp
;===================
crlf proc near ;回车换行子程序(很简单)
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
crlf endp
;====================
decihex ends
end main追问

那你能不能写一个简单的汇编语言就是键盘输入的十进制加法结果输出也是十进制,也逐句翻译一下

追答

;无论多简单,也是N多行。。。
;在原来程序基础上做了修改,重写了转换输出部分。
;不能处理大于65535的数

data segment ;数据段
temp dw ? ;定义一个字,保存输入的第一个数
sum db 0DH,0AH,5 dup (" "),0DH,0AH,'$' ;定义结果输出串,其中0DH,0AH相当于回车换行
data ends

decihex segment ;代码段
assume cs:decihex,ds:data
main proc far ;主程序开始
mov ax,data
mov ds,ax
push ds
pop es
nexts:
call decibin ;调用输入子程序,输入第一个加数,结果在BX中
mov temp,bx ;保存输入的第一个数
call decibin ;调用输入子程序,输入第二个加数,结果在BX中
mov ax,temp ;将第一个加数放入AX
add bx,ax ;将两个数相加,结果在BX中
call print_c ;调用显示结果子程序
jmp nexts ;继续做下一个加法。。。
main endp ;主程序结束
;=====================
print_c proc near ;显示结果子程序. 将和转换成10进制数并显示。
;实质是将存放和的BX依次除以10000、1000、100、10,然后依次显示其商及最后的余数
mov di,offset sum ;存放10进制显示串的起始地址
mov ax,bx ;BX是和,也就是要转换的被除数,放入AX
mov bx,10000 ;10000是第一个除数,因为AX的最大值是65535
mov dx,0 ;当除数是16位的BX时,被除数是DX:AX,所以DX必须置0
div_again:

div bx ;DX:AX/BX
cmp bx,10 ;当BX=10时结束转换
jnz save
add al,30h ;10位
mov [di],al
inc di
add dl,30h
mov [di],dl ;个位
jmp disp ;转显示
save:
add al,30h
mov [di],al ;保存商位
inc di
push dx ;余数继续除
mov dx,0
mov ax,bx
mov bx,10 ;需将除数依次缩小10倍(即:10000、1000、100、10),所以每次要要除10
div bx
mov bx,ax
pop ax
xor dx,dx
jmp div_again
disp:
mov ah,9 ;显示结果
mov dx,offset sum
int 21h
ret
print_c endp
;======================
decibin proc near
;因字数限制,此段子程序省略。。。
decibin endp

;====================
decihex ends
end main

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-11-06
数据段
  临时dw吗?
  数据结束
  decihex段
  假定cs:decihex,ds:数据
  主要过程远
  nexts:
  叫decibin
  mov临时雇员、bx
  叫decibin
  mov斧,临时
  添加bx、斧
  叫hexibin
  叫crlf
  叫binihex
  叫crlf
  nexts该科通过就业选配计划
  主要endp
  附近hexibin触发
  mov斧,bx
  mov cx、1 h
  xor bx、bx
  loop2:mov dl、10 d
  师dl
  
  mov黎宇光,呵呵
  xor呀,
  生化
  mov临时雇员、斧
  
  xor斧,ax
  mov铝、dl
  生化
  cx度