Advertisement
Guest User

sonic3k.macrosetup.asm

a guest
Nov 6th, 2011
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     padding off ; we don't want AS padding out dc.b instructions
  2.     listing off ; we don't need to generate anything for a listing file
  3.     supmode on  ; we don't need warnings about privileged instructions
  4.  
  5. notZ80 function cpu,(cpu<>128)&&(cpu<>32988)
  6.  
  7. ; make org safer (impossible to overwrite previously assembled bytes)
  8. org macro address
  9.     if notZ80(MOMCPU)
  10.         if address < *
  11.             error "too much stuff before org $\{address} ($\{(*-address)} bytes)"
  12.         else
  13.             !org address
  14.         endif
  15.     else
  16.         if address < $
  17.             error "too much stuff before org 0\{address}h (0\{($-address)}h bytes)"
  18.         else
  19.             while address > $
  20.                 db 0
  21.             endm
  22.         endif
  23.     endif
  24.     endm
  25.  
  26. ; define an alternate org that fills the extra space with 0s instead of FFs
  27. org0 macro address
  28. diff := address - *
  29.     if diff < 0
  30.         error "too much stuff before org0 $\{address} ($\{(-diff)} bytes)"
  31.     else
  32.         while diff > 1024
  33.             ; AS can only generate 1 kb of code on a single line
  34.             dc.b [1024]0
  35. diff := diff - 1024
  36.         endm
  37.         dc.b [diff]0
  38.     endif
  39.     endm
  40.  
  41. ; define the cnop pseudo-instruction
  42. cnop macro offset,alignment
  43.     if notZ80(MOMCPU)
  44.         org (*-1+(alignment)-((*-1+(-(offset)))#(alignment)))
  45.     else
  46.         org ($-1+(alignment)-(($-1+(-(offset)))#(alignment)))
  47.     endif
  48.     endm
  49.  
  50. ; define an alternate cnop that fills the extra space with 0s instead of FFs
  51. cnop0 macro offset,alignment
  52.     org0 (*-1+(alignment)-((*-1+(-(offset)))#(alignment)))
  53.     endm
  54.  
  55. ; redefine align in terms of cnop, because the built-in align can be stupid sometimes
  56. align macro alignment
  57.     cnop 0,alignment
  58.     endm
  59.  
  60. ; define an alternate align that fills the extra space with 0s instead of FFs
  61. align0 macro alignment
  62.     cnop0 0,alignment
  63.     endm
  64.  
  65. ; define the even pseudo-instruction
  66. even macro
  67.     align 2
  68.     endm
  69.  
  70. ; define a trace macro
  71. ; lets you easily check what address a location in this disassembly assembles to
  72. trace macro optionalMessageWithoutQuotes
  73.     if MOMPASS=1
  74.         if ("ALLARGS"<>"")
  75.             message "#\{tracenum/1.0}: line=\{MOMLINE/1.0} PC=$\{(*)&$FFFFFFFF} msg=ALLARGS"
  76.         else
  77.             message "#\{tracenum/1.0}: line=\{MOMLINE/1.0} PC=$\{(*)&$FFFFFFFF}"
  78.         endif
  79. tracenum := (tracenum+1)
  80.     endif
  81.    endm
  82. tracenum := 0
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement