XA: * manipulations
Posted: Fri Apr 14, 2017 6:35 pm
I'm trying to translate some macros from CA65 to XA.
One of them takes a string as parameter and puts the length of this string followed by the string:
is expanded:
To do so, I write this XA macro:
But the object file is:
With the length after the string...
Then, I'm writing the code below to trace the '*' pointer
The xa -v -l out.l test2.s output is:
The '*' pointer's values are correct and the labels values are correct too:
So everything seems ok, but the object file is:
Again, the 11 22 is after the 55.
Note the lda _table2 is correctly assembled as ad 02 04
So the value of the '*' is following all affectations, same for all labels, but the bytes are not at the right place.
Since I set '*' only to already used addresses, I thought I can do that.
Is there a way to write this kind of macro?
One of them takes a string as parameter and puts the length of this string followed by the string:
Code: Select all
pstring "TEST"
Code: Select all
.byte 4,$54,$45,$53,$54
Code: Select all
#define pstring(s) -_start=* : .byte 0,s : -_end=* : -_len=_end - _start -1 : *=_end
pstring("TEST")
Code: Select all
00000000 00 54 45 53 54 04 |.TEST.|
Then, I'm writing the code below to trace the '*' pointer
Code: Select all
* = $0400
#print *
_table_start:
.byte $00,$00,$33,$44,$55
; We are at $0405 (1029)
_table_end:
#print *
; Back to start of program
* = $400
_back:
#print *
.word $2211
; Now, we should have
; 0400 11 22 33 44 55
; * should be $0402 (1026)
#print *
_table2:
; Forward to $0405 (1029)
* = _table_end
#print *
.byte $66,$77
; Now, we should have
; 0400 11 22 33 44 55 66 77
; * should be $0407 (1031)
_end:
#print *
; Should be
; 0407 ad 02 04
lda _table2
Code: Select all
Cross-Assembler 65xx V2.2.5 (No date available)
(c) 1989-98 by A.Fachat
65816 opcodes and modes coded by Jolse Maginnis
Oric C adaptation and debugging by Mickael Pointier
Clean Linux port by Jean-Yves Lamoureux
Fri Apr 14 19:05:55 2017
xAss65: Pass 1: test2.s
*=*=1024
*=*=1029
*=*=1024
*=*=1026
*=*=1029
*=*=1031
xAss65: Pass 2:
Statistics:
5 of 5000 label used
0 of 40000 byte label-memory used
0 of 10000 PP-defs used
0 of 1000000 byte PP-memory used
225 of 400000 byte buffer memory used
0 blocks used
0 seconds used
Code: Select all
0400 _table_start
0405 _table_end
0400 _back
0402 _table2
0407 _end
Code: Select all
00000000 00 00 33 44 55 11 22 66 77 ad 02 04 |..3DU."fw...|
Note the lda _table2 is correctly assembled as ad 02 04
So the value of the '*' is following all affectations, same for all labels, but the bytes are not at the right place.
Since I set '*' only to already used addresses, I thought I can do that.
Is there a way to write this kind of macro?