English Amiga Board


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

 
 
Thread Tools
Old 15 April 2024, 17:29   #1
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Exporting/Importing absolute expressions

Hi,

I use XREF/XDEF for bigger projects in conjunction with a linker. It seems that I can only use them for labels. It doesn't work with absolute expressions like in this example:


Code:
file.a

XDEF absolute_expression

absolute_expression EQU 5


file.b

XREF absolute_expression

move.w #absolute_expression*2,d0 ;Error: I can't use any computing on the importet absolute expression
Is there a way to export/import absolute expressions?
dissident is offline  
Old 15 April 2024, 17:34   #2
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,002
use an include (.i) file where you define absolute_expression?

Not really exporting/importing, though.
Hedeon is offline  
Old 15 April 2024, 17:57   #3
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by Hedeon View Post
use an include (.i) file where you define absolute_expression?

Not really exporting/importing, though.
Hmm, that's not my intention. The absolute expression in fila.a may change with the next assembling/linking. It's a little more complex.
dissident is offline  
Old 15 April 2024, 18:07   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
That's not what XDEF/XREF are used for (EQUs&co).
You could see EQU/SET/RSSET/.. as "compile time" variables/constants. Now, if you would do something like:
Code:
QQQ EQU 123
varQQQ: DC.L QQQ
then you would use XDEF/XREF with varQQQ. To handle QQQ you simply include a header file (if they are in a separate file) and don't involve XREF/XDEF at all.
a/b is offline  
Old 15 April 2024, 18:59   #5
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by dissident View Post
Hmm, that's not my intention. The absolute expression in fila.a may change with the next assembling/linking. It's a little more complex.
Can you provide an example that's indeed more complex and won't work with simple include file ?
meynaf is offline  
Old 15 April 2024, 20:19   #6
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by meynaf View Post
Can you provide an example that's indeed more complex and won't work with simple include file ?
It's my example from above. I refered to Hedeon's answer.

file.a doesn't know the expression from file.b.

A more precise example;

file.a:
Code:
XDEF v_BPLCON4

BPLCON4    EQU $0011
v_BPLCON4 EQU BPLCON4

file.b has its own value which will be combined with the value of file.a:
Code:
XREF v_BPLCOBN4

BPLCON4 EQU 0

lea copperlist,a0

move.w #BPLCON4+v_BPLCON4,x(a0)
dissident is offline  
Old 15 April 2024, 21:11   #7
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by dissident View Post
It's my example from above. I refered to Hedeon's answer.

file.a doesn't know the expression from file.b.

A more precise example;
This can still work with an include...

Code:
; file.i
v_BPLCON4 EQU $0011

; file.a
 include file.i
BPLCON4 EQU v_BPLCON4

; file.b
 include file.i
BPLCON4 EQU 0

 lea copperlist,a0
 move.w #BPLCON4+v_BPLCON4,x(a0)
meynaf is offline  
Old 15 April 2024, 21:39   #8
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by meynaf View Post
This can still work with an include...
In most cases you are right, but not in my case. I need the different scopes for each file which represent separate effects.

file.a sets up a view with some sprites with the first copperlist. The first copperlist calls the second copperlist with a COPJMP2. You can see file.a as a wrapper for file.b.

file.b sets the viewport and uses the second copperlist. Now, if in the first copperlist the sprites colourbank is set, then the second copperlist should do the same. Otherwise the sprite colours would be weird, If I do only changes of the sprites colourbank in file.a, file.b has to know this after the linking.

Anyway, I found a solution which works. If the importet value is not part of any computing formula, it can look like this:

Code:
lea copperlist,a0

move.w #BPLCON4,d0
or.w   #v_BPLCON4,d0
move.w d0,x(a0)
dissident is offline  
Old 15 April 2024, 23:57   #9
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
1. Use SET instead of EQU so you can simply overwrite the symbol with a new value in file.b (EQU is for constants and can be used only once, while SET you can use multiple times)
Code:
; file.a:
QQ SET 123

; file.b:
  INCLUDE file.a
QQ SET 0
2. Use conditional assembly
Code:
; file.a:
 IFD IN_B
QQ EQU 0
 ELSE
QQ EQU 123
 ENDIF  ; or ENDC

; file.b:
IN_B EQU 1
  INCLUDE file.a
a/b is offline  
Old 16 April 2024, 14:36   #10
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Thx for all your replies. I guess I found a solution for my case.
dissident is offline  
Old 18 April 2024, 17:35   #11
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by dissident View Post
I use XREF/XDEF for bigger projects in conjunction with a linker. It seems that I can only use them for labels. It doesn't work with absolute expressions like in this example:
There is no difference between absolute symbols and relocatable symbols (labels). The only allowed operation is
symbol + addend
(where
addend
can also be negative or zero).
phx is offline  
Old 26 April 2024, 08:45   #12
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by phx View Post
There is no difference between absolute symbols and relocatable symbols (labels). The only allowed operation is
symbol + addend
(where
addend
can also be negative or zero).
Well, there is a difference for O.M.A 2.04, otherwise it would work. An absolute value is not a relocatable symbol. That's the point why formulas dont't work with XREF/XDEF absolute values.
dissident is offline  
Old 27 April 2024, 22:27   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by dissident View Post
Well, there is a difference for O.M.A 2.04, otherwise it would work. An absolute value is not a relocatable symbol.
You are right, of course. Absolute and relocatable symbols are very different.
I should have been more precise: There is no difference for the operators allowed in expressions involving externally defined relocatable or absolute symbols.
phx 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
vasm - Use defined object code in macros/expressions? dansalvato Coders. Asm / Hardware 2 24 March 2022 01:38
About VASM expressions JuanLuis Coders. Asm / Hardware 6 07 June 2020 10:28
Debug console / importing labels? buzzybee support.FS-UAE 4 21 August 2019 12:31
Importing into Imagine 4.0's Spline Editor? StrangeVoyager support.Apps 0 18 May 2019 07:08
Exporting, edit and importing fonts tooki41 request.Other 7 14 January 2017 16:22

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 14:44.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08358 seconds with 15 queries