home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol130 / tmodtest.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  4.0 KB  |  226 lines

  1. title    TMODTEST.MAC    
  2. version    equ    10    ;1/23/82
  3. ;    part of the SIGNON Subsystem by Dick Lieber
  4. ;    refer to SIGNON.DOC for details on how to use this.
  5. ;
  6. ;    This module is used to test the TMOD.MAC module
  7. ;    Allows selective call to:
  8. ;        DATEMD    - returns date (mm/dd/yy$)
  9. ;        DAYMD    - returns day as (dayofweek$)    
  10. ;        TIMEMD    - returns time as (hh:mm:ss$)
  11. ;    Also tests that TMOD.REL doesn't change string past what 
  12. ;    it should.
  13. ;
  14. ;    If your TMOD.REL works with this test driver, it should
  15. ;    work just fine with the various SIGNON modules.
  16. ;
  17.     .z80    ;several Z80 instructions are used
  18.  
  19. rdcon    equ    1
  20. wrcon    equ    2
  21. print    equ    9
  22.  
  23. bdos    equ    5
  24. cr    equ    0dh
  25. lf    equ    0ah
  26. tab    equ    9
  27. filler    equ    0e6h        ;used to test for corrupted strings
  28.  
  29. extrn    timemd,datemd,daymd    ;these are entry points into TMOD.REL
  30.  
  31.     ld    (oldstack),sp
  32.     ld    sp,newstack
  33. mainloop:
  34.     ld    de,menu        ;everything's menu driven
  35.     ld    c,print
  36.     call    bdos
  37.     call    fillbuff    ;put know chrarcter into buffer for 
  38.                 ;length test
  39.     call    selector    ;get command number
  40.     cp    maxcmd
  41.     jp    nc,mainloop    ;check for legal command
  42.     ld    hl,cmdtable    ;point to start of table
  43.     ld    d,0
  44.     ld    e,a        ;command number
  45.     add    hl,de        ;index into table
  46.     add    hl,de        ;each entry is two bytes long
  47.     ld    e,(hl)        ;get address of routine - low
  48.     inc    hl
  49.     ld    d,(hl)        ;now get high byte
  50.     ex    de,hl        ;hl point to routine    
  51.     ld    de,mainloop    
  52.     push    de        ;address to return to
  53.     jp    (hl)        ;just like a call
  54. ;
  55. ;    main menu
  56. ;
  57. menu:    defm    cr,lf
  58.     defm    "SIGNON Subsystem TMOD.REL tester  - version "
  59.     defb    version/10 + '0', '.', version mod 10 + '0', cr,lf
  60.     defm    cr,lf
  61.     defm    tab,    "a    time",     cr,lf
  62.     defm    tab,    "b    date",    cr,lf
  63.     defm    tab,    "c    day",    cr,lf
  64.     defm    tab,    "d    quit",    cr,lf
  65.     defm    lf
  66.     defm    tab,    "Press letter of your choice > $"
  67. ;
  68. ;    command table
  69. ;
  70. cmdtable:
  71.     defw    proctime
  72.     defw    prdate
  73.     defw    prday
  74.     defw    quit
  75. maxcmd    equ    ($ - cmdtable) / 2
  76. ;
  77. ;    fill buffer with fill character
  78. ;    note to 8080 fans (Sorry 'bout that!)
  79. ;
  80. fillbuff:
  81.     ld    hl,timebuffer
  82.     ld    (hl),filler    ;stick the first character in
  83.     ld    de,timebuffer+1    ;just copies from last address
  84.     ld    bc,bufflength    
  85.     ldir            ;do it
  86.     ret
  87. ;
  88. ;    process single letter choice
  89. ;    convert letter pressed to number
  90. ;    only allows 0 - 15
  91. ;
  92. selector:
  93.     ld    c,rdcon
  94.     call    bdos
  95.     and    0fh    ;convert to number
  96.     dec    a    ;cause 'A' is 1 not 0
  97.     ret
  98. ;
  99. ;    process error in string length
  100. ;
  101. lerror:    ld    de,lerrmess
  102.     ld    c,print
  103.     call    bdos
  104. ;
  105. ;    now we display the entire string
  106. ;
  107.     ld    hl,timebuffer
  108.     ld    bc,bufflength
  109. lerrloop:
  110.     ld    e,(hl)
  111.     push    bc
  112.     push    hl
  113.     ld    c,wrcon
  114.     call    bdos
  115.     pop    hl
  116.     pop    bc
  117.     inc    hl
  118.     dec    bc
  119.     ld    a,b
  120.     or    c
  121.     jr    nz,lerrloop
  122.     ret
  123. lerrmess:
  124.     defm    cr,lf,"*** Error! ***",cr,lf
  125.     defm    cr,lf
  126.     defm    "Your TMOD.REL changed too much of the passed string."
  127.     defm    cr,lf
  128.     defm    "This could corrupt basic's string space!"
  129.     defm    cr,lf
  130.     defm    "This is the string:",cr,lf,"$"
  131. ;
  132. ;    done - return to ccp without re-booting
  133. ;
  134. quit:    ld    de,donemess
  135.     ld    c,print
  136.     call    bdos
  137.     ld    sp,(oldstack)
  138.     ret            ; to ccp
  139. donemess:
  140.     defm    cr,lf,"back to ccp...$"
  141. ;
  142. ;    display the time
  143. ;
  144. proctime:
  145.     ld    de,timemess
  146.     ld    c,print
  147.     call    bdos
  148. ;
  149. ;    make a microsoft compatable call
  150. ;
  151.     ld    hl, tmbuffptr
  152.     call    timemd
  153. ;
  154. ;    print time
  155. ;    
  156.     ld    de, timebuffer
  157.     ld    c,print
  158.     call    bdos
  159.     ld    a,(timebuffer+10)    ;check that 10th character wastn't
  160.                     ;altered by TMOD.REL
  161.     cp    filler
  162.     call    nz,lerror
  163.     ret
  164. timemess:
  165.     defm    cr,lf,"Time: $"
  166.  
  167. ;
  168. ;    display the day of week
  169. ;
  170. prday:
  171.     ld    de,daymess
  172.     ld    c,print
  173.     call    bdos
  174.     ld    hl, tmbuffptr
  175.     call    daymd
  176. ;
  177. ;    print day
  178. ;    
  179.     ld    de, timebuffer
  180.     ld    c,9
  181.     call    bdos
  182.     ld    a,(timebuffer+10)    ;check that 10th character wastn't
  183.                     ;altered by TMOD.REL
  184.     cp    filler
  185.     call    nz,lerror
  186.     ret
  187. daymess:
  188.     defm    cr,lf,"Day of week: $"
  189.  
  190. ;
  191. ;    display date
  192. ;
  193. prdate:
  194.     ld    de,datemess
  195.     ld    c,print
  196.     call    bdos
  197.     ld    hl, tmbuffptr
  198.     call    datemd
  199. ;
  200. ;    print date
  201. ;    
  202.     ld    de, timebuffer
  203.     ld    c,print
  204.     call    bdos
  205.     ld    a,(timebuffer+10)    ;check that 10th character wastn't
  206.                     ;altered by TMOD.REL
  207.     cp    filler
  208.     call    nz,lerror
  209.     ret            ; to ccp
  210. datemess:
  211.     defm    cr,lf,"Date: $"
  212. ;
  213. ;    ram area
  214. ;
  215. tmbuffptr:
  216.     defb    9        ;length of buffer
  217.     defw    timebuffer    ;to conform to microsoft calling parms
  218. timebuffer:
  219.     defs    20        ;lots of space for tests
  220. bufflength    equ    $ - timebuffer
  221.     defs    30        ;more space for stack
  222. newstack:
  223. oldstack:
  224.     defs    2    
  225.     end
  226.