16位有符号整型数据的输出~~~~

;-----------------------------------------------------------------------------
;            __write_int_
;        ==========================
;
;Proc For write a int decimal to screen, int data in BX
;-----------------------------------------------------------------------------
__write_int_   proc    near
       push    cx
       push    ax
;process if negtive
       mov     ax, bx
       not    ax
       test    ah, 10000000B
       jne     not_negative_w            ;not negative
       mov     dl, '-'
       mov     ah, 02h
       int     21h
       neg     bx
not_negative_w:
       mov    cx, 10000d            ;divide by 10000
       mov    ax, bx                ;data in bx, mov to ax
       call    __dec_div_
       mov    cx, 1000d
       mov    ax, bx
       call    __dec_div_
       mov    cx, 100d
       mov    ax, bx
       call    __dec_div_
       mov    cx, 10d
       mov    ax, bx
       call    __dec_div_
       mov    cx, 1d
       mov    ax, bx
       call    __dec_div_
;linefeed and carriage after out put a data
       mov    ah, 2h
       mov    dl, 0ah                ;linefeed
       int    21h
       mov    dl, 0dh                ;carriage return after read
       int    21h
;
       pop    ax
       pop    cx
       ret                    ;return form _write_int_
;-----------------------------------------------------------------------------
;            __dec_div_
;        ==========================
;
;Subroutine to divide number in BX by number in CX
;print quotient on screen, (numberator in DX+AX, denom in CX)
;-----------------------------------------------------------------------------
__dec_div_     proc    near
;
       mov    ax, bx                          ;number low half
       mov    dx, 0                           ;zero out high half
       div    cx                              ;divide by CX
       mov    bx, dx                          ;remainder into BX
       mov    dl, al                ;quotient into DL
;print the contents of DL on screen
       add    dl, 30h                         ;convert to ASCII
       mov    ah, 2h
       int    21h
       ret
__dec_div_     endp                            ;end of proc __dec_div_
;-----------------------------------------------------------------------------
__write_int_   endp                            ;end of proc __write_int_
;
;-----------------------------------------------------------------------------
;
codesg    ends                    ;end of code segment
;*****************************************************************************
      end    begin                ;end assembly
;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值