18 January 2024, 17:25 | #1 |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
VASM and illegal relocations
Quick VASM and Linking question.
Assume I do this in file 1: Code:
PLANE_LENGTH EQU (320*224)/8 Code:
lea -PLANE_LENGTH(a4),a4 However, on individually compiling file 2 on its own, VASM throws an "illegal relocation" error. The current workaround is to not allow the assembler to calculate PLANE_LENGTH. So doing the following is ok: Code:
PLANE_LENGTH EQU 8960 |
18 January 2024, 17:38 | #2 | |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,997
|
Quote:
Shouldn't it be (320/8)*224 ? |
|
18 January 2024, 17:59 | #3 |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
I can promise you the calculation is fine and is what I want.
It's the ability to use the VSCode plugin with per-file compilation turned on, without it spewing out a ton of errors that vanish during the linking process I'm after. |
18 January 2024, 18:01 | #4 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Why would using
Code:
PLANE_LENGTH EQU 8960 |
18 January 2024, 18:04 | #5 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Ahh.. so you need to tell the assembler, the symbol will be found during linking..
try "xref PLANE_LENGTH" in source #2, and perhaps "xdef PLANE_LENGTH" in source #1 .. I'm not sure if that only works with labels though. |
18 January 2024, 18:17 | #6 | |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
Yep, I'd tried xdef/xref - but to no success.
The bizarre thing is - with some of my other source files, it picks up the EQU calculation fine! So I can only assume it's some sort of VASM 'internal order of doing things' that I'm violating - possibly through my own ignorance. I did Google, and this Megadrive coder was having a similar issue: https://huguesjohnson.com/programmin...is/game-state/ Quote:
|
|
18 January 2024, 18:27 | #7 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
If you assemble each file individually without xdef/xref the symbol, I don't understand why it sometimes would assemble at all, since PLANE_LENGTH is completely unknown (both the symbol *and* its value) when you assemble src #2.
I think there is posts on here about something related where vasm can't figure out the value of a label in a single pass (or something along those lines), and then fails. |
18 January 2024, 18:30 | #8 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
PLANE_LENGTH should be defined in a common include file, used by both files.
|
18 January 2024, 18:32 | #9 | |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
Quote:
main.s: INCLUDE "file1.i" INCLUDE "file2.i" file1.i ;;;PLANE_LENGTH EQU (320*224)/8 ; Does not work in file2 PLANE_LENGTH EQU 8960 ; Does work in file2 file2.i lea -PLANE_LENGTH(a4),a4 --- Anyway, yes must be something to do with the way vasm works. I was hoping someone would say "use the following command line parameter you idiot and read the manual better! |
|
18 January 2024, 18:40 | #10 | |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
Quote:
Like I say, none of this is a blocker. In the VSCode Assembly plugin there is an option to turn off per-file compilation. And maybe it's for this reason. On a full compile everything links and executes perfectly. But I usually assume I am doing something wrong when an error is thrown, and I need to understand what. (And I probably am doing something wrong!) |
|
18 January 2024, 19:33 | #11 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,107
|
Add include guards to the common header file (see system includes for example).
If you have file1.s and file2.s that can run on their own, and main.s that includes file1.s and file2.s and file1/2 need common stuff, then create common.i (with include guards) for your equates etc. All three files can then include common.i and in main.s you can include file1.s and file2.s and call their functions etc. You might want to structure your project a bit differently though.. |
19 January 2024, 10:51 | #12 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
Try putting brackets around the whole expression....
PLANE_LENGTH EQU ((320*224)/8) |
19 January 2024, 11:11 | #13 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
|
19 January 2024, 13:08 | #14 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
Otherwise, it is to be expected that -SYMBOLcannot generate any valid relocation type, when SYMBOLis unknown. All common relocations work with addends on symbols, like unknownsymbol + addend. Negating an externally defined symbol's value is not possible, as with most other arithmetic operations, like shift, multiplications, etc.. Quote:
PLANE_LENGTHcompletely unknown. Quote:
Still there is the question why you have any problems even when everything is known and included. Maybe some information is hidden, like 320 and 224 are also symbols, which are defined at a later point? Anyway, I cannot reproduce any problem out of this: Code:
frank@nerthus cat file1.i PLANE_LENGTH equ (320*224)/8 frank@nerthus cat file2.i lea -PLANE_LENGTH(a4),a4 rts frank@nerthus cat main.s include "file1.i" include "file2.i" frank@nerthus vasmm68k_mot -Fhunk main.s vasm 2.0beta (c) in 2002-2023 Volker Barthelmann vasm M68k/CPU32/ColdFire cpu backend 2.6c (c) 2002-2023 Frank Wille vasm motorola syntax module 3.18 (c) 2002-2023 Frank Wille vasm hunk format output module 2.14c (c) 2002-2022 Frank Wille CODE(acrx2): 6 bytes |
|||
19 January 2024, 13:46 | #15 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
label+addend. You cannot shift a label around. The solution would have been to enter absolute mode ( orgdirective) and assemble your code for a fixed address. Then you can do everything you like with labels as no relocations will be generated. EDIT: No, forget what I wrote above! The example from the link above is completely unrelated. The coder just didn't know how macros work in Motorola syntax, and assumed addris a macro argument while it should have been \1. As a result addrwas undefined and caused relocation errors. Last edited by phx; 19 January 2024 at 14:21. Reason: Looked at it again |
|
19 January 2024, 14:21 | #16 | |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
Quote:
With my larger project: 1/ A straight compile in VASM is fine - via the VSCode Amiga Assembly plugin. I hit Ctrl+F5. Everything compiles. No errors. It runs as expected. 2/ Then I switch to the offending file that references the EQU in the project IDE. I save it again unchanged. (I believe the VSCode Amiga Assembly Framework then compiles that file again in isolation.) This is when the compilation error is thrown to the console. The offending line is highlighted in red syntax in the IDE. 3/ The error in part 2 only occurs when there is a formula in the EQU. 4/ The error in part 2 does not occur on a full compile. 5/ As above, I cannot recreate this in my very simple project (recreating what I described in the thread) Short of sending the entire project over, I'll pause on this one for now. If I find out what was causing it, I'll update the thread. It's not blocking me and I don't want to waste anyone's time any further!! Last edited by reassembler; 19 January 2024 at 15:25. Reason: Clarity |
|
19 January 2024, 15:22 | #17 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Is your project still structured like shown above, i.e. with a main.s source including file1.i and file2.i? Then it is no suprise that assembling file2.i individually fails...
Quote:
|
|
19 January 2024, 15:35 | #18 | |
Registered User
Join Date: Oct 2023
Location: London, UK
Posts: 92
|
Quote:
I have a suspicion that this isn't a VASM issue - but potentially the way the 'Amiga Assembly' framework incrementally compiles pieces of code on save. In answer to your question, yes my project is structured in the same way as the example. Well, with many more files, sections, INCBINs and other mess. You may have spotted I'm working on an OutRun port which has entailed rewriting things so many times, there's some housekeeping urgently needed! Once things are tidied up I'll fire it over. |
|
19 January 2024, 17:03 | #19 | |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Quote:
This one I can't explain - I would expect an error regardless of formula or not. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about XREF vs XDEF (vasm 1.8 vs vasm 1.9) | roondar | Coders. Asm / Hardware | 8 | 01 May 2023 20:59 |
Illegal Operator on Include | marduk_kurios | Coders. Asm / Hardware | 8 | 04 August 2017 20:09 |
HD Installers - now illegal? | rattus | Amiga scene | 20 | 29 September 2003 00:25 |
Illegal operation / BSOD | Retroid | support.WinUAE | 9 | 21 April 2002 16:57 |
illegal operation | Traquer | support.WinUAE | 12 | 08 April 2002 10:23 |
|
|