回 帖 发 新 帖 刷新版面

主题:[讨论]帮帮忙 跪求汇编程序


   编写一程序,要求从键盘接收一个4位的16进制数,
         并在终端上显示与它等值的2进制数[em19]
  minghongyun@post.usts.edu.cn

回复列表 (共4个回复)

沙发

data segment 
buf db 10
db?
db 10 dup(?)
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
       mov ds,ax
       mov dx,offset buf
       mov ah,0ah

..................还请高手完成余下的

板凳


完成了有什么好处???呵呵[em9]

3 楼

data    segment
    buf db 4,?
    ascstg db 10 dup(?)
    integer dw 0
    promt db 'Input hexadecimal(4):$'
    dsperr db 0dh,0ah,'error!no hexadecimal!$'
data    ends
code    segment use16
    assume cs:code,ds:data
start:    mov ax,data
    mov ds,ax
    mov dx,offset promt
    mov ah,09h
    int 21h
    mov dx,offset buf
    mov ah,oah
    int 21h
    mov cl,4
    lea si,ascstg
    mov al,[si]
    cld
    xor dx,dx
    mov bl,0
    mov ch,buf[1]
    cmp ch,0
    jz exit
    cmp al,'+'
    jnz next
    inc si
    dec ch
    jmp conv
next:    cmp al,'-'
    jnz conv
    inc si
    dec ch
    mov bl,0ffh
conv:    cmp ch,0c
    jz store
    lodsb
    cmp al,'0'
    jb error
    cmp al,'9'
    ja next1
    sub al,30h
    jmp short rotate
next1:    call a_to_f
    jc error
rotate:    shl dx,cl
    or dl,al
    dec ch
    jmp short conv
store:    cmp ,bl,0
    jz lp
    neg dx
lp:    mov integer,dx
exit:    mov dx,offset dsperr
    mov ah,09h
    int 21h
    jmp exit
a_to_f    proc
    cmp al,'a'
    jb nohex
    cmp al,'f'
    ja next2
    sub al,37h
    jmp hex
next2:    cmp al,'a'
    jb nohex
    cmp al,'f'
    ja nohex
    sub al,547h
hex:    clc
    ret
nohex:    stc
    ret
a_to_f    endp
code    ends
    end start
    

4 楼


楼上的谢啦[em2]

我来回复

您尚未登录,请登录后再回复。点此登录或注册