home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol017 / which-1.asm < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  3.6 KB  |  199 lines

  1. ;    which.asm
  2. ;
  3. ;    this program returns size and version
  4. ;    of cp/m you are running.
  5. ;    this can be useful when running under
  6. ;    fast, despool, ddt, sid, etc.
  7. ;
  8. ;    version of 25 nov 1980
  9. ;
  10. ;    by David Fiedler
  11. ;       InfoPro Systems
  12. ;       Denville, NJ
  13.  
  14. ;    Copyright 1980 InfoPro Systems.  This program may
  15. ;    not be used for commercial purposes without written
  16. ;    permission from InfoPro Systems.  However it may
  17. ;    be used by hackers to their heart's content as long
  18. ;    as they don't try to sell it or pass it off as their
  19. ;    own.
  20. ;
  21. ;    Please note that this has not been tried out under
  22. ;    other than CP/M 2.2, although it should work fine.
  23. ;
  24. ;    code adapted from tpa3.asm by:
  25. ;       Ron Fowler    
  26. ;       Westland, Mich.
  27. ;
  28. ;       fixes and code optimizations to tpa3 by
  29. ;       Keith Petersen
  30. ;
  31. ;    conditional assemblies added for Micropolis Mod II CP/M
  32. ;       by Ray Glueck 1/12/81
  33. ;
  34. ;
  35. false    equ    0
  36. true    equ    not false
  37. ;
  38. stdcpm    equ    false
  39. microp    equ    true
  40. ;
  41.     org    100h
  42. ;
  43. base:    lxi    h,0
  44.     dad    sp    ;get local stack
  45.     shld    oldstk    ;save old stack
  46.  
  47.     call    tb
  48. msg:    db    'Welcome to $'
  49.  
  50. tb:    mvi    c,9    ;print msg function
  51.     pop    d    ;get msg adrs
  52.     call    5    ;print it
  53.  
  54.     mvi    c,12    ;get version number function
  55.     call    5
  56.     shld    retword    ;hold for later
  57.     mov    a,h    ;multi-tasking?
  58.     cpi    1
  59.     jz    mpm    ;yes.
  60.     mvi    a,'C'    ;no.
  61.     sta    versms    ;so announce properly
  62.     jmp    getsiz
  63. mpm:
  64.     mvi    a,'M'
  65.     sta    versms
  66.         
  67. getsiz:    lhld    6    ;get the bdos address
  68.     xchg        ;into de
  69.     lhld    retword
  70.     mov    a,l
  71.     cpi    0
  72.     jnz    newone
  73.     lxi    h,-3100h    ;get 16k bdos address for cp/m 1.4
  74.     dad    d        ;subtract it, answer left in hl
  75.     if stdcpm
  76.     lxi    d,(16 * 1024)    ;this would print 16k if addresses were equal
  77.     endif
  78.     if microp
  79.     lxi    d,(17 * 1024)
  80.     endif
  81.     dad    d        ;not efficient but clear at least
  82.     jmp    print
  83. newone:    
  84.     lxi    h,-3c00h    ;20k bdos offset for 2.0
  85.     dad    d
  86.     if stdcpm
  87.     lxi    d,(20 * 1024)
  88.     endif
  89.     if microp
  90.     lxi    d,(21 * 1024)
  91.     endif
  92.     dad    d
  93. print:    
  94.     mov    a,h
  95.     rrc            ;divide by 2
  96.     rrc            ;divide by 4
  97.     ani    7fh        ;mask to positive
  98.     mov    l,a        ;effectively divide by 2 ^ 8
  99.     mvi    h,0        ;for a total of 2 ^ 10 = 1K
  100.     call    decout        ;print it
  101.     call    tb1        ;print the line
  102. sizems:    db    'K '
  103. versms:    db    ' P/M Version $'
  104. ;
  105. ;
  106. tb1:    mvi    c,9    ;print msg function
  107.     pop    d    ;get msg adrs
  108.     call    5    ;print it
  109. ;
  110. getnum:
  111.     lhld    retword
  112.     mov    a,l
  113.     cpi    0    ;previous to 2.2?
  114.     jz    oldone    ;yes.
  115.     push    psw    ;save value
  116.     ani    0f0h    ;get high nibble
  117.     rrc
  118.     rrc
  119.     rrc
  120.     rrc        ;into low nibble
  121.     adi    '0'    ;make ascii
  122.     call    co    ;print
  123.     mvi    a,'.'
  124.     call    co
  125.     pop    psw    ;retrieve lower four bits
  126.     ani    0fh    ;mask them
  127.     adi    '0'
  128.     call    co
  129.     call    tb2
  130.     db    13,10,'$'
  131. ;
  132. oldone:
  133.     call    tb2
  134.     db    '1.4',13,10,'$'
  135. ;
  136. ;
  137. tb2:    mvi    c,9    ;print msg function
  138.     pop    d    ;get msg adrs
  139.     call    5    ;print it
  140.     lhld    oldstk    ;restore ccp stack
  141.     sphl
  142.     ret        ;back to the ccp
  143. ;
  144. ;    subroutines
  145. ;
  146. ; Console output routine
  147. ;    prints character in 'a' register
  148. ;
  149. co:    push    h
  150.     push    d
  151.     push    b
  152.     mov    e,a    ;character to e for CP/M
  153.     mvi    c,2    ;print console function
  154.     call    5    ;print character
  155.     pop    b
  156.     pop    d
  157.     pop    h
  158.     ret
  159. ;
  160. ; Decimal output routine
  161. ;    this routine has following
  162. ;    entry and external parameters:
  163. ;
  164. ;       entry:    hl=binary number to print in decimal
  165. ;       external calls: co routine
  166. ;       ** note...this routine is recursive, and uses
  167. ;       6 bytes of stack for each recursive call, in ad-
  168. ;       dition to any stack space used by the co routine.
  169. ;
  170. decout: push    b
  171.     push    d
  172.     push    h
  173.     lxi    b,-10
  174.     lxi    d,-1
  175. ;
  176. decou2: dad    b
  177.     inx    d
  178.     jc    decou2
  179.     lxi    b,10
  180.     dad    b
  181.     xchg
  182.     mov    a,h
  183.     ora    l
  184.     cnz    decout
  185.     mov    a,e
  186.     adi    '0'
  187.     call    co
  188.     pop    h
  189.     pop    d
  190.     pop    b
  191.     ret
  192. ;
  193. stack    equ    $+80    ;40 level stack
  194. ;
  195. oldstk:    ds    2
  196. retword:ds    2
  197.  
  198.     end    base
  199.