home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / langs / forst.zoo / forst / src / memory.s < prev    next >
Encoding:
Text File  |  1990-12-10  |  2.9 KB  |  209 lines

  1. ; MEMORY.S: utility routines.
  2. ; <C> John Redmond 1989
  3. ;  Public domain for non-commercial use.
  4. ;
  5.     section    text
  6.     even
  7. ;
  8. _fill:
  9.     movem.l (a6)+,d0/d1/a0        ;address,length,char 
  10.     tst.l    d1            ;length zero? 
  11.     beq    .cfx 
  12. .cflp:    move.b    d0,(a0)+        ;store char 
  13.     subq.l    #1,d1
  14.     bne    .cflp
  15. .cfx:    rts 
  16. _cmove: movem.l (a6)+,d0/a0/a1        ;source,dest,length
  17.     tst.l    d0            ;zero length? 
  18.     beq    .cmx 
  19. .cmlp:    move.b    (a1)+,(a0)+ 
  20.     subq.l    #1,d0
  21.     bne    .cmlp
  22. .cmx:    rts 
  23. _cmovegt:
  24.     movem.l (a6)+,d0/a0/a1        ;source,dest,length 
  25.     tst.l    d0            ;zero length? 
  26.     beq    .cmx 
  27.     adda.l    d0,a0
  28.     adda.l    d0,a1
  29. .cmlp:    move.b    -(a1),-(a0)
  30.     subq.l    #1,d0
  31.     bne    .cmlp
  32. .cmx:    rts 
  33. _rot:    move.l    d2,-(a7)
  34.     pop    d0
  35.     pop    d1
  36.     pop    d2
  37.     push    d1
  38.     push    d0
  39.     push    d2
  40.     move.l    (a7)+,d2
  41.     rts
  42. ;
  43. _pick:    pop    d0
  44.     bmi    .px
  45.     asl.l    #2,d0
  46.     move.l    0(a6,d0.l),d0
  47.     push    d0
  48. .px:    rts
  49. ;
  50. _twodup: move.l (a6),d1
  51.     move.l    4(a6),d0
  52.     push    d0
  53.     push    d1
  54.     rts
  55. ;
  56. _twoover: move.l 8(a6),d1
  57.     move.l    12(a6),d0
  58.     push    d0
  59.     push    d1
  60.     rts
  61. ;
  62. _twoswap: movem.l d2-d3,-(a7)
  63.     movem.l (a6)+,d0-d3
  64.     movem.l d0-d1,-(a6)
  65.     push    d3
  66.     push    d2
  67.     movem.l (a7)+,d2-d3
  68.     rts
  69. ;
  70. _tworot: movem.l d2-d5,-(a7)
  71.     movem.l (a6)+,d0-d5
  72.     movem.l d0-d3,-(a6)
  73.     push    d1
  74.     move.l    d0,d1
  75.     push    d1
  76.     movem.l (a7)+,d2-d5
  77.     rts
  78. ;
  79. _twodrop: addq.l #8,a6
  80.     rts
  81. ;
  82. _depth: lea    dstack,a0
  83.     move.l    (a0),d0
  84.     sub.l    a6,d0
  85.     asr.l    #2,d0
  86.     push    d0
  87.     rts
  88. ;
  89. _minusrot: movem.l d1-d2,-(a7)
  90.     movem.l (a6)+,d0-d2
  91.     push    d0
  92.     push    d2
  93.     push    d1
  94.     movem.l (a7)+,d1-d2
  95.     rts
  96. ;
  97. _tuck:    pop    d0
  98.     pop    d1
  99.     push    d0
  100.     push    d1
  101.     push    d0
  102.     rts
  103. ;
  104. _spstore: pop    a6
  105.     rts
  106. ;
  107. _rpstore: pop    a7
  108.     rts
  109. ;
  110. _on:    pop    a0
  111.     move.l    #-1,(a0)
  112.     rts
  113. ;
  114. _off:    pop    a0
  115.     clr.l    (a0)
  116.     rts
  117. ;
  118. _pad:    bsr    _here
  119.     add.l    #$100,(a6)
  120.     rts
  121. ;
  122. _notrailing:
  123.     movem.l (a6)+,d0/a0 
  124. .trlp:    subq.l    #1,d0
  125.     bmi    .empty
  126.     move.b    (a0,d0.l),d1
  127.     cmp.b    #32,d1        ;a blank?
  128.     bne    .end
  129.     bra    .trlp
  130. .end:    addq.l    #1,d0        ;adjust length
  131.     movem.l d0/a0,-(a6)    ;^string & trimmed length
  132.     rts
  133. .empty: clr.l    d0
  134.     movem.l d0/a0,-(a6)
  135.     rts
  136. ;
  137. _comp:    pop    d0        ;length
  138.     moveq    #0,d1        ;result
  139.     pop    a0
  140.     pop    a1
  141.     tst.l    d0
  142.     beq    .cx
  143.     subq.l    #1,d0
  144. .clp:    cmpm.b    (a0)+,(a1)+
  145.     dbne    d0,.clp
  146.     beq    .cx
  147.     bcs    .cw
  148.     moveq    #1,d1
  149.     bra    .cx
  150. .cw    moveq    #-1,d1
  151. .cx    push    d1
  152.     rts
  153. ;
  154.     section    data
  155.     even
  156. ;
  157. ; string and block words
  158. ;
  159.     dc.b    $84,'FILL',$a0
  160.     ptrs    _fill,18
  161. ;
  162.     dc.b    $84,'TYPE',$a0
  163.     ptrs    _type,18
  164. ;
  165.     dc.b    $85,'CMOV','E'!$80
  166.     ptrs    _cmove,18
  167. ;
  168.     dc.b    $86,'CMOVE>',$a0
  169.     ptrs    _cmovegt,20
  170. ;
  171.     dc.b    $89,'-TRAILIN','G'!$80
  172.     ptrs    _notrailing,22
  173. ;
  174.     dc.b    $84,'COMP',$a0
  175.     ptrs    _comp,18
  176. ;
  177.     dc.b    $83,'RO','T'!$80
  178.     ptrs    _rot,16
  179. ;
  180.     dc.b    $84,'-ROT',$a0
  181.     ptrs    _minusrot,18
  182. ;
  183.     dc.b    $84,'PICK',$a0
  184.     ptrs    _pick,18
  185. ;
  186.     dc.b    $84,'TUCK',$a0
  187.     ptrs    _tuck,18
  188. ;
  189.     dc.b    $84,'2DUP',$a0
  190.     ptrs    _twodup,18
  191. ;
  192.     dc.b    $85,'2OVE','R'!$80
  193.     ptrs    _twoover,18
  194. ;
  195.     dc.b    $85,'2SWA','P'!80
  196.     ptrs    _twoswap,18
  197. ;
  198.     dc.b    $84,'2ROT',$a0
  199.     ptrs    _tworot,18
  200. ;
  201.     dc.b    $85,'DEPT','H'!$80
  202.     ptrs    _depth,18
  203. ;
  204.     dc.b    $83,'PA','D'!$80
  205.     ptrs    _pad,16
  206.