23 November 2019, 10:41 | #1 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
dc.w / dc.l at odd address
As title says.
I wonder if there exists some assembler which can accept that. At least phxass doesn't. Because even though 68000 has these alignment restrictions, 68020+ doesn't. And i sometimes need to pack structures (or port code from another cpu). In addition, i wonder if AmigaDOS would accept doing a relocation at an odd address. At least, there is nothing in hunk format itself that forbids this. |
23 November 2019, 10:50 | #2 |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
vasm seems to assemble this, in 68000 only mode (-m68000):
Code:
dc.b 0 dc.w 0 |
23 November 2019, 10:58 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
With a value of 0 it is like ds directive, and ds.w / ds.l is accepted regardless of alignment (and would be easy to handle with ds.b anyway).
|
23 November 2019, 11:12 | #4 |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
Code:
dc.b 5 dc.w 10 |
23 November 2019, 12:10 | #5 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
The above is rejected by phxass (-> error 40 : Word at odd address).
It may be that vasm does auto-align. To see this, just do hex dump of the assembled file. |
23 November 2019, 12:17 | #6 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
KS1.x support it on bare 68k. In KS2.0+ a 020+ is required. Probably some optimization done in later hunk loader that breaked this 'feature'. EDIT: in fact this could also be considered as a yes if you are only interested in 020+ code Last edited by ross; 23 November 2019 at 12:25. |
|
23 November 2019, 13:37 | #7 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
23 November 2019, 14:36 | #8 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
|
Quote:
Lea data,A4 Move.b (a0)+,d0 Lsl.w #8,d0 Move.b (a0)+,d0 Lea (a4,d0.w),a0 .... Data Dc.b 1 Dc.w start1-Data Start1 Dc.b 6 ... Because Resource and Amiga assemblers dont like especially dc.w/dc.l at odd addreseses, i must use different way to creating custom modules from these Titan games. Original code was perhaps generated with strange C compiler, i think. This compiler created also movem.l ,-(sp) and movem.l (sp)+, opcodes too. Most assemblers dont handle these opcodes too. |
|
23 November 2019, 15:21 | #9 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
Not that I know of, but every decent assembler should allow you to create a macro that converts a word-sized argument to two dc.b directives. No. The segment loader would crash, at least on a 68K.
|
23 November 2019, 15:39 | #10 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Yes, I can confirm that I decided to allow unaligned data by default in vasm. You can enable auto-alignment with the -align option (which vasm also does in -devpac compatibility mode).
I know that LoadSeg() doesn't allow unaligned relocs, but vasm is not restricted to AmigaOS. Even on Amiga you could write absolute code with ORG and write it as a raw binary. EDIT: Then it's probably a bug that -phxass compatibility doesn't include the -align option. Will fix that. Last edited by phx; 23 November 2019 at 15:43. Reason: PhxAss |
23 November 2019, 16:18 | #11 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Of course but the target is 68020+ so there is no reason it would crash there. Quote:
Quote:
Besides, auto-alignment looks dangerous to me. Think about this code : Code:
dc.b 1 label dc.w 2 |
|||
23 November 2019, 21:30 | #12 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
label: dc.w 2 IIRC, Devpac does the same(?). |
|||
24 November 2019, 09:45 | #13 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
24 November 2019, 18:01 | #14 |
Registered User
Join Date: Sep 2006
Location: france, bdr
Age: 48
Posts: 92
|
if you need alignment, uses 'EVEN' it may work.
for example dc.b 0,5,3 even dc.l 0,5 |
24 November 2019, 18:25 | #15 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
Quote:
Well, let's put it like this: "In principle" you can put an odd byte offet into the hunk-reloc section - but frankly: Attempting to load such a binary on a 68000 and getting a software failure before the program can identify to the user as requiring a 68020+ is probably not such a nice idea. |
|
24 November 2019, 19:08 | #16 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
But here this is precisely what i'm trying to avoid. Why the heck should i add wasteful padding where the cpu doesn't need it. Quote:
Anyway, assemblers themselves already don't like doing computations on offsets. Quote:
|
|||
25 November 2019, 03:28 | #17 | ||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,546
|
Quote:
1. Not padding is less efficient because it takes two memory cycles to access a word on a byte boundary. 2. You've got plenty of memory. Do you micromanage all your code to save every last byte? I bet you don't. 3. Someone might have a fast 68000 and they won't be able to run your code if it's not padded (same reason you shouldn't use any 68020 instructions unless absolutely necessary). 4. Amiga OS pads structures, so it's in the finest retro tradition! Half the things assembly language programmers do to make their code 'less wasteful' are of dubious worth or even counterproductive. Quote:
Yeah, I know - it's 2019 and devices are supposed to handle whatever crap is thrown at them these days. But that's one reason we still use our trusting old Amigas, from a time when people acted responsibly and vandalism wasn't tolerated. Amiga OS gets a lot of its speed by not checking things. And it shouldn't have to. You are supposed to write code that doesn't crash the OS! |
||
25 November 2019, 10:55 | #18 | ||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
And as the exact same code has to handle both cases (it can't know if the data is currently aligned or not), it is a lot faster than having to realign before making the memory access. Quote:
Quote:
Quote:
Quote:
Quote:
And the users aren't supposed to run on 68000 something that's explicitly documented as requiring 68020+. It's not worse than all these programs using the fpu and crashing 8000000F without a warning. Or these who work on 68000 and fail on anything else. Checking the reloc alignment wouldn't make the OS significantly slower, btw. |
||||||
26 November 2019, 05:48 | #19 | ||||||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,546
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||
26 November 2019, 09:48 | #20 | |||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
And it's fun to code on. |
|||||||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
uncrunch same address of source | Giants | Coders. General | 18 | 24 October 2018 17:57 |
Address register expected | Nightfox | Coders. Asm / Hardware | 4 | 12 August 2016 11:51 |
How to show IP Address? | AGS | support.Apps | 18 | 08 May 2014 21:05 |
DevPac and Absolute Address | h0ffman | Coders. General | 2 | 14 January 2011 15:32 |
NAT address | -Rob- | support.Other | 7 | 07 April 2008 00:06 |
|
|