1 unsorted notes on UrAsm commands and quirks
6 EQU defines unique label (which cannot be redefined)
8 '=' assigns value to label (creating new label if necessary, or
9 redefining the existing one)
14 if label starts with '@@', it doesn't reset local labels.
16 if label starts with '.', it is a local label; all local
17 labels will be forgotten after new global label.
20 displaying expressions while assembling
21 =======================================
24 pring args on the second pass; can print strings and perform math
26 pring args on the first pass; can print strings and perform math
28 pring args on each pass; can print strings and perform math
32 the same as "DISPLAY*", but prins all numbers as hex values
38 SNA -- .sna, no autorun
39 RUNSNA -- .sna, with autorun
40 TAP, TAPE -- .tap, no autorun
41 RUNTAP, RUNTAPE -- .tap, with autorun (i.e. with BASIC loader)
42 BIN, RAW -- just a raw binary (or several binaries, one for each ORG)
43 DMB, RUNDMB -- DMB, DMB with autorun
44 NONE, NOTHING -- no output file
46 for tapes with autorun you can use "CLR" command to define BASIC "CLEAR".
51 MACRO downxx regpair, asret=0, asjp=0
90 "..label:" is label local to macro.
92 to use `regpair` as full register name: `inc =regpair[]`.
94 default arg can be empty, like `MACRO xxx arg=`. to test it, use:
95 IF marg2str(=arg) != ""
103 set current logical and physical destination address
113 physical code location is not changed, but logical code location set to "addr"
120 cannot be used in DISP
128 ALIGN, but for "DISP" blocks.
134 sets code entry point (for formats with autostart).
140 sets CLEAR addess for BASIC tap loader.
144 RESERVE address space
145 ===========================================
147 will automaticaly skip the given area (and insert all necessary
148 jumps) if assembled code will overlap.
150 WARNING! this is not properly tested, and it will happily try
151 to insert jumps even in def* data!
158 includes source file. for simple quotes, searching starts from the
159 directory with the file we are processing right now (same as in C).
160 angle brackets means "search in system library dir".
161 if file name starts with "?", this is "soft include". if file could
162 not be found, the include will be silently ignored. you can separate
163 "?" from the file name with spaces.
168 INCBIN name [,maxlen]
169 include binary file "as-is", possibly with max length limit.
176 all non-local labels between those will be "exported" to the other
177 code as "mname.labelname".
182 DUP cnt [,itervarname [,initval [,increment]]]
185 duplicates given code fragment "cnt" times. nested DUPs are allowed.
186 if `itervarname` is specified, it will contain iteration counter.
187 note that this var is local for DUP block, and will be destroyed
188 when DUP complete (i.e. it won't go to ref, and can shadow other
191 you can specily initial value (default is 0), and increment
192 (default is 1) for iteration variable.
194 you can use REPT/ENDR as synonyms.
197 conditional compilation
198 =======================
205 for "IF", all labels in "condexpr" must be defined.
206 for "IFX", any undefined label in "condexpr" turns it to 0 (false).
212 will add "val" to all data defined via:
214 and to *NUMBERS* (NOT strings) in DM, DZ, DX É DC
215 it is possible to use complex expression to modify the data, by using string.
216 all operations are done on the properly sized value.
220 sar, <count> -- arith shift, extend bit 7
221 sal, <count> -- arith shift, extend bit 0
230 DEFINCR "expr", "shl",3, "xor",0x80, "or",1
241 define 16-bit little-endian words
243 DEFine Reversed Words
244 =====================
246 define 16-bit big-endian words
249 DEFine repeated values
250 ======================
253 define repeated values
262 DEFine asciiZ strings
263 =====================
265 define string data, automatically adding zero byte after each one
268 DEFine high-bit-terminated string
269 =================================
271 define string data, automatically set highest bit on the last char of each one
274 DEFine byte-Counted strings
275 ===========================
277 define string data, automatically insert byte length before each one
280 known functions in math expressions
281 ===================================
282 defined(xxx) -- is label "xxx" value defined?
283 known(xxx) -- is label "xxx" seen? (its value may be still undefined)
284 aligned256(xxx) -- xxx%256 == 0
285 align(xxx[, what]) -- align xxx by what, default what == 256
286 sameseg(x0, x1) -- x0/256 == x1/256
287 low(xxx) -- low byte of xxx
288 high(xxx) -- high byte of xxx
289 abs(xxx) -- absolute value of xxx
290 bswap(xxx) -- swap bytes in 16-bit word
292 scraddr8x8(x, y, base=#4000) -- calculate screen address; coords are in chars
293 scraddr8x1(x, y, base=#4000) -- calculate screen address; x coord is char, y coord is pixel
294 scrattr8x8(x, y, base=#4000) -- calculate attribute address; coords are in chars
296 marg2str(argname) -- get macro argument name as string value; always lowercased
297 this is to use macro arguments in comparisons, like this:
298 IF marg2str(=regpair) == "hl"
301 note the '=' prefix. result of `marg2str()` will be lowercased.
303 strlen(str) -- string length
306 you can use "[]" instead of "()" in math expressions.
311 start numeric literal with "0" to get octal.
312 you can end hex number with "h" instead of using prefix (but this is not recommended).
314 allowed number prefixes for hex numbers:
320 allowed number prefixes for bin numbers:
325 allowed number prefixes for octal numbers:
330 allowed number prefixes for decimal numbers:
336 two-char string literals as numbers
337 ===================================
338 two-char string literals (in single or double quotes) can be used
339 as numeric literals. the difference is:
341 "ab" -- 'a' will be in low (first) byte
342 'ab' -- 'a' will be in high (second) byte
347 you can use either "AF'" or "AFX" form for this.
352 you can separate multiple commands with colons:
357 math priorities (WARNING! NOT C!)
358 =================================
380 = (equality test, the same as '==')
383 <> (inequality test, the same as '!=')
392 logical '&&' É '||' are short-circuited.
399 new is more C-like, and the current default.
400 directive is here for compatibility with the old code.
407 allow hex numbers like "&abc"? note that turning this on
408 will turn off "&b" binary prefix.
413 $REFOPT <default|alllabels|noupcase>
415 what to output to label reference file? default is "alllabels".
416 "noupcase" means "omit all-uppercase labels".
423 $PRINTF "fmt" [,args...]
425 very simple printf. automatically advances the line.
426 "printf" works only on the second pass.
427 "printf0" works only on the first pass.
428 "printfa" works on all passes.
433 $ERROR "fmt" [,args...]
435 prints "user error" message, and aborts compilation.
440 $WARNING "fmt" [,args...]
442 prints "user warning" message, but doesn't abort compilation.
445 adding external data files to the resulting image
446 =================================================
447 DATABIN "name"[,len[,offset[,codeaddr]]]
448 DATABIN "name|dfname"[,len[,offset[,codeaddr]]]
450 load external file with the given name, and write it to the
451 resulting image (tap, scl, etc.). loader will NOT automatically
452 load it. to autoload it, use CODEBIN.
454 WARNING! all such blocks will be appended (and loaded) *AFTER*
455 the normal memory blocks.
458 writing part of the code
459 ========================
460 $SAVECODE "filename",addr,size [,ldaddr [,options...]]
463 wipe -- wipe saved area (mark it as unused)
464 data -- save as data (do not autoload it)
466 this can be used to assemble and write code for additional 128K
469 WARNING! all used code labels must be known, because the code will
470 be copied "as is", and unknown labels won't be patched!
472 WARNING! all such blocks will be appended (and loaded) *AFTER*
473 the normal memory blocks.
478 STRUCT <flags> structname [,init_ofs]
481 STRUCT <flags> extend structname [,init_ofs]
484 STRUCT <flags> structname extend parentstructname [,init_ofs]
488 you can extend existing struct with new fields using the second form.
489 this will not create a new struct, but simply append fields to the existing
490 one (and fix `._sizeof`).
492 the third form is used to "subclass" existing structure. i.e. to create a
493 new structure with a new name, and with all fields from the parent, followed
496 optional `init_ofs` can be used to set initial offset of the declared fields.
497 for extensions, it sets the initial offset of the first extension field.
506 address (2 bytes, same as "word")
511 for non-label and non-ds fields it is possible to specify an initial value.
514 each struct will automatically get "structname._sizeof" label.
516 <flags> is a comma-separated list of flags in square brackets. optional.
517 currently defined flags:
518 `zero_fill`: fill uinitialised struct fields with zeroes.
521 create anonymous struct
525 label: structname [init]
527 for named structs, labels with fields addresses will be automatically
528 created. i.e. "boo: goo" will create labels "boo.fldname", etc.
530 struct initialisation consists of "name = value" pairs, delimited by
531 commas. all pairs must be on the same line. to create multiline inits,
535 field0 = 0x29a, field1 = 666
539 opening bracket must be last at the line, and closing bracket must be
540 the only non-blank char in the line.
543 existing structure can be extended:
550 this will add two new fields to the *EXISTING* struct named `mobj`.
551 "_sizeof" label will be adjusted.
554 existing structure can be "subclassed":
559 this will create a new struct "mobjex", with all fields from "mobj", and