home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 303.lha / AssemTools / Include / macros.i < prev    next >
Text File  |  1980-12-03  |  3KB  |  175 lines

  1. ; vers. 1.3    07.08.89
  2.  
  3. strcpy    macro    *srcreg,*dstreg
  4. ps.\@a    move.b    (\1)+,(\2)+
  5.     bne.s    ps.\@a
  6.     endm
  7.  
  8. strlen    macro    *strreg,len
  9.     move.l    \1,\2
  10. ps.\@a    tst.b    (\1)+
  11.     bne.s    ps.\@a
  12.     sub.l    \2,\1
  13.     exg.l    \1,\2
  14.     subq.l    #1,\2
  15.     endm
  16.  
  17. pstra    macro    reg,*string
  18.     ifnc    '\2','a1'
  19.     move.l    \2,a1
  20.     endc
  21. ps.\@a    move.b    (a1)+,(\1)+
  22.     bne.s    ps.\@a
  23.     subq.w    #1,\1
  24.     endm
  25.  
  26. ;Example:  pstra   a0,buffer(pc)    -> copies the contents of BUFFER
  27. ;       pstra   a0,(a4)
  28. ;
  29. ;does copy the string into the current address of <reg>
  30. ;and increments <reg> respectively. a null is added
  31. ;to the end address of <reg>.
  32.  
  33.  
  34. pstrn    macro    reg,*string,(UWORD)len
  35.     ifnc    '\2','a1'
  36.     move.l    \2,a1
  37.     endc
  38.     ifnc    '\3','d1'
  39.     move.w    \3,d1
  40.     endc
  41.     subq.w    #1,d1
  42. ps.\@a    move.b    (a1)+,(\1)+
  43.     dbf    d1,ps.\@a
  44.     clr.b    (\1)
  45.     endm
  46.  
  47. ;does copy a given number of characters into the current addr
  48. ;of <reg>. <reg> is incremented respectively. A null is
  49. ;added into the end of target string.
  50.  
  51.  
  52. lstr    macro    reg,string
  53.     lea    ps.\@a(pc),\1
  54.     ifc    '\3',''
  55.     bra.s    ps.\@b
  56.     endc
  57.     ifnc    '\3',''
  58.     \3    \4
  59.     endc
  60. ps.\@a    dc.b    \2
  61.     dc.b    0
  62.     ds.w    0
  63. ps.\@b
  64.     endm
  65.  
  66. ;Example:    lstr    a0,<'-ADD'>
  67. ;loads the address of a string into an address register
  68. ;        lstr    a0,<'Error: '>,rts
  69. ;        lstr    a0,<'Illegal Quantity'>,bra,stderr
  70.  
  71.  
  72. pstr    macro    reg,string
  73.     lea    ps.\@a(pc),a1
  74. ps.\@b    move.b    (a1)+,(\1)+
  75.     bne.s    ps.\@b
  76.     subq.w    #1,\1
  77.     bra.s    ps.\@c
  78. ps.\@a    dc.b    \2
  79.     dc.b    0
  80.     ds.w    0
  81. ps.\@c
  82.     endm
  83.  
  84. ;Example:  pstr    a0,<' - Error code '>
  85. ;puts the string into the current address of <reg>
  86. ;and increments <reg> respectively. a null is added
  87. ;to the end address of <reg>.
  88.  
  89.  
  90. pnull    macro    reg
  91.     clr.b    (\1)+
  92.     endm
  93.  
  94. ;Needs no example, eh
  95.  
  96.  
  97. plf    macro    reg
  98.     move.b    #10,(\1)+
  99.     endm
  100.  
  101. ;Needs no example, eh
  102.  
  103.  
  104. pchr    macro    reg,chr
  105.     move.b    \2,(\1)+
  106.     endm
  107.  
  108. ;Needs no example, eh
  109.  
  110.  
  111. ; MACROS FOR ALLOCMENU
  112.  
  113. ;    .menu    'Project'
  114. ;    .item    'New',<'IW',180>
  115. ;    .item    'Open',,'O'
  116. ;    .item    'Save',,'S'
  117. ;    .item    'Save As',,'J'
  118. ;    .item    'Print'
  119. ;    .subitm    'Draft',<'IW',60>
  120. ;    .subitm    'NLQ'
  121. ;    .item    'Quit',,'Q'
  122. ;    dc.w    0
  123.  
  124. .menu    macro    'name',<specdata>
  125.     dc.b    1,0
  126.     dc.w    .menuE\@-.menuB\@
  127. .menuB\@
  128.     ifnc    '\2',''
  129.     dc.w    \2
  130.     endc
  131. .menuE\@
  132.     dc.b    \1
  133.     dc.b    0
  134.     ds.w    0
  135.     endm
  136.  
  137. .item    macro    'name',<specdata> [,'cmd']
  138.     dc.b    2
  139.     ifnc    '\3',''
  140.     dc.b    \3
  141.     endc
  142.     ifc    '\3',''
  143.     dc.b    0
  144.     endc
  145.     dc.w    .itemE\@-.itemB\@
  146. .itemB\@
  147.     ifnc    '\2',''
  148.     dc.w    \2
  149.     endc
  150. .itemE\@
  151.     dc.b    \1
  152.     dc.b    0
  153.     ds.w    0
  154.     endm
  155.  
  156. .subitm    macro    'name',<specdata> [,'cmd']
  157.     dc.b    3
  158.     ifnc    '\3',''
  159.     dc.b    \3
  160.     endc
  161.     ifc    '\3',''
  162.     dc.b    0
  163.     endc
  164.     dc.w    .subitmE\@-.subitmB\@
  165. .subitmB\@
  166.     ifnc    '\2',''
  167.     dc.w    \2
  168.     endc
  169. .subitmE\@
  170.     dc.b    \1
  171.     dc.b    0
  172.     ds.w    0
  173.     endm
  174.  
  175.