17 March 2022, 22:55 | #1 |
Registered User
Join Date: Jun 2009
Location: United States
Posts: 57
|
Question about NEAR directive in vasm
Hello, I'm new to Amiga ASM and have been exploring options for base-relative addressing. I've taken a liking to the NEAR directive for its implicitness in converting absolute label references into base-relative ones.
The issue I have is that NEAR doesn't seem to support the relative index addressing mode. For example: Code:
NEAR a5 XREF _LinkerDB DATA SomeStruct: dcb.l 4 CODE lea _LinkerDB,a5 ; This works move.l SomeStruct+4,d0 ; This is identical to the above move.l SomeStruct+4(a5),d0 ; This does not work move.l (SomeStruct,d1.w),d0 ; Directly referencing a5 also does not work move.l SomeStruct(a5,d1.w),d0 ; This works lea SomeStruct,a0 move.l (a0,d1.w),d0 Any insight on what I might be missing about NEAR, and if I should just use BASEREG instead? Thanks very much in advance. Last edited by dansalvato; 18 March 2022 at 02:12. |
18 March 2022, 05:00 | #2 |
Registered User
Join Date: Jun 2009
Location: United States
Posts: 57
|
I think I answered my own question—the index addressing mode only supports an 8-bit offset value, but NEAR (and base-relative addressing in general) works on the premise that a 16-bit offset is available to fetch data relative to the base address. So, it makes sense that you wouldn't be able to combine an index with this addressing mode.
|
18 March 2022, 12:40 | #3 | ||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
-sdor the -phxassoption to enable automatic small-data translations. Also, the referenced symbol should be in a small-data section, named "__MERGED". Quote:
(d16,An). You can enable small-data for 68020 extended addressing modes with the -extsdoption, but you still have to explicitely define SomeStructas a 16-bit displacement. For example, these will work and should generate 16-bit small-data relocs (with -extsd): Code:
move.l (SomeStruct.w,a5,d1.w),d0 move.l ([SomeStruct.w,a5],d1.w),d0 Quote:
Traditionally, only 16-bit base relative was ever used in Amiga programs. Certainly for a reason. 8-bit leaves you with only a tiny small-data segment of 256 bytes, and there is no (d8,An)addressing mode on 68000 anyway. 32-bit gives you no size advantage to absolute addressing and requires 68020. Quote:
|
||||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issues with ORG directive (vasm + FS-UAE) | Maggot | Coders. Asm / Hardware | 15 | 05 September 2023 11:56 |
Another Vasm question | LeCaravage | Coders. Asm / Hardware | 7 | 27 January 2021 23:30 |
vasm basereg example directive | mcgeezer | Coders. Asm / Hardware | 7 | 18 November 2020 19:58 |
Vasm “so.” directive | Curbie | Coders. General | 9 | 09 April 2020 20:55 |
REPT directive in vasm | phx | Coders. Asm / Hardware | 8 | 01 October 2014 21:48 |
|
|