home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / rotate / bwprint.asm next >
Assembly Source File  |  1993-02-10  |  2KB  |  123 lines

  1.     DOSSEG
  2.  
  3.     .MODEL SMALL
  4.     .386
  5.     .CODE
  6.  
  7.     GLOBAL  PrintByte:PROC, PrintWord:PROC, PrintBig:PROC
  8.  
  9.     TextNumBIG  db  "00000"
  10.     TextNum     db  "00000"
  11.     TextNumEnd  db  0,"$"
  12.     
  13. BinToAscII PROC
  14.         mov     bx,10
  15.         mov     si,SEG TextNum
  16.         mov     es,si
  17.         mov     si,offset textnumend-1
  18.         mov     cx,5
  19. DivLoop:
  20.         sub     dx,dx
  21.         div     bx
  22.         add     dl,'0'
  23.         mov     es:[si],dl
  24.         dec     si
  25.         loop    DivLoop
  26.         ret
  27. ENDP BinToAscII
  28.  
  29. B2ABig PROC
  30.         mov     ebx,10
  31.         mov     si,SEG TextNum
  32.         mov     es,si
  33.         mov     si,offset textnumend-1
  34.         mov     cx,10
  35. DLBig:
  36.         sub     edx,edx
  37.         div     ebx
  38.         add     dl,'0'
  39.         mov     es:[si],dl
  40.         dec     si
  41.         loop    DLBig
  42.         ret
  43. ENDP B2ABig
  44.  
  45. PrintBig PROC
  46.     pushad
  47.  
  48.     call    b2aBig
  49.     mov     ax,SEG TextNumBig
  50.     mov     ds,ax
  51.     mov     dx,offset textnumBig
  52.     mov     ah,9
  53.     int     21h
  54.  
  55.     popad
  56.     ret
  57. ENDP PrintBig
  58.  
  59. PrintByte PROC
  60.     pusha
  61.     jnc     skipsignb
  62.     xor     ah,ah
  63.     test    al,10000000b
  64.     jz      skipsignb
  65.     neg     al
  66.     push    ax
  67.     mov     ah,2
  68.     mov     dl,"-"
  69.     int     21h
  70.     pop     ax
  71.     jmp     skipb
  72.  
  73. skipsignb:
  74.     xor     ah,ah
  75.     push    ax
  76.     mov     ah,2
  77.     mov     dl," "
  78.     int     21h
  79.     pop     ax
  80. skipb:
  81.     call    bintoascii
  82.     mov     ax,SEG TextNum
  83.     mov     ds,ax
  84.     mov     dx,offset textnum+2
  85.     mov     ah,9
  86.     int     21h
  87.     popa
  88.     ret
  89. ENDP PrintByte
  90.  
  91. PrintWord PROC
  92.     pusha
  93.     jnc     skipsignw
  94.     test    ah,10000000b
  95.     jz      skipsignw
  96.     neg     ax
  97.     push    ax
  98.     mov     ah,2
  99.     mov     dl,"-"
  100.     int     21h
  101.     pop     ax
  102.     jmp     skipw
  103. Skipsignw:        
  104.     push    ax
  105.     mov     ah,2
  106.     mov     dl," "
  107.     int     21h
  108.     pop     ax
  109. Skipw:
  110.     call    bintoascii
  111.     mov     ax,SEG TextNum
  112.     mov     ds,ax
  113.     mov     dx,offset textnum
  114.     mov     ah,9
  115.     int     21h
  116.     popa
  117.     ret
  118. ENDP PrintWord
  119.  
  120.     END
  121.     
  122.  
  123.