shifters74 wrote: ↑Fri Jul 01, 2022 11:59 am
HI SteveF,
sorry more questions!
Hi shifters, no problem! I'm glad you're persevering with this!
shifters74 wrote: ↑Fri Jul 01, 2022 11:59 am
Is it possible to do conditional compilation i.e. only have certain code in debug build etc?
There's no "standard" support for this in PLASMA itself. What I've done in my code is abuse the C preprocessor, which in practice works fairly well but obviously could go wrong as it's not designed for PLASMA. You can see some examples of this in the makefile, such as:
Code: Select all
cc -DJIT -E -P - < vmsrc/acorn/cmd.pla > vmsrc/acorn/32cmdjit.pla
./$(PLASM) -AOW < vmsrc/acorn/32cmdjit.pla > vmsrc/acorn/32cmdjit.a
The first line transforms cmd.pla into 32cmdjit.pla with "JIT" defined, and the second line then compiles the resulting PLASMA code.
It's probably best to stick to using the C preprocessor for #define/#if/etc; if you start trying to use #include the C preprocessor will probably start emitting #line directives which will trip up the PLASMA compiler.
If you are doing very small "within function" tweaks for conditional compilation, you *may* be able to rely on the optimiser to eliminate dead code of the form:
Code: Select all
const debug_output = FALSE
if debug_output
puts("debug output here!\n")
fin
but I haven't tested this - if you want to use this approach, please double-check the bytecode output to see if the code is indeed being removed. It's probably better to just use the C preprocessor.
At the risk of stating the obvious you are also free to create your own ad-hoc preprocessor in whatever language you want, e.g. something clunky but customised to your personal requirements could probably be written in a few lines of Python. I would still personally recommend the C preprocessor unless there's some specific problem with doing that.
shifters74 wrote: ↑Fri Jul 01, 2022 11:59 am
When running PLAS128 on a Master with a 6502 co-pro, it returns
Does this mean that on the co-pro there is $DFC9 free memory for user data and $FFF6 is free memory for byte code in the Master SW rams?
You are interpreting the values correctly, but those specific values look wrong to me.
On PLAS128, "MEM FREE" is the main RAM free for assembly language code and user data (local variables, the heap), and "AUX FREE" is free memory for bytecode functions in sideways RAM, as you say.
However, PLAS128 isn't really second processor compatible. I increasingly think I need to change this, but in order to avoid just saying "sorry, turn off your second processor" when you run it, PLAS128 disables the second processor itself and carries on running on the host, which gives a misleading impression that it is taking advantage of the second processor.
It therefore doesn't seem right you are seeing such a high MEM FREE value. When I try this on b-em, a Master with a 6502 co-pro says:
There can't be $DFC9 bytes of (ordinary) "MEM FREE" when the second processor is disabled as the "MEM FREE" is a subset of the 32K of main RAM. If you just made those numbers up for the question that's fine, but if you're really seeing this can you please let me have a copy of the .ssd containing the PLAS128 which is saying this so I can investigate! (It would be good if you could confirm the branch/commit you built it from too, please.)
Changing the subject slightly to offer some unsolicited advice
, it's probably quite hard to write a program which will seriously benefit from ~64K of bytecode space. Your plans to use sideways RAM as cache are probably better, and it may be worth taking steps of some kind to stop PLAS128 grabbing the maximum 64K of RAM for itself. One thing you could possibly do to take advantage of all this bytecode space is to store data in the form of constant strings, e.g. (contrived, not tested):
Code: Select all
def roomhandler(description)#0:
puts(description)
// do lots of cool stuff here
end
def room1desc()#0:
roomhandler("This is a very verbose description of room 1, which will be stored in sideways RAM as bytecode and temporarily copied into main RAM while this function is executing.")
end
def room2desc()#0:
roomhandler("Another very verbose description blah blah.")
end