| 1 |
|
| 2 |
|
| 3 |
ACME |
| 4 |
|
| 5 |
...the ACME Crossassembler for Multiple Environments |
| 6 |
|
| 7 |
--- pseudo opcodes --- |
| 8 |
|
| 9 |
|
| 10 |
This is a list of all the pseudo opcodes currently implemented. |
| 11 |
Stuff in square brackets is optional, stuff followed by "*" may be |
| 12 |
given more than once. This list is not sorted alphabetically, the |
| 13 |
pseudo opcodes are grouped together according to their usage. |
| 14 |
|
| 15 |
|
| 16 |
---------------------------------------------------------------------- |
| 17 |
Section: How to insert values |
| 18 |
---------------------------------------------------------------------- |
| 19 |
|
| 20 |
Call: !8 EXPRESSION [, EXPRESSION]* |
| 21 |
Purpose: Insert 8-bit values. |
| 22 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 23 |
"list" objects will be treated as if all their items |
| 24 |
were given separately. |
| 25 |
Aliases: "!by", "!byt", "!byte", "!08" |
| 26 |
Examples: !8 127, symbol, -128 ; output some values |
| 27 |
!by 14, $3d, %0110, &304, <*, 'c' |
| 28 |
!byte 3 - 4, symbol1 XOR symbol2, 2 ^ tz, (3+4)*7 |
| 29 |
!byte [2, 3, 5, 7], other_list ; iterate over items |
| 30 |
|
| 31 |
|
| 32 |
Call: !16 EXPRESSION [, EXPRESSION]* |
| 33 |
Purpose: Insert 16-bit values in chosen CPU's byte order. |
| 34 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 35 |
Aliases: "!wo", "!word" (and because all currently supported |
| 36 |
CPUs are little-endian, "!le16" is in fact another |
| 37 |
alias) |
| 38 |
Examples: !16 65535, symbol, -32768 ; output some values |
| 39 |
!wo 14, $4f35, %100101010010110, &36304, *, 'c' |
| 40 |
!word 3000 - 4, a1 AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 41 |
!word [2, 3, 5, 7], other_list ; iterate over items |
| 42 |
|
| 43 |
Call: !le16 EXPRESSION [, EXPRESSION]* |
| 44 |
Purpose: Insert 16-bit values in little-endian byte order. |
| 45 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 46 |
Aliases: None (but because all currently supported CPUs are |
| 47 |
little-endian, "!16/!wo/!word" are in fact aliases) |
| 48 |
Examples: !le16 65535, symbol, -32768 ; output some values |
| 49 |
!le16 14, $4f35, %100101010010110, &36304, *, 'c' |
| 50 |
!le16 3000 - 4, a1 AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 51 |
!le16 [2, 3, 5, 7], other_list ; iterate over items |
| 52 |
|
| 53 |
Call: !be16 EXPRESSION [, EXPRESSION]* |
| 54 |
Purpose: Insert 16-bit values in big-endian byte order. |
| 55 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 56 |
Aliases: None |
| 57 |
Examples: !be16 65535, symbol, -32768 ; output some values |
| 58 |
!be16 14, $4f35, %100101010010110, &36304, *, 'c' |
| 59 |
!be16 3000 - 4, a1 AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 60 |
!be16 [2, 3, 5, 7], other_list ; iterate over items |
| 61 |
|
| 62 |
|
| 63 |
Call: !24 EXPRESSION [, EXPRESSION]* |
| 64 |
Purpose: Insert 24-bit values in chosen CPU's byte order. |
| 65 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 66 |
Aliases: None (but because all currently supported CPUs are |
| 67 |
little-endian, "!le24" is in fact an alias) |
| 68 |
Examples: !24 16777215, symbol, -8388608, 14, $6a4f35 |
| 69 |
!24 %10010110100101010010110, &47336304, *, 'c' |
| 70 |
!24 300000 - 4, a1 AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 71 |
!24 [2, 3, 5, 7], other_list ; iterate over items |
| 72 |
|
| 73 |
Call: !le24 EXPRESSION [, EXPRESSION]* |
| 74 |
Purpose: Insert 24-bit values in little-endian byte order. |
| 75 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 76 |
Aliases: None (but because all currently supported CPUs are |
| 77 |
little-endian, "!24" is in fact an alias) |
| 78 |
Examples: !le24 16777215, symbol, -8388608, 14, $6a4f35 |
| 79 |
!le24 %10010110100101010010110, &47336304, *, 'c' |
| 80 |
!le24 300000 - 4, a1 AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 81 |
!le24 [2, 3, 5, 7], other_list ; iterate over items |
| 82 |
|
| 83 |
Call: !be24 EXPRESSION [, EXPRESSION]* |
| 84 |
Purpose: Insert 24-bit values in big-endian byte order. |
| 85 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 86 |
Aliases: None |
| 87 |
Examples: !be24 16777215, symbol, -8388608, 14, $6a4f35 |
| 88 |
!be24 %10010110100101010010110, &47336304, *, 'c' |
| 89 |
!be24 300000 - 4, a1 AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 90 |
!be24 [2, 3, 5, 7], other_list ; iterate over items |
| 91 |
|
| 92 |
|
| 93 |
Call: !32 EXPRESSION [, EXPRESSION]* |
| 94 |
Purpose: Insert 32-bit values in chosen CPU's byte order. |
| 95 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 96 |
Aliases: None (but because all currently supported CPUs are |
| 97 |
little-endian, "!le32" is in fact an alias) |
| 98 |
Examples: !32 $7fffffff, symbol, -$80000000, 14, $46a4f35 |
| 99 |
!32 %1001011010010101001011010010, &4733630435, *, 'c' |
| 100 |
!32 300000 - 4, a AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 101 |
!32 [2, 3, 5, 7], other_list ; iterate over items |
| 102 |
|
| 103 |
Call: !le32 EXPRESSION [, EXPRESSION]* |
| 104 |
Purpose: Insert 32-bit values in little-endian byte order. |
| 105 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 106 |
Aliases: None (but because all currently supported CPUs are |
| 107 |
little-endian, "!32" is in fact an alias) |
| 108 |
Examples: !le32 $7fffffff, symbol, -$80000000, 14, $46a4f35 |
| 109 |
!le32 %1001011010010101001011010010, &4733630435, *, 'c' |
| 110 |
!le32 300000 - 4, a AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 111 |
!le32 [2, 3, 5, 7], other_list ; iterate over items |
| 112 |
|
| 113 |
Call: !be32 EXPRESSION [, EXPRESSION]* |
| 114 |
Purpose: Insert 32-bit values in big-endian byte order. |
| 115 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 116 |
Aliases: None |
| 117 |
Examples: !be32 $7fffffff, symbol, -$80000000, 14, $46a4f35 |
| 118 |
!be32 %1001011010010101001011010010, &4733630435, *, 'c' |
| 119 |
!be32 300000 - 4, a AND a2, 2 ^ tz, (3+4)*70, l1 & .j2 |
| 120 |
!be32 [2, 3, 5, 7], other_list ; iterate over items |
| 121 |
|
| 122 |
|
| 123 |
Call: !hex PAIRS_OF_HEX_DIGITS |
| 124 |
Purpose: Insert byte values with a minimum of additional |
| 125 |
syntax. This pseudo opcode was added for easier |
| 126 |
writing of external source code generator tools. |
| 127 |
Parameters: PAIRS_OF_HEX_DIGITS: Just hexadecimal digits, without |
| 128 |
any "0x" or "$" prefix. Spaces and TABs are allowed, |
| 129 |
but not needed to separate the byte values. |
| 130 |
Aliases: "!h" |
| 131 |
Examples: !h f0 f1 f2 f3 f4 f5 f6 f7 ; insert values 0xf0..0xf7 |
| 132 |
!h f0f1f2f3 f4f5f6f7 ; insert values 0xf0..0xf7 |
| 133 |
!h f0f1f2f3f4f5f6f7 ; insert values 0xf0..0xf7 |
| 134 |
!h f0f 1f2 ; ERROR: space inside pair! |
| 135 |
!h 0x00, $00 ; ERROR: "0x", "," and "$" are forbidden! |
| 136 |
!h SOME_SYMBOL ; ERROR: symbols are forbidden! |
| 137 |
!h ABCD ; insert value 0xAB, then 0xCD (CAUTION, big-endian) |
| 138 |
|
| 139 |
|
| 140 |
Call: !fill AMOUNT [, VALUE] |
| 141 |
Purpose: Fill amount of memory with value. |
| 142 |
Parameters: AMOUNT: Any formula the value parser accepts, but it |
| 143 |
must be solvable even in the first pass. |
| 144 |
VALUE: Any formula the value parser accepts. If |
| 145 |
omitted, a default value is used (currently zero). |
| 146 |
Aliases: "!fi" |
| 147 |
Examples: !fi 256, $ff ; reserve 256 bytes |
| 148 |
!fill 2 ; reserve two bytes |
| 149 |
|
| 150 |
|
| 151 |
Call: !skip AMOUNT |
| 152 |
Purpose: Advance in output buffer without starting a new |
| 153 |
segment. |
| 154 |
Parameters: AMOUNT: Any formula the value parser accepts, but it |
| 155 |
must be solvable even in the first pass (this |
| 156 |
limitation will hopefully be lifted in a future |
| 157 |
release). |
| 158 |
Aliases: None |
| 159 |
Examples: !skip BUFSIZE ; reserve some bytes |
| 160 |
!skip 5 ; reserve five bytes |
| 161 |
|
| 162 |
|
| 163 |
Call: !align ANDVALUE, EQUALVALUE [, FILLVALUE] |
| 164 |
Purpose: Fill memory until a matching address is reached. ACME |
| 165 |
outputs FILLVALUE until "program counter AND ANDVALUE" |
| 166 |
equals EQUALVALUE. |
| 167 |
Parameters: ANDVALUE: Any formula the value parser accepts, but it |
| 168 |
must be solvable even in the first pass. |
| 169 |
EQUALVALUE: Any formula the value parser accepts, but |
| 170 |
it must be solvable even in the first pass. |
| 171 |
FILLVALUE: Any formula the value parser accepts. If it |
| 172 |
is omitted, a default value is used (currently 234, |
| 173 |
that's the opcode of the 6502 CPU's NOP instruction). |
| 174 |
Examples: !align 255, 0 ; align to page (256 bytes) |
| 175 |
!align 63, 0 ; align to C64 sprite block (64 bytes) |
| 176 |
|
| 177 |
|
| 178 |
---------------------------------------------------------------------- |
| 179 |
Section: How to insert text strings |
| 180 |
---------------------------------------------------------------------- |
| 181 |
|
| 182 |
Call: !convtab KEYWORD [ { BLOCK } ] |
| 183 |
or: !convtab FILENAME [ { BLOCK } ] |
| 184 |
Purpose: Choose text conversion table. |
| 185 |
Parameters: KEYWORD: Name of conversion table. Valid names are: |
| 186 |
pet converts to PetSCII |
| 187 |
raw doesn't convert at all |
| 188 |
scr converts to C64 screencode |
| 189 |
FILENAME: File name of conversion table, given in |
| 190 |
"..." quoting (load from current directory) or in |
| 191 |
<...> quoting (load from library). The file must hold |
| 192 |
exactly 256 bytes. |
| 193 |
BLOCK: A block of assembler statements |
| 194 |
Before encountering this PO, ACME defaults to "raw". |
| 195 |
This PO supersedes the now deprecated "!cbm". |
| 196 |
Aliases: "!ct" |
| 197 |
Examples: !convtab raw |
| 198 |
!text "Test" ; outputs $54 $65 $73 $74 |
| 199 |
!ct pet |
| 200 |
!tx "Test" ; outputs $d4 $45 $53 $54 |
| 201 |
!ct scr { |
| 202 |
!tx "Test" ; outputs $54 $05 $13 $14 |
| 203 |
!ct "my_own_table_file" |
| 204 |
!tx "abcdefg" ; whatever... :) |
| 205 |
} |
| 206 |
!tx "Test" ; outputs $d4 $45 $53 $54 again |
| 207 |
Hint: If you don't want to fiddle with a hex editor to create a |
| 208 |
conversion table file, try using ACME: |
| 209 |
!to "asc2pet.ct", plain ; no load address |
| 210 |
* = 0 ; pc = table index |
| 211 |
; first create "as-is" table |
| 212 |
!for i, 0, 255 {!byte i} |
| 213 |
; now exchange upper and lower case characters |
| 214 |
* = 65, overlay |
| 215 |
!for i, 1, 26 {!byte * + 128} |
| 216 |
* = 97, overlay |
| 217 |
!for i, 1, 26 {!byte * - 32} |
| 218 |
The resulting file can be used as a conversion table to convert to |
| 219 |
PetSCII (which is useless, because ACME can do so anyway. But you get |
| 220 |
the idea). |
| 221 |
|
| 222 |
|
| 223 |
Call: !text STRING_VALUE [, STRING_VALUE]* |
| 224 |
Purpose: Output the given string(s) using the current |
| 225 |
conversion table. |
| 226 |
Parameters: STRING_VALUE: Can be either a string given in double |
| 227 |
quotes or any formula the value parser accepts. |
| 228 |
Please note that formula results won't be converted, |
| 229 |
but single characters involved in calculations will. |
| 230 |
Aliases: "!tx", "!txt" |
| 231 |
Examples: !text "Loading...", Char_NewLine, "Filename:", 0 |
| 232 |
!tx "Offset character is ", offset - 1 + 'a', 0 |
| 233 |
|
| 234 |
|
| 235 |
Call: !pet STRING_VALUE [, STRING_VALUE]* |
| 236 |
Purpose: Output the given string(s) using the PetSCII |
| 237 |
conversion table (This means to exchange the upper- |
| 238 |
and lowercase characters; useful for C64 programs). |
| 239 |
Parameters: STRING_VALUE: Can be either a string given in double |
| 240 |
quotes or any formula the value parser accepts. |
| 241 |
Please note that formula results won't be converted, |
| 242 |
but single characters involved in calculations will. |
| 243 |
Examples: !pet "Loading...", Char_NewLine, "Filename:", 0 |
| 244 |
!pet "Offset character is ", offset - 1 + 'a', 0 |
| 245 |
|
| 246 |
|
| 247 |
Call: !raw STRING_VALUE [, STRING_VALUE]* |
| 248 |
Purpose: Output the given string(s) without any conversion at |
| 249 |
all. |
| 250 |
Parameters: STRING_VALUE: Can be either a string given in double |
| 251 |
quotes or any formula the value parser accepts. |
| 252 |
Examples: !raw "Loading...", Char_NewLine, "Filename:", 0 |
| 253 |
!raw "Offset character is ", offset - 1 + 'a', 0 |
| 254 |
|
| 255 |
|
| 256 |
Call: !scr STRING_VALUE [, STRING_VALUE]* |
| 257 |
Purpose: Output the given string(s) using the C64 screen code |
| 258 |
conversion table (useful for C64 programs, as you will |
| 259 |
have guessed). |
| 260 |
Parameters: STRING_VALUE: Can be either a string given in double |
| 261 |
quotes or any formula the value parser accepts. |
| 262 |
Please note that formula results won't be converted, |
| 263 |
but single characters involved in calculations will. |
| 264 |
Examples: !scr "Loading...", Char_NewLine, "Filename:", 0 |
| 265 |
!scr "Offset character is ", offset - 1 + 'a', 0 |
| 266 |
|
| 267 |
|
| 268 |
Call: !scrxor XOR_VALUE, STRING_VALUE [, STRING_VALUE]* |
| 269 |
Purpose: Output the given string(s) using the C64 screen code |
| 270 |
conversion table and exclusive-OR-ing the results with |
| 271 |
the given value (useful for C64 programs when inverse |
| 272 |
video is needed, or EBC mode, etc.). |
| 273 |
Parameters: XOR_VALUE: Any formula the value parser accepts. |
| 274 |
STRING_VALUE: Can be either a string given in double |
| 275 |
quotes or any formula the value parser accepts. |
| 276 |
Please note that formula results will be neither |
| 277 |
converted nor exclusive-OR-d. |
| 278 |
Single characters involved in calculations will be |
| 279 |
converted, but not exclusive-OR-d. |
| 280 |
Examples: !scrxor $80, "Loading..." |
| 281 |
!scrxor $a0, "Offset char is ", (offset-1+'a') XOR $a0 |
| 282 |
|
| 283 |
|
| 284 |
---------------------------------------------------------------------- |
| 285 |
Section: File stuff |
| 286 |
---------------------------------------------------------------------- |
| 287 |
|
| 288 |
Call: !to FILENAME, FILEFORMAT |
| 289 |
Purpose: Define the output file name and file type. If this |
| 290 |
opcode isn't used, ACME still fully processes the |
| 291 |
source code - as the resulting binary isn't stored, |
| 292 |
this only serves to check for errors. Instead of using |
| 293 |
this pseudo opcode, you can also use the command line |
| 294 |
options "--outfile" and "--format". |
| 295 |
Parameters: FILENAME: A file name given in "..." quoting. |
| 296 |
FILEFORMAT: Name of file format. Valid names are: |
| 297 |
cbm with load address (Commodore format) |
| 298 |
plain without load address |
| 299 |
apple with load address and length (Apple II) |
| 300 |
If FILEFORMAT is omitted, ACME gives a warning and |
| 301 |
then defaults to "cbm" (this can be changed using the |
| 302 |
command line option "--format"). |
| 303 |
Examples: !to "eprom.p", plain ; don't add a load address |
| 304 |
!to "demo.o", cbm ; add c64-style load address |
| 305 |
|
| 306 |
|
| 307 |
Call: !source FILENAME |
| 308 |
Purpose: Assemble another source code file. After having |
| 309 |
processed the new file, ACME continues processing the |
| 310 |
old one. |
| 311 |
Parameters: FILENAME: A file name given in "..." quoting (load |
| 312 |
from current directory) or in <...> quoting (load from |
| 313 |
library). |
| 314 |
Aliases: "!src" |
| 315 |
Examples: !source <6502/std.a> ; Read library file |
| 316 |
!src "Macros.a" ; Read file from current dir |
| 317 |
|
| 318 |
|
| 319 |
Call: !binary FILENAME [, [SIZE] [, [SKIP]]] |
| 320 |
Purpose: Insert binary file directly into output file. |
| 321 |
Parameters: FILENAME: A file name given in "..." quoting (load |
| 322 |
from current directory) or in <...> quoting (load from |
| 323 |
library). |
| 324 |
SIZE: Any formula the value parser accepts, but it |
| 325 |
must be solvable even in the first pass. If SIZE is |
| 326 |
given, it is used: If the file is longer, only SIZE |
| 327 |
bytes are read; if it is shorter, ACME will use |
| 328 |
padding until SIZE is reached. If SIZE is omitted, |
| 329 |
ACME will include the file until EOF. |
| 330 |
SKIP: Any formula the value parser accepts. If SKIP is |
| 331 |
omitted, it defaults to zero. ACME will start loading |
| 332 |
the file from file offset SKIP. So C64 coders wanting |
| 333 |
to include C64 files without their load addresses |
| 334 |
should use a SKIP value of 2. |
| 335 |
Aliases: "!bin" |
| 336 |
Examples: !binary <Own/menudata.b> ; insert library file |
| 337 |
!bin "asc2pet.b", 256, 2 ; insert 256 bytes |
| 338 |
; from file offset 2. |
| 339 |
!bin "table", 2, 9 ; insert 2 bytes from offset 9 |
| 340 |
!bin "list",, 9 ; insert from offset 9 to EOF |
| 341 |
|
| 342 |
|
| 343 |
---------------------------------------------------------------------- |
| 344 |
Section: Symbols |
| 345 |
---------------------------------------------------------------------- |
| 346 |
|
| 347 |
Call: !zone [TITLE] [ { BLOCK } ] |
| 348 |
Purpose: Switch to new zone of local symbols. Zones can either |
| 349 |
be nested or used sequentially. |
| 350 |
Parameters: TITLE: May consist of letters and digits. Its only |
| 351 |
purpose is to be displayed in error messages, so it'll |
| 352 |
be omitted in most cases. |
| 353 |
BLOCK: A block of assembler statements |
| 354 |
If no block is given, the previous zone is terminated |
| 355 |
and the new zone is started. |
| 356 |
If a block is given, the old zone continues after the |
| 357 |
block. |
| 358 |
Aliases: "!zn" |
| 359 |
Examples: .backgroundcolor = 0 ; some local symbol |
| 360 |
!zone File_IO ; new zone begins here, so |
| 361 |
.backgroundcolor = 1 ; this is a different symbol |
| 362 |
!zn LinkedList_Init |
| 363 |
.backgroundcolor = 2 |
| 364 |
!zone LinkedList { ; start of nested zone |
| 365 |
; imagine some code here... |
| 366 |
!zone LinkedList_Init |
| 367 |
; imagine some more code here... |
| 368 |
!zone LinkedList_Body { |
| 369 |
; imagine yet some more code here... |
| 370 |
!zone LinkedList_SecondPart |
| 371 |
; imagine still some more code here... |
| 372 |
} |
| 373 |
!zone LinkedList_End |
| 374 |
; you know what to imagine here... |
| 375 |
} |
| 376 |
.backgroundcolor = 3 ; -> "Symbol already defined." |
| 377 |
|
| 378 |
|
| 379 |
Call: !symbollist FILENAME |
| 380 |
Purpose: Write a symbol list to the given file after assembly |
| 381 |
is finished. The list will contain all global symbols. |
| 382 |
This table could be loaded during another assembly |
| 383 |
session using the "!source" pseudo opcode. |
| 384 |
Parameters: FILENAME: A file name given in "..." quoting. |
| 385 |
Aliases: "!sl" |
| 386 |
Examples: !sl "Symbols.a" ; produce symbol list after assembly |
| 387 |
!sl "global" ; produce symbol list after assembly |
| 388 |
|
| 389 |
|
| 390 |
---------------------------------------------------------------------- |
| 391 |
Section: Flow control |
| 392 |
---------------------------------------------------------------------- |
| 393 |
|
| 394 |
Call: !if CONDITION { BLOCK } [ else { BLOCK } ] |
| 395 |
Purpose: Conditional assembly. If the given condition is true, |
| 396 |
the matching block of statements will be parsed; |
| 397 |
if no condition is true, the ELSE block (if present) |
| 398 |
will be parsed. |
| 399 |
Parameters: CONDITION: Any formula the value parser accepts, but |
| 400 |
it must be solvable even in the first pass. |
| 401 |
BLOCK: A block of assembler statements. |
| 402 |
Examples: ; Choose word according to "country" symbol: |
| 403 |
!if country == uk { |
| 404 |
!text "Grey" |
| 405 |
} else if country == fr { |
| 406 |
!text "Gris" |
| 407 |
} else if country == de { |
| 408 |
!text "Grau" |
| 409 |
} else { |
| 410 |
!text "Gray" |
| 411 |
} |
| 412 |
|
| 413 |
; Insert debug code depending on symbol "debug": |
| 414 |
!if debug { lda #'z':jsr char_output } |
| 415 |
|
| 416 |
|
| 417 |
Call: !ifdef SYMBOL { BLOCK } [ else { BLOCK } ] |
| 418 |
or: !ifdef SYMBOL STATEMENT |
| 419 |
Call: !ifndef SYMBOL { BLOCK } [ else { BLOCK } ] |
| 420 |
or: !ifndef SYMBOL STATEMENT |
| 421 |
Purpose: Conditional assembly, depending on whether a symbol is |
| 422 |
already defined or not. |
| 423 |
With "ifdef", if the symbol is defined, the first |
| 424 |
block of statements will be parsed; if it isn't, the |
| 425 |
second block will be parsed instead (if present). |
| 426 |
With "ifndef", it's the other way around: If the |
| 427 |
symbol isn't defined, the first block of statements |
| 428 |
will be parsed; if it is defined, the second block |
| 429 |
will be parsed instead (if present). |
| 430 |
CAUTION: These opcodes were added to speed up parsing |
| 431 |
of library files (see example below). They can be used |
| 432 |
to tell passes apart, therefore only use them in your |
| 433 |
own files if you're sure you *really* know what you |
| 434 |
are doing - using them in the wrong way will result in |
| 435 |
loads of error messages. |
| 436 |
Parameters: SYMBOL: Any valid symbol name. |
| 437 |
BLOCK: A block of assembler statements. |
| 438 |
STATEMENT: Any assembler statement. |
| 439 |
Examples: ; this was taken from <6502/std.a>: |
| 440 |
!ifdef Lib_6502_std_a !eof ; in later passes, |
| 441 |
Lib_6502_std_a = 1 ; skip this file. |
| 442 |
; During the first pass, the symbol is not defined, |
| 443 |
; therefore the file will get parsed. During all |
| 444 |
; further passes, the symbol is already defined, |
| 445 |
; therefore the file will be skipped. |
| 446 |
|
| 447 |
; if the following code gets included several times, |
| 448 |
; only assemble it at the first location: |
| 449 |
!ifndef my_label {my_label} ; only define if undefined |
| 450 |
!if * == my_label { |
| 451 |
; imagine some code here... |
| 452 |
; this block will only be assembled at the |
| 453 |
; first location where it is included. all |
| 454 |
; further instances will be skipped. |
| 455 |
} |
| 456 |
|
| 457 |
; include at most one driver source code: |
| 458 |
!ifdef RAM_REU { |
| 459 |
!src "driver_reu.a" |
| 460 |
} else ifdef RAM_GEORAM { |
| 461 |
!src "driver_georam.a" |
| 462 |
} else ifdef RAM_VDCRAM { |
| 463 |
!src "driver_vdcram.a" |
| 464 |
} else ifdef RAM_SUPERRAM { |
| 465 |
!src "driver_superram.a" |
| 466 |
} else { |
| 467 |
!src "driver_noram.a" |
| 468 |
} |
| 469 |
|
| 470 |
|
| 471 |
Call: !for SYMBOL, START, END { BLOCK } |
| 472 |
or: !for SYMBOL in ITERABLE { BLOCK } |
| 473 |
Purpose: Looping assembly. The block of statements will be |
| 474 |
parsed a fixed number of times, as specified by the |
| 475 |
arguments: |
| 476 |
When using the first syntax, SYMBOL will simply count |
| 477 |
from START to END. |
| 478 |
When using the second syntax, SYMBOL will iterate over |
| 479 |
the contents of the ITERABLE, which must be a string |
| 480 |
or a list. |
| 481 |
For more flexible loop constructs, have a look at |
| 482 |
"!do" and "!while" below. |
| 483 |
Parameters: SYMBOL: Any valid symbol name. |
| 484 |
START: Any formula the value parser accepts, but it |
| 485 |
must be solvable even in the first pass. SYMBOL will |
| 486 |
have this value during the first loop cycle. |
| 487 |
END: Any formula the value parser accepts, but it must |
| 488 |
be solvable even in the first pass. SYMBOL will have |
| 489 |
this value during the last loop cycle. |
| 490 |
ITERABLE: This must be a string or a list, but its |
| 491 |
length must be defined even in the first pass (and of |
| 492 |
course it should stay the same during all subsequent |
| 493 |
passes). |
| 494 |
If ITERABLE is a list, its _items_ are allowed |
| 495 |
to be undefined. |
| 496 |
If ITERABLE is a string, SYMBOL will be set to |
| 497 |
each of its character codes in turn, using the |
| 498 |
currently chosen conversion table. |
| 499 |
BLOCK: A block of assembler statements. |
| 500 |
If START or END are floats, they will be converted to |
| 501 |
integers (never use floats for loop counters). If |
| 502 |
START is less than or equal to END, SYMBOL will get |
| 503 |
incremented at the end of each cycle; if START is |
| 504 |
greater than END, SYMBOL will get decremented at the |
| 505 |
end of each cycle. So after leaving the loop, SYMBOL |
| 506 |
will have an "illegal" value (END + 1 if counting up, |
| 507 |
END - 1 if counting down). |
| 508 |
Please note that it is impossible to change the number |
| 509 |
of loop cycles "inside" the loop by fiddling with the |
| 510 |
counter using the "!set" pseudo opcode: The "!for" |
| 511 |
routine keeps its own copy of the counter value and |
| 512 |
only sets the symbol value, it never reads it back. |
| 513 |
This was done to eliminate a possibility to hang ACME. |
| 514 |
Examples: |
| 515 |
int2BCD ; conversion table: integer to BCD |
| 516 |
!for Outer, 0, 9 { |
| 517 |
!for Inner, 0, 9 { |
| 518 |
!byte (Outer << 4) OR Inner |
| 519 |
} |
| 520 |
} |
| 521 |
!fill 156, $ff ; values above 99 give 255 (invalid) |
| 522 |
|
| 523 |
BCD2int ; conversion table: BCD to integer |
| 524 |
!for Outer, 0, 9 { |
| 525 |
!for Inner, 0, 9 { |
| 526 |
!byte 10 * Outer + Inner |
| 527 |
} |
| 528 |
!fill 6, $ff ; invalid BCD values give 255 |
| 529 |
} |
| 530 |
!fill 96, $ff ; invalid BCD values give 255 |
| 531 |
|
| 532 |
quickclear ; generate speedcode to clear C64 screen |
| 533 |
lda #' ' |
| 534 |
!for i, 0, 999 { |
| 535 |
sta $0400 + i |
| 536 |
} |
| 537 |
|
| 538 |
split_table_lo ; generate two tables from one list |
| 539 |
!for h in my_handler_list { |
| 540 |
!by <h |
| 541 |
} |
| 542 |
split_table_hi |
| 543 |
!for h in my_handler_list { |
| 544 |
!by >h |
| 545 |
} |
| 546 |
|
| 547 |
hidden_string ; "encrypt" a string by XORing with address |
| 548 |
!ct scr { ; use screen codes |
| 549 |
!for c in "very secret message" { |
| 550 |
!by c XOR <* |
| 551 |
} |
| 552 |
} |
| 553 |
|
| 554 |
Miscellaneous: The old syntax |
| 555 |
!for SYMBOL, END { BLOCK } |
| 556 |
where START was always implied to be 1 is still fully |
| 557 |
supported, but gives a warning to get people to change |
| 558 |
to the new syntax. |
| 559 |
You can disable this warning using the "--dialect" or |
| 560 |
the "-Wno-old-for" switches, but then you will get |
| 561 |
warnings for using the *new* syntax. |
| 562 |
When migrating your sources to the current syntax, |
| 563 |
bear in mind that it is no longer possible to skip the |
| 564 |
block completely by specifying a loop count of zero. |
| 565 |
Also note that with the new algorithm, SYMBOL has a |
| 566 |
different value after the block than during the last |
| 567 |
loop cycle, while the old algorithm kept that last |
| 568 |
value. |
| 569 |
|
| 570 |
|
| 571 |
Call: !set SYMBOL = VALUE |
| 572 |
Purpose: Assign given value to symbol even if the symbol |
| 573 |
already has a different value. Needed for loop |
| 574 |
counters when using "!do"or "!while", for example. |
| 575 |
Only use this opcode for something else if you're sure |
| 576 |
you *really* know what you are doing... :) |
| 577 |
Parameters: SYMBOL: Any valid symbol name. |
| 578 |
VALUE: Any formula the value parser accepts. |
| 579 |
Example: see "!do" below |
| 580 |
|
| 581 |
|
| 582 |
Call: !do [KEYWORD CONDITION] { BLOCK } [KEYWORD CONDITION] |
| 583 |
Purpose: Looping assembly. The block of statements can be |
| 584 |
parsed several times, depending on the given |
| 585 |
condition(s). |
| 586 |
Conditions may be placed before or after the block (or |
| 587 |
even at both places), they are then parsed in every |
| 588 |
repetition before or after the block respectively. If |
| 589 |
there is a condition before the block and it isn't |
| 590 |
met when first checked, the block will be skipped. |
| 591 |
Parameters: KEYWORD: Either "until" or "while" (without quotes). |
| 592 |
CONDITION: Any formula the value parser accepts, but |
| 593 |
it must be solvable even in the first pass. |
| 594 |
BLOCK: A block of assembler statements. |
| 595 |
Examples: ; a loop with conditions at both start and end |
| 596 |
!set a = 0 ; init loop counter |
| 597 |
!do while loop_flag == TRUE { |
| 598 |
lda #a |
| 599 |
sta label + a |
| 600 |
!set a = a + 1 |
| 601 |
} until a > 6 |
| 602 |
|
| 603 |
; a loop with a condition at the start |
| 604 |
!do while * < $c000 { nop } |
| 605 |
|
| 606 |
; a loop with a condition at the end |
| 607 |
!do { !wo * + base } while * < base + 345 |
| 608 |
|
| 609 |
; a never ending loop - this will cause an error |
| 610 |
!do while 3 < 4 { nop } until 3 == 4 |
| 611 |
|
| 612 |
; an empty loop - this will hang ACME |
| 613 |
!do until 3 == 4 { } while 3 < 4 |
| 614 |
|
| 615 |
|
| 616 |
Call: !while [CONDITION] { BLOCK } |
| 617 |
Purpose: Looping assembly. The block of statements can be |
| 618 |
parsed several times, depending on the given |
| 619 |
condition. |
| 620 |
The condition is parsed in every repetition before the |
| 621 |
actual block. If it isn't met when first checked, the |
| 622 |
block will be skipped. |
| 623 |
Parameters: CONDITION: Any formula the value parser accepts, but |
| 624 |
it must be solvable even in the first pass. |
| 625 |
BLOCK: A block of assembler statements. |
| 626 |
Examples: ; a loop with a counter |
| 627 |
!set a = 0 ; init loop counter |
| 628 |
!while a < 6 { |
| 629 |
lda #a |
| 630 |
sta label + a |
| 631 |
!set a = a + 1 |
| 632 |
} |
| 633 |
|
| 634 |
; a loop depending on program counter |
| 635 |
!while * < $c000 { nop } |
| 636 |
|
| 637 |
; a never ending loop - this will cause an error |
| 638 |
!while 3 < 4 { nop } |
| 639 |
|
| 640 |
; an empty loop - this will hang ACME |
| 641 |
!while 3 != 4 { } |
| 642 |
|
| 643 |
|
| 644 |
Call: !endoffile |
| 645 |
Purpose: Stop processing the current source file. Using this |
| 646 |
pseudo opcode you can add explanatory text inside your |
| 647 |
source file without having to comment out every single |
| 648 |
line of it. |
| 649 |
Aliases: "!eof" |
| 650 |
Example: rts ; some assembler mnemonic |
| 651 |
!eof |
| 652 |
Though this text isn't preceded by a semicolon, it is |
| 653 |
treated as if it were a comment. In fact, ACME doesn't |
| 654 |
even parse this anymore - the file gets closed when |
| 655 |
"!eof" is reached. |
| 656 |
|
| 657 |
|
| 658 |
Call: !warn VALUE [, VALUE]* |
| 659 |
Purpose: Show a warning during assembly. |
| 660 |
Parameters: VALUE: Can be either a string given in double quotes |
| 661 |
or any formula the value parser accepts. |
| 662 |
Integer numbers will be output in both decimal _and_ |
| 663 |
hex formats. |
| 664 |
Example: !if * > $a000 { |
| 665 |
!warn "Program reached ROM: ", * - $a000, " bytes overlap." |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
Call: !error VALUE [, VALUE]* |
| 670 |
Purpose: Generate an error during assembly (therefore, no |
| 671 |
output file will be generated). |
| 672 |
Parameters: VALUE: Can be either a string given in double quotes |
| 673 |
or any formula the value parser accepts. |
| 674 |
Integer numbers will be output in both decimal _and_ |
| 675 |
hex formats. |
| 676 |
Example: rts ; end of some function |
| 677 |
start !source "colors.a" |
| 678 |
end !if end - start > 256 { |
| 679 |
!error "Color strings are ", end - start - 256, " bytes too long." |
| 680 |
} |
| 681 |
|
| 682 |
|
| 683 |
Call: !serious VALUE [, VALUE]* |
| 684 |
Purpose: Generate a serious error, immediately stopping |
| 685 |
assembly. |
| 686 |
Parameters: VALUE: Can be either a string given in double quotes |
| 687 |
or any formula the value parser accepts. |
| 688 |
Integer numbers will be output in both decimal _and_ |
| 689 |
hex formats. |
| 690 |
Example: !source "part1.a" ; sets part1_version |
| 691 |
!source "part2.a" ; sets part2_version |
| 692 |
!if part1_version != part2_version { |
| 693 |
!serious "part1.a and part2.a don't match!" |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
---------------------------------------------------------------------- |
| 698 |
Section: Macro usage |
| 699 |
---------------------------------------------------------------------- |
| 700 |
|
| 701 |
Call: !macro TITLE [[~]SYMBOL [, [~]SYMBOL]*] { BLOCK } |
| 702 |
Purpose: Define a macro. |
| 703 |
Parameters: TITLE: The macro's desired name (same rules as for |
| 704 |
symbol names). If the title's first character is a dot |
| 705 |
("."), the macro will be local (though why anyone |
| 706 |
could want this is beyond me). |
| 707 |
SYMBOL: The desired name for the parameter value at |
| 708 |
call time. Normally, these parameter symbols should be |
| 709 |
local (first character a '.' or a '@'), as different |
| 710 |
macro calls will almost for sure have different |
| 711 |
parameter values. |
| 712 |
If you prefix SYMBOL with a '~' character, it will be |
| 713 |
called by reference, not by value: Changing the value |
| 714 |
inside the macro will result in the "outer" symbol to |
| 715 |
be changed as well. |
| 716 |
BLOCK: A block of assembler statements. |
| 717 |
Examples: ; far branch, as defined in <6502/std.a> |
| 718 |
!macro bne .target { |
| 719 |
beq * + 5 |
| 720 |
jmp .target |
| 721 |
} |
| 722 |
|
| 723 |
; increase 16-bit counters |
| 724 |
!macro dinc .target { |
| 725 |
inc .target |
| 726 |
bne + ; "bne * + 5" would not work in zp |
| 727 |
inc .target + 1 |
| 728 |
+ |
| 729 |
} |
| 730 |
; Yes, anonymous label references can be used with |
| 731 |
; macros (unlike several other assemblers). That's |
| 732 |
; because ACME's macros are implemented more like |
| 733 |
; real functions. |
| 734 |
|
| 735 |
; load A and X |
| 736 |
!macro ldax .target { |
| 737 |
lda .target |
| 738 |
ldx .target + 1 |
| 739 |
} |
| 740 |
|
| 741 |
; store A and X |
| 742 |
!macro stax .target { |
| 743 |
sta .target |
| 744 |
stx .target + 1 |
| 745 |
} |
| 746 |
|
| 747 |
; use call-by-reference for return value |
| 748 |
!macro reserve ~.address, .amount { |
| 749 |
.address = external_pc |
| 750 |
!set external_pc = external_pc + .amount |
| 751 |
} |
| 752 |
|
| 753 |
; define a pixel row of a C64 hardware sprite |
| 754 |
!macro SpriteLine .v { |
| 755 |
!by .v >> 16, (.v >> 8) & 255, .v & 255 |
| 756 |
} |
| 757 |
|
| 758 |
|
| 759 |
Call: +TITLE [ARGUMENT [, ARGUMENT]*] |
| 760 |
Purpose: Call a macro, using the given parameter values. |
| 761 |
Parameters: TITLE: The macro's name as given in its definition. |
| 762 |
ARGUMENT: This is either any formula the value parser |
| 763 |
accepts, or (new in release 0.86) a '~' character |
| 764 |
followed by a symbol name. The '~'-prefix indicates |
| 765 |
call-by-reference semantics, which means that when the |
| 766 |
macro changes the symbol's value, the caller's |
| 767 |
symbol's value will change as well. |
| 768 |
Examples: inc label |
| 769 |
bne mark ; "near" branch |
| 770 |
inc label2 |
| 771 |
+bne mark2 ; "far" branch |
| 772 |
|
| 773 |
inc $fa ; increase 8-bit counter |
| 774 |
+dinc $fb ; increase 16-bit counter |
| 775 |
|
| 776 |
ldy label ; get byte |
| 777 |
+ldax label2 ; get two bytes |
| 778 |
|
| 779 |
; using macro calls in a macro definition |
| 780 |
!macro cp16 .source, .target { |
| 781 |
+ldax .source |
| 782 |
+stax .target |
| 783 |
} |
| 784 |
|
| 785 |
; use call-by-reference for return value |
| 786 |
!set external_pc = $0400 |
| 787 |
+reserve ~.line_buffer, 80 |
| 788 |
+reserve ~.in_buffer, 256 |
| 789 |
+reserve ~.out_buffer, 256 |
| 790 |
+reserve ~.byte_var, 1 |
| 791 |
|
| 792 |
; define a C64 hardware sprite |
| 793 |
; 765432107654321076543210 |
| 794 |
+SpriteLine %........................ |
| 795 |
+SpriteLine %.#...................... |
| 796 |
+SpriteLine %.##..................... |
| 797 |
+SpriteLine %.###.................... |
| 798 |
+SpriteLine %.####................... |
| 799 |
+SpriteLine %.#####.................. |
| 800 |
+SpriteLine %.######................. |
| 801 |
+SpriteLine %.#######................ |
| 802 |
+SpriteLine %.########............... |
| 803 |
+SpriteLine %.#########.............. |
| 804 |
+SpriteLine %.########............... |
| 805 |
+SpriteLine %.######................. |
| 806 |
+SpriteLine %.######................. |
| 807 |
+SpriteLine %.##..##................. |
| 808 |
+SpriteLine %.#....##................ |
| 809 |
+SpriteLine %......##................ |
| 810 |
+SpriteLine %.......##............... |
| 811 |
+SpriteLine %.......##............... |
| 812 |
+SpriteLine %........##.............. |
| 813 |
+SpriteLine %........##.............. |
| 814 |
+SpriteLine %........................ |
| 815 |
!byte 0 ; pad to 64-byte block |
| 816 |
|
| 817 |
Since release 0.86, different macros are allowed to have the same name |
| 818 |
as long as their parameter lists differ in size (number of arguments) |
| 819 |
or type (call-by-value vs. call-by-reference). So |
| 820 |
!macro process_bytes b1, b2 {...whatever...} |
| 821 |
!macro process_bytes b1, b2, b3 {...whatever...} |
| 822 |
!macro process_bytes b1, b2, ~b3 {...whatever...} |
| 823 |
can *all* be used at the same time without any name clash. |
| 824 |
|
| 825 |
Since release 0.97, lists are supported. This is useful for macros if |
| 826 |
you want an arbitrary number of arguments: Just pass a list or string |
| 827 |
as one of the arguments and have the macro iterate over its contents. |
| 828 |
Examples: ; a macro to store any number of arguments as 16-bit values: |
| 829 |
!macro iter_example @iterable { |
| 830 |
!for @item in @iterable { |
| 831 |
!16 @item |
| 832 |
} |
| 833 |
} |
| 834 |
+iter_example [2, 3, 5, 7] ; iterate over list items |
| 835 |
+iter_example "string" ; iterate over characters |
| 836 |
|
| 837 |
; a macro to "encrypt" each argument with its index: |
| 838 |
!macro scramble @iterable { |
| 839 |
@length = len(@iterable) |
| 840 |
!for @index, 0, @length - 1 { |
| 841 |
!byte @iterable[@index] xor @index |
| 842 |
} |
| 843 |
} |
| 844 |
+scramble [2, 3, 5, 7] ; iterate over list items |
| 845 |
+scramble "string" ; iterate over characters |
| 846 |
|
| 847 |
|
| 848 |
---------------------------------------------------------------------- |
| 849 |
Section: Segment assembly |
| 850 |
---------------------------------------------------------------------- |
| 851 |
|
| 852 |
Call: * = EXPRESSION [, MODIFIER]* |
| 853 |
Purpose: Set program counter to given value and start new |
| 854 |
segment. This opcode must be given at least once |
| 855 |
(or the command line option "--setpc" must be used). |
| 856 |
If segments overlap each other, warnings will be |
| 857 |
issued. Because some people do this overlapping |
| 858 |
on purpose, the warnings can be suppressed using |
| 859 |
modifier keywords. |
| 860 |
Using the "--strict-segments" CLI switch, these |
| 861 |
warnings can be turned onto errors. Future versions of |
| 862 |
ACME may do that by default - so if needed, use the |
| 863 |
modifier keywords. |
| 864 |
Parameters: EXPRESSION: Any formula the value parser accepts, but |
| 865 |
it must be solvable even in the first pass. |
| 866 |
MODIFIER: "overlay" or "invisible" (without quotes): |
| 867 |
"overlay" suppresses the warning "Segment starts |
| 868 |
inside another one, overwriting it". |
| 869 |
"invisible" makes the new segment invisible, so that |
| 870 |
_other_ segments will never raise the warning "Segment |
| 871 |
reached another one, overwriting it". |
| 872 |
Examples: !to "TinyDemo", cbm ; define output file + format |
| 873 |
* = $0801 ; start at C64 BASIC start |
| 874 |
!src "basicmacros.a" ; include macro definitions |
| 875 |
+basic_header ; call program header macro |
| 876 |
!src "main.a" ; include main program |
| 877 |
* = $1000 ; jump to new segment |
| 878 |
!bin "music.b" ; load music to $1000 |
| 879 |
* = $8000 ; jump to new segment |
| 880 |
!bin "pic.b" ; load graphics to $8000 |
| 881 |
* = $8010, overlay, invisible ; go back and patch |
| 882 |
; the graphics, suppressing warnings |
| 883 |
; After assembly, ACME will save everything from $0801 |
| 884 |
; up to the highest address written to. The resulting |
| 885 |
; file will contain some big unused areas (zero'd), |
| 886 |
; but demos will get compressed anyway... :) |
| 887 |
|
| 888 |
|
| 889 |
Call: !initmem EXPRESSION |
| 890 |
Purpose: Define "unchanged" memory. ACME will fill its output |
| 891 |
buffer completely with the given value before storing |
| 892 |
the assembled code. So gaps between segments will |
| 893 |
contain the desired byte when writing the output file. |
| 894 |
Instead of using this pseudo opcode, you can also use |
| 895 |
the "--initmem" command line option. If neither is |
| 896 |
used, the buffer is cleared. |
| 897 |
Parameters: EXPRESSION: Any formula the value parser accepts, but |
| 898 |
it must be solvable even in the first pass (because |
| 899 |
this opcode will be ignored in all later passes). |
| 900 |
Examples: !to "TinyDemo", cbm ; define output file + format |
| 901 |
!initmem $ea ; default memory content $ea. |
| 902 |
* = $0801 ; start at C64 BASIC start |
| 903 |
!src "basicmacros.a" ; include macro definitions |
| 904 |
+basic_header ; call program header macro |
| 905 |
!src "main.a" ; include main program |
| 906 |
* = $1000 ; jump to new segment |
| 907 |
!bin "music.b" ; load music to $1000 |
| 908 |
* = $8000 ; jump to new segment |
| 909 |
!bin "pic.b" ; load graphics to $8000 |
| 910 |
* = $8010, overlay, invisible ; go back and patch |
| 911 |
; the graphics, suppressing warnings |
| 912 |
; This is the same example as before, but now the big |
| 913 |
; unused areas will contain the value $ea instead of |
| 914 |
; zero. |
| 915 |
|
| 916 |
!initmem $ff ; Default memory content is now $ff. |
| 917 |
; Useful if you want to store your code in an EPROM. |
| 918 |
|
| 919 |
|
| 920 |
Call: !xor EXPRESSION [ { BLOCK } ] |
| 921 |
Purpose: Change the value to XOR all output bytes with (the |
| 922 |
value defaults to zero on startup). This "encryption" |
| 923 |
facility was added to compensate for the shortcomings |
| 924 |
of the "!scrxor" pseudo opcode, which only XORs |
| 925 |
strings and characters, but not numbers. |
| 926 |
When used with block syntax, the previously chosen |
| 927 |
value is restored afterwards. |
| 928 |
Parameters: EXPRESSION: Any formula the value parser accepts. |
| 929 |
BLOCK: A block of assembler statements. |
| 930 |
Examples: ; first as normal screencodes: |
| 931 |
!scr "Hello everybody...", GROUPLOGOCHAR |
| 932 |
; and now as inverted screencodes: |
| 933 |
!xor $80 { |
| 934 |
!scr "Hello everybody...", GROUPLOGOCHAR |
| 935 |
} |
| 936 |
|
| 937 |
|
| 938 |
---------------------------------------------------------------------- |
| 939 |
Section: Offset assembly |
| 940 |
---------------------------------------------------------------------- |
| 941 |
|
| 942 |
Call: !pseudopc EXPRESSION { BLOCK } |
| 943 |
Purpose: Assemble code as if the program counter had the given |
| 944 |
value, effectively producing a program that has to be |
| 945 |
copied to a different address space before being run. |
| 946 |
After having processed the block of statements with |
| 947 |
the new program counter, the updated (!) old program |
| 948 |
counter is used again. |
| 949 |
Thanks to the block syntax, offset assembly can now be |
| 950 |
nested. Then the old program counter would not |
| 951 |
necessarily be the *real* program counter, but could |
| 952 |
be a pseudopc as well. ;) |
| 953 |
Parameters: EXPRESSION: Any formula the value parser accepts, but |
| 954 |
it must be solvable even in the first pass. |
| 955 |
BLOCK: A block of assembler statements. |
| 956 |
Examples: ldx #.shifted_end - .shifted_start |
| 957 |
- lda .shifted_start - 1, x |
| 958 |
sta .target - 1, x |
| 959 |
dex |
| 960 |
bne - |
| 961 |
jmp .target |
| 962 |
.shifted_start |
| 963 |
!pseudopc $0400 { |
| 964 |
.target ; imagine some code here... |
| 965 |
; it should be copied to $0400 and executed *there* |
| 966 |
} |
| 967 |
.shifted_end |
| 968 |
|
| 969 |
Miscellaneous: If you need to convert a label or the program counter |
| 970 |
from its "pseudopc" to its "real" value, you can do |
| 971 |
that using the "&" operator. Given the example above, |
| 972 |
the symbol ".target" will evaluate to the value $0400, |
| 973 |
but "&.target" will evaluate to the same value as |
| 974 |
".shifted_start" will. |
| 975 |
|
| 976 |
|
| 977 |
---------------------------------------------------------------------- |
| 978 |
Section: CPU support pseudo opcodes (especially 65816 support) |
| 979 |
---------------------------------------------------------------------- |
| 980 |
|
| 981 |
Call: !cpu KEYWORD [ { BLOCK } ] |
| 982 |
Purpose: Select the processor to produce code for. If this PO |
| 983 |
isn't used, ACME defaults to the 6502 CPU (or to the |
| 984 |
one selected by the "--cpu" command line option). |
| 985 |
ACME will give errors if you try to assemble |
| 986 |
instructions the chosen CPU does not support. You can |
| 987 |
change the chosen CPU at any time. When used with |
| 988 |
block syntax, the previously chosen CPU value is |
| 989 |
restored afterwards. |
| 990 |
Parameters: KEYWORD: Currently valid keywords are: |
| 991 |
6502 for the original MOS 6502 |
| 992 |
nmos6502 6502 plus undocumented opcodes |
| 993 |
6510 (alias for "nmos6502") |
| 994 |
65c02 6502 plus BRA,PHX/Y,PLX/Y,STZ,TRB/TSB |
| 995 |
r65c02 65c02 plus BBRx, BBSx, RMBx, SMBx |
| 996 |
w65c02 r65c02 plus STP/WAI |
| 997 |
65816 65c02 plus 16/24-bit extensions |
| 998 |
65ce02 r65c02 plus Z reg, long branches, ... |
| 999 |
4502 65ce02 with MAP instead of AUG |
| 1000 |
m65 4502 plus 32-bit extensions |
| 1001 |
c64dtv2 6502 plus BRA/SAC/SIR plus some of the |
| 1002 |
undocumented opcodes |
| 1003 |
See "docs/cputypes/all.txt" for more info. |
| 1004 |
BLOCK: A block of assembler statements. |
| 1005 |
Examples: !if cputype == $65c02 { |
| 1006 |
!cpu 65c02 { ; temporarily allow 65c02 stuff |
| 1007 |
stz .todelete |
| 1008 |
} |
| 1009 |
} else { |
| 1010 |
pha |
| 1011 |
lda #0 |
| 1012 |
sta .todelete |
| 1013 |
pla |
| 1014 |
} |
| 1015 |
rts |
| 1016 |
!cpu 65816 ; now allow instructions of 65816 cpu |
| 1017 |
|
| 1018 |
|
| 1019 |
Call: !al [ { BLOCK } ] |
| 1020 |
Purpose: Assume long (16 bits) accumulator. Only allowed when |
| 1021 |
producing code for the 65816 CPU. When used with block |
| 1022 |
syntax, the previous configuration is restored |
| 1023 |
afterwards. |
| 1024 |
|
| 1025 |
|
| 1026 |
Call: !as [ { BLOCK } ] |
| 1027 |
Purpose: Assume short (8 bits) accumulator. Only needed when |
| 1028 |
producing code for the 65816 CPU. When used with block |
| 1029 |
syntax, the previous configuration is restored |
| 1030 |
afterwards. Short accumulator is the default in every |
| 1031 |
pass. |
| 1032 |
|
| 1033 |
|
| 1034 |
Call: !rl [ { BLOCK } ] |
| 1035 |
Purpose: Assume long (16 bits) index registers. Only allowed |
| 1036 |
when producing code for the 65816 CPU. When used with |
| 1037 |
block syntax, the previous configuration is restored |
| 1038 |
afterwards. |
| 1039 |
|
| 1040 |
|
| 1041 |
Call: !rs [ { BLOCK } ] |
| 1042 |
Purpose: Assume short (8 bits) index registers. Only needed |
| 1043 |
when producing code for the 65816 CPU. When used with |
| 1044 |
block syntax, the previous configuration is restored |
| 1045 |
afterwards. Short registers are the default in every |
| 1046 |
pass. |
| 1047 |
|
| 1048 |
|
| 1049 |
---------------------------------------------------------------------- |
| 1050 |
Section: Type system |
| 1051 |
---------------------------------------------------------------------- |
| 1052 |
|
| 1053 |
Call: !address [ { BLOCK } ] |
| 1054 |
or: !address SYMBOL = VALUE |
| 1055 |
Purpose: Mark a block or a statement as "explicitly defined |
| 1056 |
symbols are holding addresses". |
| 1057 |
Parameters: BLOCK: A block of assembler statements |
| 1058 |
Everything inside the block will be parsed as usual, |
| 1059 |
but explicitly defined symbols will be marked as |
| 1060 |
referencing memory. |
| 1061 |
If no block is given, only the current statement will |
| 1062 |
be affected, which should then be an explicit symbol |
| 1063 |
definition. |
| 1064 |
To make use of this feature, you need to use the |
| 1065 |
"-Wtype-mismatch" CLI switch. |
| 1066 |
Aliases: "!addr" |
| 1067 |
Examples: !addr k_chrout = $ffd2 ; this is an address |
| 1068 |
CLEAR = 147 ; but this is not |
| 1069 |
!addr { |
| 1070 |
; these are addresses: |
| 1071 |
sid_v1_control = $d404 |
| 1072 |
sid_v2_control = $d40b |
| 1073 |
sid_v3_control = $d412 |
| 1074 |
} |
| 1075 |
; these are not: |
| 1076 |
sid_VOICECONTROL_NOISE = %#....... |
| 1077 |
sid_VOICECONTROL_RECTANGLE = %.#...... |
| 1078 |
sid_VOICECONTROL_SAWTOOTH = %..#..... |
| 1079 |
sid_VOICECONTROL_TRIANGLE = %...#.... |
| 1080 |
|
| 1081 |
|
| 1082 |
---------------------------------------------------------------------- |
| 1083 |
Section: Obsolete pseudo opcodes (they will throw errors if used) |
| 1084 |
---------------------------------------------------------------------- |
| 1085 |
|
| 1086 |
Call: !cbm |
| 1087 |
Purpose: Use PetSCII as the text conversion table. Now |
| 1088 |
superseded by the "!convtab" pseudo opcode. |
| 1089 |
Old usage: !cbm ; gives "use !ct pet instead" error |
| 1090 |
Now use: !convtab pet ; does the same without error |
| 1091 |
If you just want to assemble an old source code |
| 1092 |
without touching it, use the "--dialect" CLI switch: |
| 1093 |
Using "--dialect 0.94.6" or earlier will assemble this |
| 1094 |
pseudo opcode without throwing an error. |
| 1095 |
|
| 1096 |
|
| 1097 |
Call: !subzone [TITLE] { BLOCK } |
| 1098 |
Purpose: Allows nesting of zones. Now superseded by "!zone" |
| 1099 |
because that allows nesting as well. |
| 1100 |
Parameters: TITLE: May consist of letters and digits. |
| 1101 |
BLOCK: A block of assembler statements. |
| 1102 |
Aliases: "!sz" |
| 1103 |
Old usage: !subzone graphics { |
| 1104 |
!source "graphics.a" |
| 1105 |
} |
| 1106 |
Now use: !zone graphics { |
| 1107 |
!source "graphics.a" |
| 1108 |
} |
| 1109 |
If you just want to assemble an old source code |
| 1110 |
without touching it, use the "--dialect" CLI switch: |
| 1111 |
Using "--dialect 0.94.6" or earlier will assemble this |
| 1112 |
pseudo opcode without throwing an error. |
| 1113 |
|
| 1114 |
|
| 1115 |
Call: !realpc |
| 1116 |
Purpose: Restore the program counter to its real value, |
| 1117 |
therefore finishing offset assembly. Because |
| 1118 |
"!pseudopc" now knows block syntax and can be nested, |
| 1119 |
there's no reason to use "!realpc" any more. |
| 1120 |
Old usage: !pseudopc $0400 |
| 1121 |
; imagine some code here... |
| 1122 |
!realpc |
| 1123 |
Now use: !pseudopc $0400 { |
| 1124 |
; imagine some code here... |
| 1125 |
} |
| 1126 |
If you just want to assemble an old source code |
| 1127 |
without touching it, use the "--dialect" CLI switch: |
| 1128 |
Using "--dialect 0.94.6" or earlier will assemble this |
| 1129 |
pseudo opcode without throwing an error. |
| 1130 |
Using "--dialect 0.85", not even a warning is thrown. |