01 January 2019, 01:08 | #1 |
Registered User
Join Date: Dec 2018
Location: Málaga
Posts: 61
|
Label as expression in GNU Assembler
Hello,
I have built Amiga GCC 6.4.1b from Bebbo because I wanted to develop code with the most recent GCC Compiler available in Amiga. I wanted to use GNU Assembler 2.31.51(of same GCC build) for critical routines, so I have tried to compile a code of Scoopex Tutorial (Tutorial 9) using GNU Assembler. I have adapted code to GNU Assembler format but there is an error that I can't fix. Here it's a fragment of the code. ... .even Spr: dc.w 0x2c40,0x3c00 /* Vstart.b,Hstart/2.b,Vstop.b,%A0000SEH */ dc.w 0b0000011111000000,0b0000000000000000 … Sprite definition ... ... SprP: dc.w 0x120,(Spr>> 16) & 0xffff dc.w 0x122,(Spr) & 0xffff ... Error: invalid operands (.text and *ABS* sections) for `>>' The problem is I'm trying to use a Label (the address of Sprite definition) as integer value in an expression. ASMOne allows using labels as values, but I can't do the same thing with GNU Assembler. Where is the error? Is there any special syntax for that? Another thing I tried to do was defining a Symbol equal to the label Spr: ... Sprite definition ... ... Spr_value = Spr ... SprP: dc.w 0x120,(Spr_value>> 16) & 0xffff dc.w 0x122,(Spr_value) & 0xffff ... The code compiles but taking a look on output listing Spr_value has a null value. The assigment sentence is not executed as I expected. Thanks in advance. |
01 January 2019, 02:32 | #2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,057
|
My guess is...
Spr_value is a 32-bit relocatable symbol, its actual value is not know until you start a program and the loader resolves it. So you cannot do some things with it, like splitting it into two or more parts, multiplying/dividing, bit manipulation, ... This will work: DC.L Spr_value+1234 This won't: DC.W Spr_value>>16 You'll probably have to do something like: Code:
move.l #Spr_value,d0 move.w d0,SprP+6 swap d0 move.w d0,SprP+2 ... SprP: DC.W 0x120,0,0x122,0 |
01 January 2019, 21:34 | #3 |
Registered User
Join Date: Dec 2018
Location: Málaga
Posts: 61
|
I thought about runtime initialization but AsmOne can initialize values at compiling time. If you take a look in attached code, you'll be able to see that I have written an org instruction at the begining of the code. So, the address of Spr should be known at compiling time. In fact, AsmOne can compile the declaration without any problem.
Anyway, thanks for your advice. I'll replace static initialization by runtime initialization. I forgot an important thing in my earlier post. Happy new Year to English Amiga Board and its members! |
02 January 2019, 00:02 | #4 |
Registered User
Join Date: Nov 2016
Location: DE
Posts: 20
|
Later on in Photon's tutorials (episode 12), he cleans up his code not to use fixed adressing and sets addresses in the copperlist at runtime.
|
02 January 2019, 04:16 | #5 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,057
|
That's because .org doesn't work the same way as ORG/LOAD in asm-one. It doesn't make your code load and execute at specified absolute address, it merely moves the current code address by 0x20000 bytes, so you end up with a 128KB hole in your, *still* relocatable, code section.
|
03 January 2019, 06:32 | #6 | |
Registered User
Join Date: Dec 2018
Location: Málaga
Posts: 61
|
Quote:
Thanks for all answers. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Art Expression V2.04 working copy? | Peter | request.Apps | 8 | 27 September 2020 12:45 |
Mounting HDF with RDB in GNU/Linux | Gaula92 | support.Other | 0 | 25 August 2016 12:04 |
GNU GAS Immediate data misbehaving | MintyTheCat | Coders. Asm / Hardware | 14 | 03 January 2016 16:01 |
Preparing a CF from GNU/Linux | iddqd | support.FS-UAE | 1 | 21 June 2015 10:09 |
OS3.9 Gnu C Compiler Environment help | Morbane | Coders. General | 0 | 06 January 2012 08:35 |
|
|