Page 1 of 1

Question about the ORG value

PostPosted: Sat Nov 18, 2017 4:37 pm
by LukeBord1
Maybe the question could result dumb to Assembly experts; however, is there a way to make an ORiGin memory address flexible? Saying it more clearly, even setting an ORG value in the ZXB commandline, is there a way to import the code into a new memory address?

Re: Question about the ORG value

PostPosted: Wed Nov 22, 2017 11:18 pm
by boriel
Currently not. What do you want to achieve exactly?

Re: Question about the ORG value

PostPosted: Thu Nov 23, 2017 7:10 pm
by LukeBord1
boriel wrote:What do you want to achieve exactly?


...just to avoid to repeat the compile process regarding multiple bas files when the first org value is incorrectly calculated. I thought there was a way to freely import the compiled bin files as it happens with other tools like screen compressors or sound fx generators.

Re: Question about the ORG value

PostPosted: Fri Nov 24, 2017 10:49 am
by boriel
LukeBord1 wrote:
boriel wrote:What do you want to achieve exactly?


...just to avoid to repeat the compile process regarding multiple bas files when the first org value is incorrectly calculated. I thought there was a way to freely import the compiled bin files as it happens with other tools like screen compressors or sound fx generators.

You can, but not with ZX Basic cdeo, but with ASM code:

1) Compile your code with zxbasm for example
2) Your code must be relocatable (no org, no JP's, just JR, etc)
3) In your ZX Basic program do:

  Code:
PRINT "Hello world"
GOTO AfterBinary  : REM Avoid the CPU entering this region
MyBinary:   REM here starts your rutine
ASM
incbin "myfile.bin" ;  This include a binary file "as is"
END ASM
AfterBinary:
REM Now let's invoke the rutine

RANDOMIZE USR @MyBinary : REM @ means "address of", like "&" operator in C

Have not tested this, but it should work. Please, try this and tell me

In the mean time, just to let you know that, at this moment, ZX Basic does not have a linker (yet to be done).
But I think is what you're asking for. Basically, libraries (.BAS and asm) to be compiled once and stored in a binary format in a lib/ directory to be reused later, like C and other languages do. Still working on it.