Hope this is not considered too off-topic as it about the gnu assemble (gnu-as). I beg forgiveness on grounds that's its Pascal related.
In my assembly code I'm trying to place string constants in memory (length byte followed by ASCII string with no trailing zero byte)
The following is failing with "Error: illegal relocation size: 1"
FOO: .byte ((BAR - . - 2) & 0x7F) ; calculate length .ascii "foo" BAR: .word 0x1234 ; dummy for this example
I could just hard code the length, except I eventually want this as macro as I have several hundred strings. And unfortunately this part of the code has to be in assembler, for various reasons.
I assume the error is because ((BAR - . - 2) & 0x7F) resolves to a two byte type even although we can see its value would always fit within a byte.
It didn't seem a particularly unusually thing to want to do so I'm hoping someone can point me in the right direction with this.
Regards, Steven
steven.borley wrote:
Hope this is not considered too off-topic as it about the gnu assemble (gnu-as). I beg forgiveness on grounds that's its Pascal related.
In my assembly code I'm trying to place string constants in memory (length byte followed by ASCII string with no trailing zero byte)
The following is failing with "Error: illegal relocation size: 1"
FOO: .byte ((BAR - . - 2) & 0x7F) ; calculate length .ascii "foo" BAR: .word 0x1234 ; dummy for this example
I could just hard code the length, except I eventually want this as macro as I have several hundred strings. And unfortunately this part of the code has to be in assembler, for various reasons.
This makes me curious to know those various reasons.
Regards,
Adriaan van Os
steven.borley a écrit:
Hope this is not considered too off-topic as it about the gnu assemble (gnu-as). I beg forgiveness on grounds that's its Pascal related.
In my assembly code I'm trying to place string constants in memory (length byte followed by ASCII string with no trailing zero byte)
You seem to confuse GPC strings with BP strings: the latter are indeed one length byte followed by the actual string without trailing null bute. But GPC string are ISO 10206 schemata, made from two integer fields: Capacity (maximum length) and Length (actual), followed by the actual string. And the length of an integer field depends on the backend, most of the times 4 bytes, 32 bits.
The
following is failing with "Error: illegal relocation size: 1" FOO: .byte ((BAR - . - 2) & 0x7F) ; calculate length .ascii "foo" BAR: .word 0x1234 ; dummy for this example I could just hard code the length, except I eventually want this as macro as I have several hundred strings. And unfortunately this part of the code has to be in assembler, for various reasons. I assume the error is because ((BAR - . - 2) & 0x7F) resolves to a two byte type even although we can see its value would always fit within a byte. It didn't seem a particularly unusually thing to want to do so I'm hoping someone can point me in the right direction with this.
Maurice