home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmlib.lbr / PACC.AZM / PACC.ASM
Encoding:
Assembly Source File  |  1991-06-25  |  2.4 KB  |  82 lines

  1. ;----------------------------------------------------------------
  2. ;        This is a module in the ASMLIB library
  3. ;
  4. ;      Print the accumulator as a pair of HEX digits.
  5. ; This routine uses the convert nibble routine (later) then uses
  6. ; the LZB information flag to decode how to print the bytes.
  7. ;
  8. ;            Written         R.C.H.     16/8/83
  9. ;            Last Update    R.C.H.       31/12/83
  10. ;----------------------------------------------------------------
  11. ;
  12.     name    'pacc'
  13. ;
  14.     public    phacc,pdacc,nibasc
  15.     public    ?phacc2,?pdacc2,?clrblank
  16.     extrn    ?result,hexbcd,dispatch,?lzprint,?blank
  17. ;
  18. phacc:
  19.     call    ?clrblank
  20. ?phacc2:
  21.     push    psw            ; save
  22.     rar
  23.     rar
  24.     rar
  25.     rar                ; load right libble into low byte
  26.     call    nibasc            ; convert to ascii in A
  27.     call    ?lzprint
  28.     pop    psw            ; restore character to be printed
  29.     ani    0fh
  30.     call    nibasc
  31.     jmp    dispatch        ; print regardless of LZB as last digit
  32. ;
  33. ;----------------------------------------------------------------
  34. ;     Print the accumulator as three decimal digits.
  35. ;----------------------------------------------------------------
  36. ;
  37. pdacc:
  38.     call    ?clrblank
  39.     push    h
  40.     push    d            ; save
  41.     mov    e,a            ; load digit
  42.     mvi    d,0            ; clear upper digit
  43.     lxi    h,?result        ; point to buffer for bcd result
  44.     call    hexbcd            ; do the conversion from hex to bcd
  45. ; Now print the correct 3 digits in the 10 digit buffer
  46.     lda    ?result+1        ; this gets top digit
  47.     call    nibasc            ; convert lower nibble in acc to ascii
  48.     call    ?lzprint
  49. ?pdacc2:    ; Jump here to print two bytes at result in correct bcd order
  50.     lda    ?result+0        ; get the two lower bytes
  51.     call    ?phacc2            ; send it via Print Hex Digits
  52.     pop    d            ; restore bytes
  53.     pop    h
  54.     ret
  55. ;
  56. ;----------------------------------------------------------------
  57. ; Clear the byte called blank to 00. This indicates a new number
  58. ; in progress. This is used by many of the number printing routines.
  59. ;----------------------------------------------------------------
  60. ;
  61. ?clrblank:
  62.     push    psw
  63.     xra    a
  64.     sta    ?blank
  65.     pop    psw
  66.     ret
  67. ;
  68. ;----------------------------------------------------------------
  69. ; Convert the low nibble in A to ascii also in A
  70. ;----------------------------------------------------------------
  71. ;
  72. nibasc:
  73.     ani    0fh            ; mask of any possible top bits
  74.     adi    090h            ; add offset
  75.     daa
  76.     aci    040h            ; add again to make ascii
  77.     daa                ; final adjust.
  78.     ret
  79. ;
  80.     end
  81.  
  82.