home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / pdp11 / krtmac.mac < prev    next >
Text File  |  1996-10-17  |  12KB  |  468 lines

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