To avoid assembling a program, then compressing it and then re-importing it, RASM is able to assemble and compress on the fly, then relocate the labels prior to the compressed sections as needed. Rasm can open an unlimited number of compressed segments and mix crunchers. You can exceed the 64K limit by as much as you like, as long as the final result comes back under 64K (or 16K for a ROM/Cartridge export).
It is not possible to nest compressed segments
LZEXO ; open a crunched section with Exomizer 2.0
LZX7 ; crunched with ZX7
LZX0 ; crunched with ZX0
LZX0B ; crunched with ZX0 backward
LZAPU ; crunched with AP-Ultra
LZSA1 ; crunched with LZSA1
LZSA2 ; crunched with LZSA2
LZ4 ; crunched with LZ4
LZ48 ; crunched with LZ48
LZ49 ; crunched with LZ49
LZCLOSE
Closes a compressed portion, this directive is to be used with any of the compression tags
Example
jr later ; the relative jump can be done after compression in less than 128 bytes of the compressed portion
lzx0
defs 256,0
lzclose
later
ret
; concat some binary files, then crunch them all in a single file with ZX0, and save this file
bank
lzx0
incbin 'firstdata.bin'
incbin 'seconddata.bin'
incbin 'thirddata.bin'
lzclose
save 'concat.bin',0,$
Advanced example
Creation of specifics modules which own the same execution address. We want them all to be crunched in a row then the main engine can decrunch them before execution
script_addr=#1000 ; script execution address
bank
org #C000
script_list
defw script01
defw script02
script01
org script_addr,$
lzx0
defs 256 ; script code
ret
lzclose
org $
script02
org script_addr,$
lzx0
defs 256 ; script code
ret
lzclose
org $
level03
jp $ ; the $ wont be relocated, it uses the address BEFORE crunch
jp script03 ; labels are relocated, this will be the address AFTER crunch
; same effect for print and delayed_print, the $ is still computed at first sight
print '$=',$,'script03=',script03 ; before
delayed_print '$=',$,'script03=',script03 ; after
Here is an example of how to deploy you crunched scripts in the main engine:
; C=script to deploy
ld hl,script_list
ld b,0
add hl,bc : add hl,bc
ld a,(hl) : inc hl : ld h,(hl) : ld l,a ; get crunched script addr in HL
ld de,script_addr
jp unzx0 ; unpack it to DE