12 March 2010, 13:33 | #1 |
Registered User
Join Date: Feb 2010
Location: Helsinki, Finland
Posts: 36
|
32bit PC-relative LEA ??
I'd like to see beyond 16bit indexing limit, so how to do it?
This is the normal way... it only sees 32k forwards and backwards. lea data(pc),a0 data: dc.l $0 I think I did it yesterday, or I just thought I did dit it but it was something else, but now I can't remember what it was. Suppose you have 64k of data between those two lines, you ain't seeing "data" anymore. I can think of a hundred bad ways to do it, but in case you know the best way, you could enlighten me. I think I just put .l somewhere... |
12 March 2010, 13:39 | #2 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
START moveq #0,d0 ; start of your program code, can be any instruction of course .... lea START(pc),a0 add.l #data-START,a0 ; -> "emulate" lea data(pc),a0 et voilá. |
|
12 March 2010, 14:20 | #3 |
Banned
Join Date: Jan 2007
Location: France
Posts: 655
|
It's "et voilà."
|
12 March 2010, 14:32 | #4 |
Registered User
Join Date: Feb 2010
Location: Helsinki, Finland
Posts: 36
|
Thanks. Modified it a little bit...
here: lea (pc),a0 add.l #data-here,a0 data: dc.l $0 Now it can see also backwards Fantastique! |
12 March 2010, 14:38 | #5 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Damn, I'll never learn french.
Quote:
Code:
MLEA MACRO lea *+2(pc),\2 add.l #\1-*+2,\2 ENDM |
|
12 March 2010, 15:56 | #6 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Just want to point out that on 68020 and above you have 32-bit PC relative addressing modes available.
|
13 March 2010, 00:56 | #7 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Yes, but don't use them on the Amiga. They are not needed and slow. It would be faster to use absolute addresses and let the Amiga loader relocate. If there is a free address register and very many accesses then something like the examples above is the best.
|
13 March 2010, 17:03 | #8 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,633
|
Good tip That actually works, although I was a bit skeptical about the *+2 references on different instruction addresses
Here's an alternate take that does the same. Code:
MLEA: MACRO .mlea\@: lea .mlea\@(pc),\2 add.l #\1-.mlea\@,\2 ENDM |
15 March 2010, 16:02 | #9 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
An interesting test case, indeed. I'm surprised that most assemblers generate correct code (even my own ones)!
I would not recommend it though. Isn't \@ more likely taken from Devpac? Or did the original SEKA also support it? |
15 March 2010, 19:17 | #10 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
"Cleaner" version would be: Code:
MLEA MACRO lea *(pc),\2 add.l #(\1-*)+4,\2 ENDM You say you wouldn't recommend it but do not explain why. I am interested as to WHY you would not recommend it because I can't see any reason. The MACRO makes perfect sense and works as intended! Last edited by StingRay; 15 March 2010 at 19:51. Reason: typo |
|
15 March 2010, 20:20 | #11 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
Quote:
Quote:
I personally would avoid the * symbol whenever possible, because it is not implemented the same in all assemblers. As an example, critical cases are short-branches Code:
bra.b *-2 Code:
dc.l *,*,*,* Code:
dc.l *,* dc.l *,* The only case where I have to use * is with assembler-inline code in C sources. |
||
15 March 2010, 20:32 | #12 | |||
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Using uppercase wasn't meant as shouting, I just wanted to emphasize that I'm really interested in the reason why you wouldn't recommend it.
Quote:
Quote:
Quote:
How about pc relative jump tables? dc.l *-TAB. There are certainly more reasons to use * than just inline asm in C! |
|||
15 March 2010, 21:01 | #13 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
Don't misunderstand me. My replies were general and not directed to you personally. I didn't want to advise you or even make you change your coding habbits. You just asked why I wouldn't use '*'. And I answered. Just have fun everybody!
You're right about AsmOne. I never used it in my whole life (because of those "problems" ). |
15 March 2010, 21:12 | #14 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
To make it a bit more clear, I'd f.e. never use bra.b *+2 in a macro for the reasons you mentioned, branch distance can change and then all hell breakes loose. However, in the case of the "PC relative lea" macro there are no problems like that because it consists of just 2 instructions of fixed length that can never(!) change. Which is why I don't see it as a problem to use the "*" symbol there. I never found a better alternative so despite the lot of problems Asm1 definitely has, it's still the best choice for me. =) |
|
15 March 2010, 22:42 | #15 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
Quote:
Quote:
And there might be also some special cases where * is just easier. You mentioned one form of jump table. But there are several kinds of jump tables. Quote:
It heavily depends on personal taste, how you are used to work and in which environment you want to do it. |
|||
15 March 2010, 23:14 | #16 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,633
|
Ah, but then you won't have us believe that your first choices aren't phxAss and... (help me out here?)
Welcome to EAB and Coder's Heaven anyway, good to see another umm oldtimer (/me ducks) |
16 March 2010, 04:09 | #17 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Everyone remembers PhxAss though. Maybe the name wasn't so bad after all . Vasm is getting very good. It's worth while to switch from PhxAss as it's more forgiving and has less bugs. No one should be using Devpac as vasm has a Devpac compatibility mode, more options and more optimizations. Vasm can optimize branches both forward and backward for example. AsmOne still makes sense as it has some features vasm never will. You have to live with the bugs and lack of support though. Ced with ARexx, and BDebug make a pretty potent programming combo. I think many 68k assembly programmers are set in their ways and don't try new things so they miss gems like vasm. It took me a long time to switch but I'm glad I did. |
|
16 March 2010, 11:35 | #18 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
|
|
16 March 2010, 12:39 | #19 | ||
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
Quote:
You could f.e. tell me to use vasm and I'd still use Asm1 because as you say it depends on personal taste. So far I didn't find any other package with shorter turnaround times than Asm1 so despite its bugs it allows me to do the things I want to do in the shortest time. |
||
18 March 2010, 01:37 | #20 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,633
|
Argh, it was meant as a hidden insult. Argh, fail
Yeah, I've certainly never coded a 68K assembler, that's for sure. I've made my own bugfixed version of AsmOne 1.02, with Promax's help, and I've made a C-64 crossassembler (with parallel cable transfer) monstrosity using macros in AsmOne, but certainly not a real assembler for Amiga. Props. I did code a Z80 assembler on PC though, with the sole purpose of coding a little MSX-cartridge Pong game The cartridge EPROM did work and I was very proud... for about a day or two and then, you know, lose interest and onto the next project This was way after MSX was popular, as nothing but nostalgia would have made me do all that work My first steps in coding assembler was when I was 11, on the Acorn Atom and Apple-II. But it was not until I was 13 or so that it was anything more than 'modified typed-in sources from magazines'. If you know what I mean. All those home computer brands, one more exciting than the other! Good times |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
adda / suba Vs. lea | pmc | Coders. General | 45 | 01 October 2022 14:20 |
question on resourcing relative addressing | ara | Coders. Asm / Hardware | 5 | 04 February 2012 23:42 |
Trying to have portable configuration, relative paths relative to C:\Public\... ? | Turrican | support.WinUAE | 3 | 24 June 2011 16:33 |
Relative paths (WAS: Has anybody ever gotten Shiftrix to work?) | rsn8887 | support.WinUAE | 9 | 27 August 2010 06:56 |
Relative paths | Toni Wilen | request.UAE Wishlist | 0 | 16 August 2009 16:06 |
|
|