home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / 22rsx / rxmd.ark.2 / RXMD12.MAC < prev    next >
Encoding:
Text File  |  1985-12-07  |  2.4 KB  |  143 lines

  1. ;
  2. ; Divides 'HL' by value in 'DE' - upon exit: BC=quotient, HL=remainder
  3. ; a,f,b,c,h,l
  4. dvhlde:    push    d;        divisor
  5.     mov    a,e
  6.     cma;            Negate divisor
  7.     mov    e,a
  8.     mov    a,d
  9.     cma
  10.     mov    d,a
  11.     inx    d;        de := - de
  12.     lxi    b,0;        Init quotient
  13. divl1:    dad    d;        Subtract divisor from divident
  14.     inx    b;        Bump quotient
  15.     jc    divl1;        Loop until sign changes
  16.     dcx    b;        Adjust quotient
  17.     pop    d;        restore divisor
  18.     dad    d;        adjust remainder
  19.     ret
  20. ;
  21. ; Multiply the value in 'HL' by the value in 'A',
  22. ; return with answer in 'HL'.
  23. ; a,f,d,e,h,l
  24. mulhla:    xchg;            Multiplicand to 'DE'
  25.     lxi    h,0;        Init product
  26.     inr    a
  27. mullp:    dcr    a
  28.     rz
  29.     dad    d
  30.     jmp    mullp
  31. ;
  32. ; Logical shift hl 4 bits to the right
  33. ; a,f,h,l
  34. dv16hl:    call    dv2hl
  35. ;    "    "
  36. ; Logical shift hl 3 bits to the right
  37. ; a,f,h,l
  38. dv8hl:    call    dv2hl
  39. ;    "    "
  40. ; Logical shift hl 2 bits to the right
  41. ; a,f,h,l
  42. dv4hl:    call    dv2hl
  43. ;    "    "
  44. ; Logical shift 'HL' register pair right one bit, rh bit to carry
  45. ; a,f,h,l
  46. dv2hl:    ora    a;        Clear the carry bit
  47.     mov    a,h
  48.     rar
  49.     mov    h,a
  50.     mov    a,l
  51.     rar
  52.     mov    l,a
  53.     ret
  54. ;
  55. ;        end of open file, set time routine
  56. ; -------------------------------------------------------------------
  57. ;
  58. ; Closes the received file
  59. ;
  60. closfil:
  61.     mvi    a,close
  62.     call    fileop
  63.     inr    a
  64.     rnz;            Close ok
  65.     call    erxit;        bad close, abort
  66.  db    '++ Can''t close file ++','$'
  67. ;
  68. ; print hl/8, rounded up (i.e. convert recds to k)
  69. ; a,f,h,l
  70. decoutk:
  71.     mvi    a,7
  72.     call    indexb;        round up
  73.     call    dv8hl;        and divide by 8
  74.     jmp    decout
  75. ;
  76. ; Decimal output from (a)
  77. ; a,f,h,l
  78. decouta:
  79.     mov    l,a
  80.     mvi    h,0
  81. ;    "    "
  82. ; Decimal output routine - call with decimal value in 'HL'
  83. ; a,f
  84. decout:    push    b
  85.     push    d
  86.     push    h
  87.     lxi    b,-10
  88.     lxi    d,-1
  89. decou2:    dad    b
  90.     inx    d
  91.     jc    decou2
  92.     lxi    b,10
  93.     dad    b
  94.     xchg
  95.     mov    a,h
  96.     ora    l
  97.     cnz    decout
  98.     mov    a,e
  99.     adi    '0'
  100.     call    ctype
  101.     pop    h
  102.     pop    d
  103.     pop    b
  104.     ret
  105. ;
  106. ; Print hex value from (hl) on CRT
  107. ; a,f
  108. t4hex:    mov    a,h
  109.     call    hexo
  110.     mov    a,l
  111. ;    "    "
  112. ; Prints a hex value in 'A' on the CRT
  113. ; a,f
  114. hexo:    push    psw
  115.     rar
  116.     rar
  117.     rar
  118.     rar
  119.     call    t1hex
  120.     pop    psw
  121. ;    "    "
  122. t1hex:    ani    0fh
  123.     adi    090h;        convert hex to ascii
  124.     daa
  125.     aci    040h
  126.     daa
  127.     jmp    ctype
  128. ;
  129. ; Move hl^ to de^ for 12 bytes.  Advance hl & de by b
  130. ; a,f,b,d,e,h,l
  131. move12:    mvi    b,12
  132. ;    "    "
  133. ; Move hl^ to de^, length in (b) (0 for 256). Adv. hl & de by b
  134. ; a,f,b,d,e,h,l
  135. move:    mov    a,m
  136.     stax    d
  137.     inx    d
  138.     inx    h
  139.     dcr    b
  140.     jnz    move
  141.     ret
  142. ;
  143. ╨╬