pascal strings in the gnu assembler

steven.borley steven.borley at
Mon May 5 12:31:59 CEST 2008

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  

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Gpc mailing list