VLINK problem with *=<expression> on VIC-20

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
stenlik
Posts: 8
Joined: 28 Nov 2021

VLINK problem with *=<expression> on VIC-20

Post by stenlik »

Hello,

I have a small problem with the use of the VLINK. I hope someone can help me:

In the VIC-20 program source code, I am using the *=<expression> to define the base address for the code section (starts at $1001) and the character section (starts at $1C00):

Code: Select all

*=$1001
; Code and data
...
*=$1C00
; Character RAM
...
When I am using VASM (oldstyle syntax module) to create a binary from assembler source code it all works fine and it produces the .prg file with:
  • - Two bytes header
    - Followed by code section with the machine code and data
    - Followed by the area filled with zeros
    - Starting with the position $C02 (because of the 2 bytes header) in the file are appended custom characters.
However, when I use VASM to create the object file followed by calling the VLINK linker to create a binary the *=1$C00 is ignored and the character section starts immediately after the code section without the area filled with zeros, so the app does not work properly…

Please see attached image:

Code: Select all

Broken external image link
https://gcdn.pbrd.co/images/rMtBoCi129Vg.png?o=1
Many thanks for your help
STeN
vbc
Posts: 80
Joined: 23 Apr 2020

Re: VLINK problem with *=<expression> on VIC-20

Post by vbc »

stenlik wrote:
However, when I use VASM to create the object file followed by calling the VLINK linker to create a binary the *=1$C00 is ignored and the character section starts immediately after the code section without the area filled with zeros, so the app does not work properly…
Because many object file formats do not store target addresses, when using a linker and relocatable object files, you usually specify the memory layout in a linker script. This is very flexible but a bit more effort. The oldstyle syntax module creates a new section for every org directive. A linker file for your case could look like this:

Code: Select all

MEMORY
{
 ram : org = 0x1001, len=0x4000
}

SECTIONS
{
 code: { *(seg1001) } >ram
 fill: { .=.+0x1c00-0x1001-SIZEOF(code);}
 chars: { *(seg1c00) } >ram
}
The section names seg* are generated from the addresses. You could also use a named section, but then the code will not work without a linker.

I am not sure at the moment if it is also possible to have the oldstyle syntax module generate a single section with the gaps filled, eliminating the need for a linker script. I will check this with the author of that module.
Post Reply