2

I am trying to use the xa assembler to write some 6502 code. According to the documentation, I can define a zeropage segment using the .zero pseudo-op. I was hoping to do something like this:

.zero

tmp1: .byt 0
tmp2: .byt 0

.text

      lda $12
      sta tmp1
      lda $34
      sta tmp2

I am hoping for this output:

a512 8500 a534 8501

But trying to assemble the above fails with:

foo.s:line 1: 1000:Illegal segment error

According to the docs, "These pseudo-ops are valid in relative and absolute modes". Just for kicks, I tried enabling relocatable mode (xa -R ...), which compiles the code without error, but now I have an o65 format file instead of raw assembly output (and linking that with ldo65 produces an o65 binary).

Is it possible to use segment pseudo-ops in xa while still producing raw assembly output?


@Raffzahn asked for complete command lines. Assuming the code is in file xatest.s, this fails:

xa xatest.s

This fails:

xa -bz 0 -bt 512 xatest.s

This completes without error, but doesn't produce useful output:

xa -R xatest.s
1
  • Not sure, but IIRC .text is only allowed in relocatable format. Maybe the issue is just reported with a wrong line number? Also, in non relocatable mode the Assembler needs a well a hint were to start. Next, when using relocatable format, the linker needs to be given addresses for each segment. This can be done with the assembler as well (-b*), so maybe theres somethign to try (P.S.: addin the whole command line with all options used may be a good idea).
    – Raffzahn
    Jan 16, 2021 at 17:31

1 Answer 1

2

This code achieves the output you want:

    tmp1=$00
    tmp2=$01

* = $100
    lda $12
    sta tmp1
    lda $34
    sta tmp2

I don't think the segment identifiers are really intended to be used in raw output. They're for relocatable object files, as the documentation tries to allude to:

The following pseudo-ops apply primarily to relocatable .o65 objects. A full discussion of the relocatable format is beyond the scope of this manpage, as it is currently a format in flux. Documentation on the proposed v1.2 format is in doc/fileformat.txt within the xa installation directory.

1
  • 1
    ...which leads me to wonder about the use of segments in absolute assemblers, but I'll post that as a new question.
    – larsks
    Jan 16, 2021 at 23:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .