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
;
; __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
;