home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG038.ARK / UTL.LIB < prev   
Text File  |  1984-04-29  |  3KB  |  134 lines

  1. ;
  2. ; TITLE        .UTL file linkage macro
  3. ; FILENAME    UTL.LIB
  4. ; AUTHOR    Robert A. Van Valzah   11/25/79
  5. ; LAST REVISED    R. A. V.   11/25/79
  6. ; REASON    removed comments following endm's
  7. ;
  8. ;
  9. ; macro to define a string in memory backwards, followed
  10. ; by its lenght
  11. ;
  12. backwrd    macro    parm
  13.       if        not nul parm
  14. ?last      set        0ffh
  15.       rept        0ffh    ;;do forever
  16.         if        ?last=0    ;;well, at least until ?last=0
  17.           exitm
  18.         endif
  19. cnt        set        0
  20.         irpc    arg,parm
  21.           if    cnt=?last
  22.             exitm
  23.           endif
  24. chr          set    '&ARG'
  25. cnt          set    cnt+1
  26.         endm
  27. ?last        set        cnt-1
  28.         db        chr
  29.       endm
  30. cnt      set        0    ;;count lenght of arg
  31.       irpc        arg,parm
  32. cnt        set        cnt+1
  33.       endm
  34.       db        cnt
  35.     endm
  36. ;
  37. ; macro to produce sid interface for a .UTL file
  38. ;
  39. utl    macro    parm1,parm2,parm3
  40.     local    ep1,ep2,ep3
  41. base:
  42.     jmp    entry
  43. symtbl:
  44.     backwrd    parm1
  45.     dw    ep1
  46.     backwrd    parm2
  47.     dw    ep2
  48.     backwrd    parm3
  49.     dw    ep3
  50. symlen    equ    $-symtbl
  51. ep1:    jmp    parm1
  52. ep2:    jmp    parm2
  53. ep3:    jmp    parm3
  54. ;
  55. ; parameter passed to relhdr
  56. ;
  57.     dw    codelen    ;length of code to be relocated
  58.     db    '(C) Copyright 1979, Robert A. Van Valzah'
  59. getline:        ;;get a line to sid buffer
  60.     lxi    b,3
  61.     jmp    sidlink
  62. getchar:        ;;get a character from buffer to reg a
  63.     lxi    b,6    ;;converting to upper case
  64.     jmp    sidlink
  65. crlf:
  66.     mvi    a,13
  67.     call    conout
  68.     mvi    a,10
  69. conout:            ;;send charcter from reg a to console
  70.     lxi    b,9
  71.     jmp    sidlink
  72. hexode:
  73.     push    d    ;;save low byte
  74.     mov    a,d    ;;print high byte
  75.     call    hexo
  76.     pop    d    ;;get low byte
  77.     mov    a,e    ;;fall thru to print it
  78. ;
  79. hexo:            ;;print reg a as two hex digits
  80.     lxi    b,0ch
  81.     jmp    sidlink
  82. parseline:        ;;parse line in input buffer, returning
  83.     lxi    b,12h    ;;reg a = number of args, and carry set
  84.     jmp    sidlink    ;;if error
  85. getarg:            ;;get argument from input buffer to
  86.     lxi    b,15h    ;;reg hl
  87.     jmp    sidlink
  88. brktest:        ;;call bdos break function
  89.     lxi    b,18h
  90. sidlink:
  91.     lhld    39h    ;;address field of jmp @ rst 7
  92.     dad    b    ;;add displacement into sid jmp table
  93.     pchl        ;;and vector to desired routine
  94. ;
  95. ; print message pointed to by reg de unitl 0h is found
  96. ;
  97. prmsg:
  98.     ldax    d    ;;get a character of message
  99.     ora    a    ;;end of message?
  100.     rz        ;;yes - all done
  101.     inx    d    ;;no - print character
  102.     push    d
  103.     call    conout
  104.     pop    d
  105.     jmp    prmsg    ;;print more
  106. ;
  107. entry:
  108.     lhld    bdos+1    ;;get current sid base
  109.     shld    base+1    ;;store it into utl base
  110.     lxi    h,base    ;;make loc 5 jmp to utl base
  111.     shld    bdos+1
  112.     lxi    d,p1msg    ;;print entry point addresses
  113.     call    prmsg
  114.     lxi    d,ep1
  115.     call    hexode
  116.     lxi    d,p2msg
  117.     call    prmsg
  118.     lxi    d,ep2
  119.     call    hexode
  120.     lxi    d,p3msg
  121.     call    prmsg
  122.     lxi    d,ep3
  123.     call    hexode
  124.     call    init    ;;if additional init required
  125.     lxi    d,symlen ;;pass symbol table lenght back to sid
  126.     ret
  127. p1msg:
  128.     db    13, 10, '.&PARM1 = ', 0
  129. p2msg:
  130.     db    13, 10, '.&PARM2 = ', 0
  131. p3msg:
  132.     db    13, 10, '.&PARM3 = ', 0
  133.     endm
  134.