关闭

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

2445人阅读 评论(0) 收藏 举报
;-----------------------------------------------------------------------------
;            __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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:101974次
    • 积分:1444
    • 等级:
    • 排名:千里之外
    • 原创:38篇
    • 转载:8篇
    • 译文:0篇
    • 评论:39条
    最新评论
    资源下载