EgonOlsen71 / basicv2

A Commodore (CBM) BASIC V2 interpreter/compiler written in Java
https://egonolsen71.github.io/basicv2/
The Unlicense
84 stars 15 forks source link

turning off 2 bytes loading address #26

Closed nippur72 closed 5 years ago

nippur72 commented 5 years ago

currently the output file does include the 2 bytes for the loading address at the start -- which is fine for loading in the emulator but inconvenient if you want to include it as a binary for another assembly source file.

Can be it turned off in some way?

EgonOlsen71 commented 5 years ago

Not yet, but can add it. Not sure if I manage to do so today, though.

EgonOlsen71 commented 5 years ago

I've added it and tested it briefly. It seems to work. Just compile the program with /addressheader=false and the two additional bytes should be skipped.

nippur72 commented 5 years ago
Settings this to false will prevent the BASIC header from being written as well.

is this a feature or a side effect? Because in my build chain it's useful to have the BASIC header ON and the address OFF (not a real issue I can put a basic header with the assembler). Perhaps the generation of the header could be a separate command line options.

EgonOlsen71 commented 5 years ago

Well, I failed to see the point in having a BASIC header but not the address bytes, so I coupled these two. I could decouple it but as you've mentioned, that would require an additional parameter and some changes to the logic of when the BASIC header is being added and when not. Still...what's the point in having a BASIC header but not address bytes?

nippur72 commented 5 years ago

If you wanted a mixed program, half basic and half assembly you could do something like this:

org 2049
include binary "some_bas_compiled_with_mospeed.bin"
assembly_part:
  rts

So the .bin needs to NOT have the address bytes but you still want the BASIC header so that it can bootstrap itself.

I do this in my 3dfun program, where I had to add the stub:

#ifdef MOSPEED  
      basic start
         10 sys {mospeed_part}
      basic end
mospeed_part:
#endif
#ifdef MOSPEED then include binary "compiled.bin"

(there I use my asmproc language/assembler but the concept is the same for a generic assembler.

EgonOlsen71 commented 5 years ago

I see. I've made it so now that the address bytes and the basic header are independent of each other. Omitting the bytes has no influence on the basic header anymore.