home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtmac.mac < prev    next >
Text File  |  2020-01-01  |  10KB  |  417 lines

  1.     .sbttl    KRTMAC    Various handy constants and macros
  2. ;    .ident    "V03.63"        ; this is an .include file
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman  V03.63
  5. ;
  6. ;    add support for SET ATTRIBUTES
  7. ;    add flag to suspend logging to a disk file
  8. ;    make $LN$MAX 132. bytes for EIS assembly
  9. ;    pulled message macro, no longer used..
  10.  
  11. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  12. ;
  13. ;    move dispatch macro to KRTSER
  14. ;    move erbfsiz here from KRTPAK
  15. ;    condense logging (debug) modes
  16. ;    increase efficiency of incm64 macro
  17. ;    increase MAXLNG (long-packet size) to 1920.
  18. ;    reduce MAXLNG to 600. for NONEIS assembly, so pgm loads under FB..
  19. ;    ditto for ALSIZE (phone # buffer) and LN$CNT (SL # of lines saved)
  20.  
  21. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  22. ;
  23. ;    modified message macro to call .newline instead of saving CR/LF
  24. ;    and null for each new line, knocking 1042. bytes off the size
  25. ;    of this version..  also changed ".print" emulation to wrtall,
  26. ;    for a similar savings in compiled program size.
  27. ;
  28. ;    dump raw I/O logging from log$al (SET DEB ALL) - too confusing
  29. ;    also pulled log$rp out and made it a completely separate item..
  30. ;
  31. ;    added a couple upper case macros
  32.  
  33. ;    include file for Kermit-11
  34. ;
  35. ;    Brian Nelson  01-Dec-83  13:56:12
  36.  
  37.     .NLIST    BEX
  38.     .LIST    MEB            ; /62/
  39.  
  40.     KRTINC    =    1        ; for .include error checking
  41.  
  42.  
  43.     .psect    $code    ,ro,i,lcl,rel,con ; psect ordering..
  44.     .psect    $pdata    ,ro,d,lcl,rel,con
  45.  
  46. ;    various ascii chars
  47.     SOH    =   1        ; default packet start of header
  48.     BELL    =   7        ; beep
  49.     BS    =  10        ; backspace
  50.     TAB    =  11        ; tab
  51.     LF    =  12        ; line feed
  52.     FF    =  14        ; form feed
  53.     CR    =  15        ; carriage return
  54.     CTRL$N    =  16        ; ^N VT-100 line drawing on
  55.     CTRL$O    =  17        ; ^O VT-100 line drawing off
  56.     XON    =  'Q&37    ; ^Q
  57.     XOFF    =  'S&37    ; ^S
  58.     ESC    =  33        ; escape
  59.     SPACE    =  40
  60.     COMMA    =  54
  61.     DOT    =  56        ; /63/
  62.     SCOLON    =  73        ; /63/
  63.     TILDE    = 176        ; /63/
  64.     DEL    = 177        ; delete
  65.  
  66. ;    system data locations
  67.     JSW    = 44        ; job status word
  68.     ERRBYT    = 52        ; emt error byte
  69.     USERRB    = 53        ; /62/ user error byte
  70.         SUCCS$    =  1    ; no error
  71.         WARN$    =  2    ; warning
  72.         ERROR$    =  4    ; error
  73.         SEVER$    = 10    ; sever error
  74.         FATAL$    = 20    ; fatal error
  75.  
  76. ;    byte offsets into SINIT parameter vector
  77.     P.SPSIZ    = 0        ; set packet length
  78.     P.TIME    = 1        ; time-out
  79.     P.NPAD    = 2        ; number of pad chars
  80.     P.PADC    = 3        ; the pad character
  81.     P.EOL    = 4        ; eol char
  82.     P.QCTL    = 5        ; control char quoting
  83.     P.QBIN    = 6        ; 8-bit quote
  84.     P.CHKT    = 7        ; checksum type
  85.     P.REPT    = 10        ; repeated character prefix
  86.     P.CAPAS    = 11        ; capability bitmask
  87.         CAPA.A    = 10    ; attribute handling
  88.         CAPA.L    = 2    ; /42/ long packets
  89.         CAPA.S    = 4    ; /42/ sliding windows
  90.     P.WINDS    = 12        ; /43/ window size, # of packets
  91.     P.MXL1    = 13        ; /43/ high order of long packet size
  92.     P.MXL2    = 14        ; /43/ low order of long packet size
  93.     P.VEND    = 17        ; end of parameter vector
  94.  
  95. ; /62/    bits in doattr (file attribute processing)
  96.     AT.CDT    =: 1        ; create date
  97.     AT.INF    =: 2        ; /63/ system specific info
  98.     AT.LEN    =: 4        ; length
  99.     AT.PRO    =: 10        ; file protection
  100.     AT.SYS    =: 20        ; system ID
  101.     AT.TYP    =: 40        ; file type
  102.     AT.XLE    =: 100        ; exact length in bytes
  103.     AT.ON    =: 100000    ; /63/ do attribute processing
  104.     AT.ALL    =: AT.CDT!AT.INF!AT.LEN!AT.PRO!AT.SYS!AT.TYP!AT.XLE
  105.  
  106. ;    bits in trace (debug status word)
  107.     LOG$PA    = 1        ; log all packets
  108.     LOG$CO    = 2        ; /62/ CONNECT logging to disk
  109.     LOG$RP    = 4        ; /62/ rpack chars to TT
  110.     LOG$IO    = 10        ; /62/ everything received or sent
  111.     LOG$DE    = 20        ; /62/ debugging to TT
  112.     LOG$ON    = 40000        ; /63/ set to write to disk, clear to suspend
  113.     LOG$OP    = 100000    ; logfile is open
  114.     LOG$AL    = LOG$PA!LOG$CO    ; /62/ ALL
  115.  
  116. ;    parity options
  117.     PAR$NO    =: 0        ; none
  118.     PAR$OD    =: 1        ; odd
  119.     PAR$EV    =: 2        ; even
  120.     PAR$MA    =: 3        ; mark
  121.     PAR$SP    =: 4        ; space
  122.  
  123. ;    file types
  124.     TERMINAL=: -1        ; file to term ala xreply, not to disk
  125.     TEXT    =:  0        ; normal ascii text files
  126.     BINARY    =:  1        ; image mode
  127.     DECNAT    =:  2        ; /52/ 8-bit text files
  128.  
  129. ;    terminal types
  130.     NOSCOPE    = 0        ; /BBS/ hard copy terminal
  131.     TTY    = 1        ; a dumb tube terminal
  132.     VT100    = 2        ; itself
  133.     VT200    = 3        ; ditto..
  134.  
  135. ;    supported CVT$$ cvt_bit_pattern bits
  136.     C.CRLF    = 4        ; discard CR LF FF ESC
  137.     C.LSPA    = 10        ; discard leading spaces and tabs
  138.     C.SSPA    = 20        ; reduce spaces and tabs to a single space
  139.     C.LCUC    = 40        ; lower case to upper case
  140.     C.TSPA    = 200        ; discard trailing spaces and tabs
  141.  
  142.     CON$ESC    =  '\-100    ; default CONNECT escape char
  143.     ERBFSIZ    =  120.        ; /62/ error msg text buff size
  144.     MAXPAK    =:  94.        ; /63/ max_packet_length - max_checksum_length
  145.  
  146.     .if df    NONEIS        ; /62/ using NONEIS for convenience..
  147.     ALSIZE    =   1000    ; /63/ bufsiz for SET DIAL/PHO NUM
  148.     LN$CNT    =      3.    ; /62/ save/recall 3. commands
  149.     LN$MAX    =     80.    ; /63/ max command line length
  150.     MAXLNG    =    600.    ; /63/ so image is small enuff to run
  151.     .iff
  152.     ALSIZE    =   2000    ; /62/ bufsiz for SET DIAL/PHO NUM
  153.     LN$CNT    =     10.    ; /63/ save/recall 10. commands
  154.     LN$MAX    =    132.    ; /63/ max command line length
  155.     MAXLNG    =   1920.    ; /63/ use max long-packet buff size
  156.     .endc
  157.     $ALLSIZ    = <MAXLNG+14>&177776 ; /62/ make it this for safety
  158.  
  159.  
  160.     .sbttl    Utility macros
  161.  
  162.     .macro    .br to        ; /63/ added
  163.     .if df    to
  164.     .if ne    to-.
  165.     .error    <; not at location to;>
  166.     .endc
  167.     .endc
  168.     .endm    .br
  169.  
  170.     .macro    .chksp    arg
  171.     .ntype    $$5    ,arg
  172.     .iif eq <<$$5&7>-6> .error arg <; Illegal use of SP (r6) in call>
  173.     .endm    .chksp
  174.  
  175.     .macro    calls    name    ,arglst
  176. ;    subroutine call with arguments passed in an area pointed to by r5
  177. ;    (as with F4 and BP2).  all args are pushed onto the stack in the
  178. ;    order specified.  r5 points to the sp before the call and is saved
  179. ;    and restored.
  180.     $$ = 0                ; init # of args count
  181.       .irp x ,<arglst>        ; count up # of args passed
  182.       $$ = $$+1            ; one at a time
  183.       .endr                ; got it
  184.     .if eq $$            ; no args present?
  185.     jsr    pc    ,name        ; if so, substitute a simple call
  186.     .iff                ; at least one arg in <arglst>
  187.     mov    r5    ,-(sp)        ; /63/ will be used to point to arg(s)
  188.       .if eq $$-1            ; is it one or more than one arg?
  189.       .chksp    arglst        ; one arg, check for legal SP modes
  190.       mov    arglst    ,-(sp)        ; doing it thusly generates less code
  191.       mov    sp    ,r5        ; set pointer to argument list
  192.       jsr    pc    ,name        ; call the subroutine
  193.       tst    (sp)+            ; pop parameter list from stack
  194.       mov    (sp)+    ,r5        ; /63/ restore r5
  195.       .iff                ; arg_count > 1
  196.       $$2 = $$            ; extract the args in
  197.         .rept    $$        ; reverse order so that
  198.         $$1 = 0            ; we might save a little
  199.           .irp x ,<arglst>        ; core (four words)
  200.           $$1 = $$1+1        ; scan the arg list until we come to
  201.             .if eq $$2-$$1        ; the last one before one we just did
  202.             .chksp    x        ; check for SP addressing mode
  203.             mov    x    ,-(sp)    ; push it
  204.             .mexit            ; and exit the .irp
  205.             .endc
  206.           .endr
  207.         $$2 = $$2-1            ; backwards to previous arg
  208.         .endr
  209.       mov    sp    ,r5        ; set up the argument list pointer
  210.       jsr    pc    ,name        ; and go to the routine
  211.       .iif eq <$$-2>  cmp    (sp)+    ,(sp)+    ; two args
  212.       .iif gt <$$-2>  add    #$$*2    ,sp    ; gen "add 2*argnum ,sp"
  213.       mov    (sp)+    ,r5        ; /63/ restore r5
  214.       .endc
  215.     .endc
  216.     .endm    calls
  217.  
  218.     .macro    ctl    src ,dst
  219.     clr    -(sp)
  220.     bisb    src    ,@sp
  221.     call    l$xor
  222.     movb    (sp)+    ,dst
  223.     .endm    ctl
  224.  
  225.     .macro    copyz    from ,to ,maxlen
  226.     .if  b    <maxlen>
  227.     clr    -(sp)
  228.     .iff
  229.     mov    maxlen    ,-(sp)
  230.     .endc
  231.     mov    from    ,-(sp)
  232.     mov    to    ,-(sp)
  233.     call    copyz$
  234.     .endm    copyz
  235.  
  236.     .macro    deccvt    val ,buf ,width
  237.     mov    r5    ,-(sp)
  238.     .if  b    <width>
  239.     clr    -(sp)
  240.     .iff
  241.     mov    width    ,-(sp)
  242.     .endc
  243.     mov    val    ,-(sp)
  244.     mov    buf    ,-(sp)
  245.     mov    sp    ,r5
  246.     call    l$cvtnum
  247.     add    #6    ,sp
  248.     mov    (sp)+    ,r5
  249.     .endm    deccvt
  250.  
  251.     .macro    decout    val
  252.     mov    r5    ,-(sp)
  253.     mov    val    ,-(sp)        ; /62/ l$wrdec pops this buffer
  254.     mov    sp    ,r5
  255.     call    l$wrdec
  256.     mov    (sp)+    ,r5
  257.     .endm    decout
  258.  
  259.     .macro    direrr    val
  260.     mov    val    ,-(sp)
  261.     call    direr$
  262.     .endm    direrr
  263.  
  264.     .macro    incm64    val
  265.     inc    val
  266.     bic    #^c<77>    ,val        ; /62/ faster
  267.     .endm    incm64
  268.  
  269.     .macro    indexm    reg        ; check for auto increment/decrement
  270.     .ntype    $$$0    ,reg        ; modes for macros that can't have..
  271.     .if  ne    $$$0-27            ; always allow pc autoincrement
  272.     $$$0 =    <$$$0&177770>/10    ; ..these modes in their arg list
  273.     .ift                ; get the mode into 0..7
  274.       .if  ge $$$0-2        ; if mode >=2 and mode <=5 then error
  275.       .iif ge <5-$$$0> .error      <; Can't use auto inc/dec mode here>
  276.       .endc
  277.     .endc
  278.     .endm    indexm
  279.  
  280.     .macro    ixor    reg ,dst
  281. ;    get around the mode restrictions for the hardware XOR instruction
  282. ;    and fix for RT-11 systems that don't have the EIS chip option
  283.     .chksp    reg            ; can't allow sp args
  284.     .chksp    dst            ; in either register
  285.     indexm    reg            ; check for allowed
  286.     indexm    dst            ; addressing mode
  287.     mov    reg    ,-(sp)        ; it's much simpler to do this
  288.     bic    dst    ,@sp        ; for all RT-11 systems rather
  289.     bic    reg    ,dst        ; than to be selective
  290.     bis    (sp)+    ,dst        ; done
  291.     .endm    ixor
  292.  
  293.     .macro    .newline        ; print CR/LF on TT
  294.     call    l$pcrlf
  295.     .endm    .newline
  296.  
  297.     .macro    octout    val
  298.     calls    l$wroct    ,<val>
  299.     .endm    octout
  300.  
  301.     .macro    prsbuf    dst
  302.     mov    dst    ,r0
  303.     call    prsarg
  304.     .endm    prsbuf
  305.  
  306.     .macro    rpack    len.a ,pakn.a ,msg.a ,max.len    ; /62/
  307.     sub    #10    ,sp
  308.     mov    sp    ,r1
  309.     calls    rpack$    ,<msg.a,r1,max.len>
  310.     mov    (r1)+    ,len.a
  311.     mov    (r1)+    ,pakn.a
  312.     mov    @r1    ,r1
  313.     add    #10    ,sp
  314.     .endm    rpack
  315.  
  316.     .macro    save    list
  317.     .if  b    <list>
  318.      save    <r0,r1,r2,r3,r4,r5>
  319.     .iff
  320.     .irp    x ,<list>
  321.      mov    x    ,-(sp)
  322.     .endr
  323.     .endc
  324.     .endm    save
  325.  
  326.     .macro    scan    ch ,str
  327.     mov    str    ,-(sp)
  328.     clr    -(sp)
  329.     bisb    ch    ,@sp
  330.     call    scanch
  331.     .endm    scan
  332.  
  333.     .macro    setpar    src ,dst
  334.     movb    src    ,-(sp)
  335.     call    dopari
  336.     movb    (sp)+    ,dst
  337.     .endm    setpar
  338.  
  339.     .macro    spack    type ,pnum ,len ,msg
  340.     .if  b    <len>
  341.     .iif nb    <msg>    .error    <; bad call to SPACK macro>
  342.     calls    spack$    ,<type,pnum,#0,#null>
  343.     .iff
  344.     calls    spack$    ,<type,pnum,len,msg>
  345.     .endc
  346.     .endm    spack
  347.  
  348.     .macro    strcat    dst ,src
  349.     mov    src    ,-(sp)
  350.     mov    dst    ,-(sp)
  351.     jsr    pc    ,strcat
  352.     .endm    strcat
  353.  
  354.     .macro    strcpy    dst ,src
  355.     mov    src    ,-(sp)
  356.     mov    dst    ,-(sp)
  357.     jsr    pc    ,strcpy
  358.     .endm    strcpy
  359.  
  360.     .macro    strlen    string
  361.     mov    string    ,r0
  362.     call    l$len
  363.     .endm    strlen
  364.  
  365.     .macro    textsrc    text
  366.     .if  b    <text>
  367.     clr    getcroutine        ; /62/ reset to file I/O
  368.     clr    tgetaddr
  369.     .iff
  370.     mov    #tgetcr0,getcroutine
  371.     mov    text    ,tgetaddr
  372.     .endc
  373.     .endm    textsrc
  374.  
  375.     .macro    tochar    src ,dst
  376.     clr    -(sp)
  377.     bisb    src    ,@sp
  378.     add    #40    ,@sp
  379.     movb    (sp)+    ,dst
  380.     .endm    tochar
  381.  
  382.     .macro    unchar    src ,dst
  383.     clr    -(sp)
  384.     bisb    src    ,@sp
  385.     sub    #40    ,@sp
  386.     movb    (sp)+    ,dst
  387.     .endm    unchar
  388.  
  389.     .macro    unsave    list
  390.     .if b <list>
  391.     unsave    <r5,r4,r3,r2,r1,r0>
  392.     .iff
  393.     .irp    x ,<list>
  394.      mov    (sp)+    ,x
  395.     .endr
  396.     .endc
  397.     .endm    unsave
  398.  
  399.     .macro    upcase    s        ; /BBS/ added ..
  400.     mov    s    ,r0
  401.     call    upcase            ; /BBS/ upcase until null terminator
  402.     .endm    upcase
  403.  
  404.     .macro    upone    s        ; /BBS/ added ..
  405.     mov    s    ,r0
  406.     call    upone            ; /BBS/ upcase only to next delimiter
  407.     .endm    upone
  408.  
  409.     .macro    wrtall    arg        ; IO.WAL for an .asciz string
  410.     mov    arg    ,-(sp)        ; pass the address
  411.     call    wrtall            ; do it
  412.     .endm    wrtall
  413.  
  414.     .macro    xor    reg ,dst
  415.     ixor    reg    ,dst
  416.     .endm    xor
  417.