+ -
当前位置:首页 → 问答吧 → -------------------高手快来呀。------------------

-------------------高手快来呀。------------------

时间:2010-12-25

来源:互联网

从键盘中键入两个4位数,分别保存到BUF1和BUF2存储区中,进行求和,求和的结果送至变量SUM当中,并进行显示 用“汇编语言”的!!
 比如输入1234  
  5678
得出结果是6912
 比如输入9999
  1111
 得出结果是11110
  这里要注意有进位和无进位 
 
不要用VB或者VC的、是汇编语言的!!!比如这样的:
  MOV AX,NA
  CMP AX,NB
 

作者: l527749   发布时间: 2010-12-25

好像前几天有人问过这个问题,且已有人回答了。

作者: shzhfu   发布时间: 2010-12-25

Assembly code

assume    cs:code,ds:data,ss:stack
stack    segment stack
    dw    32 dup (0)
stack    ends
data    segment
buff    db    5,0,5 dup (0)
num    dw    2 dup (0)
data    ends
code    segment
start:
    mov ax,data
    mov ds,ax
    mov cx,2
    mov bx,offset num
s:
    push cx
    push bx
    mov dx,offset buff
    mov ah,10
    int 21h
    mov ax,0
    mov si,offset buff+2
    mov cl,buff+1
s1:    
    mov bx,10    
    mul bx
    mov dl,[si]
    and dx,0fh
    add ax,dx
    inc si
    loop s1
    
    call crlf
    pop bx
    pop cx
    mov word ptr [bx],ax
    add bx,2
    loop s
;
    xor dx,dx
    xor ax,ax
    mov ax,num
    add ax,num+2
    adc dx,0
    call show
;
    mov ah,4ch
    int 21h
;
crlf    proc uses ax dx
    mov ah,2
    mov dl,0dh
    int 21h
    mov dl,0ah
    int 21h
    ret
crlf    endp
;
;DX:AX
show    proc uses ax bx cx dx si 
    mov bx,10
    mov si,0
_divdw:
;    cmp ax,10
;    jb _ok
    push ax
    mov ax,dx
    xor dx,dx
    div bx
    mov cx,ax
    pop ax
    div bx
    add dl,30h
    push dx
    inc si
    mov dx,cx
    cmp ax,10
    jb _ok
    jmp _divdw
_ok:    
    and ax,0fh
    cmp ax,0
    jz _pop
    add al,30h
    push ax
    inc si
_pop:    mov cx,si
_disp:
    pop dx
    mov ah,2
    int 21h
    loop _disp
    ret
show    endp
;
code    ends
end    start


测试:

d:\MASM>jf
9999
9999
19998
d:\MASM>jf
8888
8888
17776
d:\MASM>

作者: masmaster   发布时间: 2010-12-25

上面程序没有做输入是否是数字的检测。楼主自行更改吧

作者: masmaster   发布时间: 2010-12-25

热门下载

更多