home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krtatr.min < prev    next >
Text File  |  2020-01-01  |  7KB  |  528 lines

  1.     .title    KRTATR.MIN  Process attribute packets
  2.     .ident    "V03.62"
  3.  
  4. ; /62/    31-May-93  Billy Youdelman
  5.  
  6. ;    Copyright 1984 Change Software, Inc.
  7.  
  8.     .include "IN:KRTMAC.MIN"
  9.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MIN failed>
  10.  
  11.     .mcall    .DATE    ,.GTIM
  12.  
  13.     .psect    tempdata,rw,d,lcl,rel,con
  14. atrctx:    .word    0
  15. curatr:    .blkb    200
  16. day.x:    .word    0
  17. day.y:    .byte    0 ,0 ,0 ,0
  18. mon.x:    .word    0
  19. mon.y:    .byte    0 ,0 ,0 ,0
  20. sizbuf:    .byte    0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0
  21. xblock:    .word    0 ,0
  22. yr.x:    .word    0
  23. yr.y:    .byte    0 ,0 ,0 ,0 ,0 ,0
  24.  
  25.  
  26.     .psect    $code
  27.     .sbttl    Send all attributes in a single packet
  28.  
  29. w$attr::save    <r2,r3,r4>
  30.     clr    r1
  31.     bitb    #capa.a    ,conpar+p.capas
  32.     beq    100$
  33.     mov    2(r5)    ,r4
  34.     clr    atrctx
  35.  
  36. 10$:    mov    atrctx    ,r0
  37.     asl    r0
  38.     tst    watt(r0)
  39.     beq    30$
  40.     jsr    pc    ,@watt(r0)
  41.     inc    atrctx
  42.     br    10$
  43.  
  44. 30$:    strlen    2(r5)
  45.     mov    r0    ,r1
  46. 100$:    clr    r0
  47.     unsave    <r4,r3,r2>
  48.     return
  49.  
  50.     .save
  51.     .psect    $pdata
  52. watt:    .word    sn.sys    ,sn.typ    ,sn.pr1    ,sn.len    ,sn.fty    ,sn.cdt    ,sn.xlen
  53.     .word    0
  54.     .restore
  55.  
  56.     .sbttl    Send system type
  57.  
  58. sn.sys:    movb    #'.    ,(r4)+
  59.     movb    #42    ,(r4)+
  60.     movb    #'D&137    ,(r4)+
  61.     movb    #'B&137    ,(r4)+
  62.     clrb    @r4
  63.     return
  64.  
  65.  
  66.     .sbttl    Send generic file type
  67.  
  68. sn.typ:    movb    #42    ,(r4)+
  69.     movb    #41    ,(r4)+
  70.     movb    #'A&137    ,r0
  71.     cmpb    image    ,#binary
  72.     bne    10$
  73.     movb    #'B&137    ,r0
  74. 10$:    movb    r0    ,(r4)+
  75.     clrb    (r4)
  76.     return
  77.  
  78.  
  79.     .sbttl    Send file protection
  80.  
  81. sn.pr1:    movb    #55    ,(r4)+
  82.     movb    #41    ,(r4)+
  83.     mov    (r5)    ,r0
  84.     asl    r0
  85.     tst    prot.a(r0)
  86.     bne    10$
  87.     mov    #<1!2!4!10!20!40>,r0
  88.     br    30$
  89. 10$:    mov    #<1!4!40>,r0
  90. 30$:    add    #40    ,r0
  91.     movb    r0    ,(r4)+
  92.     clrb    @r4
  93.     return
  94.  
  95.  
  96.     .sbttl    Send file length
  97.  
  98. sn.len:    mov    (r5)    ,r1
  99.     asl    r1
  100.     mov    sizof(r1),r1
  101.     inc    r1
  102.     asr    r1
  103.     bne    1$
  104.     inc    r1
  105. 1$:    movb    #41    ,(r4)+
  106.     movb    #45    ,(r4)+
  107.     deccvt    r1    ,r4    ,#5
  108.     mov    #5    ,r0
  109. 10$:    cmpb    @r4    ,#space
  110.     bne    20$
  111.     movb    #'0    ,@r4
  112. 20$:    inc    r4
  113.     sob    r0    ,10$
  114.     clrb    @r4
  115.     return
  116.  
  117.  
  118.     .sbttl    Send DEC_specific file type
  119.     .enabl    lsb
  120.  
  121. sn.fty:    movb    #'0    ,(r4)+
  122.     movb    #42    ,(r4)+
  123.     movb    #42    ,(r4)+
  124.     mov    image    ,r0
  125.     movb    200$(r0),(r4)+
  126.     clrb    @r4
  127.     return
  128.  
  129.     .save
  130.     .psect    $pdata
  131. 200$:    .byte    'A&137    ,'I&137    ,'N&137
  132.     .even
  133.     .restore
  134.  
  135.     .dsabl    lsb
  136.  
  137.  
  138.     .sbttl    Get file creation date
  139.  
  140. sn.cdt:    save    <r4>
  141.     mov    (r5)    ,r4
  142.     asl    r4
  143.     mov    date.a(r4),r0
  144.     mov    #curatr    ,r1
  145.  
  146.     mov    r0    ,r3
  147.     bic    #^c37    ,r3
  148.     add    #1972.    ,r3
  149.     mov    r0    ,r2
  150.     bic    #^c140000,r2
  151.     swab    r2
  152.     asr    r2
  153.     add    r2    ,r3
  154.     call    i4toa
  155.  
  156.     mov    r0    ,r3
  157.     swab    r3
  158.     asr    r3
  159.     asr    r3
  160.     bic    #^c37    ,r3
  161.     call    i2toa
  162.  
  163.     mov    r0    ,r3
  164.     ash    #3    ,r3
  165.     swab    r3
  166.     bic    #^c37    ,r3
  167.     call    i2toa
  168.  
  169.     clrb    @r1
  170.     unsave    <r4>
  171.     mov    #curatr    ,r1
  172.     strlen    r1
  173.     add    #40    ,r0
  174.     movb    #'#    ,(r4)+
  175.     movb    r0    ,(r4)+
  176. 95$:    movb    (r1)+    ,(r4)+
  177.     bne    95$
  178.     dec    r4
  179. 100$:    return
  180.  
  181.  
  182.     .sbttl    Send file length in bytes
  183.  
  184. sn.xlen:mov    (r5)    ,r3
  185.     asl    r3
  186.     mov    sizof(r3),r3
  187.     bne    1$
  188.     inc    r3
  189. 1$:    clr    r2
  190.     mov    #512.    ,r0
  191.     call    $dmul
  192.     mov    r0    ,xblock
  193.     mov    r1    ,xblock+2
  194.     clr    r2
  195.     mov    #xblock    ,r1
  196.     mov    #sizbuf    ,r0
  197.     call    $cddmg
  198.     clrb    @r0
  199.     cmpb    #'*    ,sizbuf
  200.     beq    9$
  201.     strlen    #sizbuf
  202.     movb    #61    ,(r4)+
  203.     add    #40    ,r0
  204.     movb    r0    ,(r4)+
  205.     mov    #sizbuf    ,r0
  206. 3$:    movb    (r0)+    ,(r4)+
  207.     bne    3$
  208. 9$:    return
  209.  
  210.  
  211.     .sbttl    Received attribute packet processing
  212.  
  213. r$attr::save    <r1,r2,r5>
  214.     tst    doattr
  215.     beq    99$
  216.     mov    @r5    ,r5
  217.  
  218. 10$:    movb    (r5)+    ,r0
  219.     beq    90$
  220.     movb    (r5)+    ,r1
  221.     beq    90$
  222.     cmpb    r0    ,#'.
  223.     bne    20$
  224.     cmpb    r1    ,#'D&137
  225.     bne    20$
  226.     dec    r5
  227.     mov    #42    ,r1
  228.  
  229. 20$:    sub    #40    ,r1
  230.     ble    90$
  231.     mov    #curatr    ,r2
  232. 40$:    movb    (r5)+    ,(r2)+
  233.     sob    r1    ,40$
  234.     clrb    (r2)+
  235.     mov    r5    ,-(sp)
  236.     scan    r0    ,#attrty
  237.     asl    r0
  238.     jsr    pc    ,@attrds(r0)
  239.     mov    (sp)+    ,r5
  240.     tst    r0
  241.     beq    10$
  242.     br    100$
  243.  
  244. 90$:    call    ispdp
  245.     cmp    r0    ,#4
  246.     beq    99$
  247.     cmp    image    ,#binary
  248.     beq    99$
  249.     mov    at$len    ,r0
  250.     beq    100$
  251.     asr    r0
  252.     asr    r0
  253.     inc    r0
  254.     add    r0    ,at$len
  255.     bcc    99$
  256.     mov    #65497.    ,at$len
  257. 99$:    clr    r0
  258. 100$:    unsave    <r5,r2,r1>
  259.     return
  260.  
  261.     .save
  262.     .psect    $pdata
  263. attrty:    .byte    41    ,42    ,43    ,55    ,56    ,60    ,61
  264.     .byte    0
  265.     .even
  266. attrds:    .word    at.$$
  267.     .word    at.len    ,at.typ    ,at.cre    ,at.pr1    ,at.sys    ,at.fab    ,at.xle
  268.     .restore
  269.  
  270.  
  271.     .sbttl    Null attribute handler
  272.  
  273. at.$$:    clr    r0
  274.     return
  275.  
  276.  
  277.     .sbttl    Process received length specified in 1024. byte blocks
  278.  
  279. at.len:    tst    at$len
  280.     bne    100$
  281.     mov    #curatr    ,r2
  282.     clr    r1
  283. 10$:    tstb    @r2
  284.     beq    30$
  285.     cmpb    @r2    ,#space
  286.     beq    20$
  287.     clr    -(sp)
  288.     bisb    @r2    ,@sp
  289.     sub    #'0    ,@sp
  290.     mul    #12    ,r1
  291.     add    (sp)+    ,r1
  292. 20$:    inc    r2
  293.     br    10$
  294. 30$:    asl    r1
  295.     mov    r1    ,at$len
  296. 100$:    clr    r0
  297.     return
  298.  
  299.  
  300.     .sbttl    Received file type
  301.  
  302. at.typ:    tst    doauto
  303.     bne    1$
  304.     mov    $image    ,image
  305.     br    100$
  306. 1$:    cmpb    curatr    ,#'B&137
  307.     beq    10$
  308.     cmpb    curatr    ,#'I&137
  309.     bne    100$
  310. 10$:    mov    #binary    ,image
  311. 100$:    clr    r0
  312.     return
  313.  
  314.  
  315.     .sbttl    Put create date where close can get them later
  316.  
  317. at.cre:    clr    -(sp)
  318.     scan    #space    ,#curatr
  319.     tst    r0
  320.     bne    1$
  321.     strlen    #curatr
  322.     cmp    r0    ,#7
  323.     bgt    3$
  324.     br    10$
  325.  
  326. 1$:    cmp    r0    ,#10
  327.     blt    10$
  328. 3$:    mov    sp    ,(sp)
  329. 10$:    mov    #curatr    ,r1
  330.     mov    #yr.y    ,r0
  331.     call    mov2b
  332.     tst    (sp)+
  333.     beq    13$
  334.     call    mov2b
  335. 13$:    mov    #mon.y    ,r0
  336.     call    mov2b
  337.     mov    #day.y    ,r0
  338.     call    mov2b
  339.  
  340.     mov    #yr.y    ,r3
  341.     call    gnum
  342.     mov    r1    ,yr.x
  343.     mov    #mon.y    ,r3
  344.     call    gnum
  345.     mov    r1    ,mon.x
  346.     mov    #day.y    ,r3
  347.     call    gnum
  348.     mov    r1    ,day.x
  349.  
  350.     mov    mon.x    ,r1
  351.     ash    #5    ,r1
  352.     add    day.x    ,r1
  353.     ash    #5    ,r1
  354.  
  355.     mov    yr.x    ,-(sp)
  356.     cmp    (sp)    ,#100.
  357.     bge    20$
  358.  
  359.     cmp    (sp)    ,#71.
  360.     ble    17$
  361.     add    #1900.    ,(sp)
  362.     br    20$
  363. 17$:    add    #2000.    ,(sp)
  364.  
  365. 20$:    sub    #1972.    ,(sp)
  366.     bge    23$
  367.     clr    r1
  368.     br    30$
  369.  
  370. 23$:    mov    (sp)    ,r0
  371.     bic    #^c<40!100>,r0
  372.     asl    r0
  373.     swab    r0
  374.     bic    #^c37    ,(sp)
  375.     add    (sp)    ,r1
  376.     bis    r0    ,r1
  377.  
  378. 30$:    tst    (sp)+
  379.     mov    #lun.ou    ,r0
  380.     asl    r0
  381.     mov    r1    ,date.a(r0)
  382.     clr    r0
  383.     return
  384.  
  385. mov2b:    movb    (r1)+    ,(r0)+
  386.     movb    (r1)+    ,(r0)+
  387.     clrb    (r0)
  388.     return
  389.  
  390. gnum:    clr    r1
  391. 10$:    movb    (r3)+    ,r0
  392.     sub    #'9+1    ,r0
  393.     add    #9.+1    ,r0
  394.     bcc    20$
  395.     mul    #10.    ,r1
  396.     add    r0    ,r1
  397.     br    10$
  398. 20$:    tstb    -(r3)
  399.     rts    pc
  400.  
  401.  
  402.     .sbttl    Put file protection code where close can get it later
  403.  
  404. at.pr1:    mov    #lun.ou    ,r1
  405.     asl    r1
  406.     bicb    #<1!4!40!100!200>,curatr
  407.     beq    10$
  408.     clr    prot.a(r1)
  409.     br    100$
  410. 10$:    mov    sp    ,prot.a(r1)
  411. 100$:    clr    r0
  412.     return
  413.  
  414.  
  415.     .sbttl    Received system type
  416.  
  417. at.sys:    movb    curatr    ,at$sys
  418.     movb    curatr+1,at$sys+1
  419.     clr    r0
  420.     return
  421.  
  422.  
  423.     .sbttl    Receive IFAB file attributes data from another PDP-11
  424.     .enabl    lsb
  425.  
  426. at.fab:    call    ispdp
  427.     tst    r0
  428.     beq    100$
  429.     mov    #curatr    ,r0
  430.     cmpb    (r0)+    ,#42
  431.     bne    100$
  432.     tst    doauto
  433.     beq    100$
  434.     scan    (r0)    ,#200$
  435.     asl    r0
  436.     mov    210$(r0),image
  437. 100$:    clr    r0
  438.     return
  439.  
  440.     .save
  441.     .psect    $pdata
  442. 200$:    .byte    'A&137    ,'I&137    ,'N&137
  443.     .byte    0
  444.     .even
  445. 210$:    .word    TEXT
  446.     .word    TEXT    ,BINARY    ,DECNAT
  447.     .restore
  448.  
  449.     .dsabl    lsb
  450.  
  451.  
  452.     .sbttl    Exact file size in bytes (type "1")
  453.  
  454. at.xlen:mov    #curatr    ,r5
  455.     clr    r3
  456.     clr    r2
  457. 10$:    tstb    @r5
  458.     beq    30$
  459.     cmpb    @r5    ,#space
  460.     beq    20$
  461.     mov    #12    ,r0
  462.     call    $dmul
  463.     mov    r0    ,r2
  464.     mov    r1    ,r3
  465.     clr    -(sp)
  466.     bisb    @r5    ,@sp
  467.     sub    #'0    ,@sp
  468.     add    (sp)+    ,r3
  469.     adc    r2
  470. 20$:    inc    r5
  471.     br    10$
  472. 30$:    div    #1000    ,r2
  473.     mov    r2    ,at$len
  474.     tst    r3
  475.     beq    100$
  476.     inc    at$len
  477. 100$:    clr    r0
  478.     return
  479.  
  480.  
  481.     .sbttl    Determine if other system is a PDP-11
  482.  
  483.     PD$RSX    = '8
  484.     PD$IAS    = '9
  485.     PD$RSTS    = 'A&137
  486.     PD$RT    = 'B&137
  487.     PD$POS    = 'C&137
  488.  
  489. ispdp:    clr    r0
  490.     cmpb    at$sys    ,#'D&137
  491.     bne    100$
  492.     scan    <at$sys+1>,#pdplst
  493. 100$:    return
  494.  
  495.     .save
  496.     .psect    $pdata
  497. pdplst:    .byte    pd$rsx    ,pd$ias    ,pd$rsts,pd$rt    ,pd$pos    ,0
  498.     .even
  499.     .restore
  500.  
  501.  
  502.     .sbttl    Clear attributes
  503.  
  504. clratr::clr    at$len
  505.     clr    at$sys
  506.     return
  507.  
  508.  
  509.     .sbttl    32-bit multiply from RSX SYSLIB.OLB
  510.  
  511. $DMUL:    MOV    R0    ,-(SP)
  512.     CLR    R0
  513.     CLR    R1
  514. 10$:    TST    (SP)
  515.     BEQ    30$
  516.     ROR    (SP)
  517.     BCC    20$
  518.     ADD    R3    ,R1
  519.     ADC    R0
  520.     ADD    R2    ,R0
  521. 20$:    ASL    R3
  522.     ROL    R2
  523.     BR    10$
  524. 30$:    TST    (SP)+
  525.     RETURN
  526.  
  527.     .end
  528.