pascal strings in the gnu assembler

Maurice Lombardi Maurice.Lombardi at
Mon May 5 14:11:15 CEST 2008

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.

> 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 Lombardi
Laboratoire de  Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex     FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice.Lombardi at

More information about the Gpc mailing list