English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 01 January 2019, 02:08   #1
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 5
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.
Attached Files
File Type: s prueba.s (4.6 KB, 18 views)
JuanLuis is offline  
Old 01 January 2019, 03:32   #2
a/b
Registered User

 
Join Date: Jun 2016
Location: europe
Posts: 83
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
a/b is offline  
Old 01 January 2019, 22:34   #3
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 5
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!
JuanLuis is offline  
Old 02 January 2019, 01:02   #4
hmn
Registered User

 
Join Date: Nov 2016
Location: DE
Posts: 15
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.
hmn is offline  
Old 02 January 2019, 05:16   #5
a/b
Registered User

 
Join Date: Jun 2016
Location: europe
Posts: 83
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.
a/b is offline  
Old 03 January 2019, 07:32   #6
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 5
Quote:
Originally Posted by a/b View Post
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.
Ok. Then GNU Assembler can't generate code in a fixed address space. The code will be always relocatable. So, the unique option is to initialize at runtime.


Thanks for all answers.
JuanLuis is offline  
 


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 7 16 October 2018 23:22
Mounting HDF with RDB in GNU/Linux Gaula92 support.Other 0 25 August 2016 13:04
GNU GAS Immediate data misbehaving MintyTheCat Coders. Asm / Hardware 14 03 January 2016 17:01
Preparing a CF from GNU/Linux iddqd support.FS-UAE 1 21 June 2015 11:09
OS3.9 Gnu C Compiler Environment help Morbane Coders. General 0 06 January 2012 09:35

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:11.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.06386 seconds with 14 queries