Next Previous Contents

5. Building a GEOS VLIR application

Currently, you can build VLIR applications only if your code is written in assembly -- no C code allowed.

In your sources, only the command .segment "NAME" will decide which code/data goes where. File-names don't matter. Segments CODE, RODATA, DATA, and BSS go into VLIR part #0. Segment VLIR1 goes into VLIR part #1, VLIR2 goes into VLIR part #2, and so on.

The GEOS resource file's contents are similar to the sequential-file example, but there also is a VLIR section and a structure VLIR tag. Here is that part:

VLIR vlir-head.bin 0x3000 {
  vlir-0.bin    ; CODE, RODATA, DATA, BSS
  vlir-1.bin    ; VLIR1
  vlir-2.bin    ; VLIR2
(Source files are only .s.)

OK, we have "cvthead.grc", so let's allow grc to compile it:

$ grc cvthead.grc
Now, there are two new files: "cvthead.cfg" and "cvthead.s" -- the first one is a config. file for ld65, and the second one contains the GEOS .cvt header. It can be assembled:
$ ca65 -t geos cvthead.s
Now, we have "cvthead.o". The rest of the assembly sources can be assembled:
$ ca65 -t geos vlir0.s
$ ca65 -t geos vlir1.s
$ ca65 -t geos vlir2.s
Note that the file-names here, although similar to those from the VLIR section of the .grc file, are not significant. The only thing that matters is which code will go into which segment.

Now, we can generate binaries. This time, the order of the arguments on the command-line is not important.

$ ld65 -C cvthead.cfg vlir1.o cvthead.o vlir0.o vlir2.o
As defined in the .grc file, we now have the binary parts of the VLIR file: "vlir-head.bin", "vlir-0.bin", "vlir-1.bin", and "vlir-2.bin".

The last step is to put them together in the right order -- the order of the arguments is important this time! As suggested in the comments at the end of "cvthead.cfg", we do:

$ grc -vlir output.cvt vlir-head.bin vlir-0.bin vlir-1.bin vlir-2.bin
That is the end. The file "output.cvt" can be deconverted under GEOS. Note that -C cvthead.cfg was used on the ld65 command-line instead of the switch -t geos.

Next Previous Contents