Page 1 of 1
Silly 68k question
Posted: Sun May 10, 2009 5:18 am
by powerofrecall
I have been experimenting with the Easy68k environment to do some MD stuff.
The syntax is pretty much straight up Motorola so I have the old SGCC header/crt0 asm assembling and working okay... Easy68k's assembler is supposed to respect the original motorola style.
What I can't figure out though is why it won't accept
move.l (variable), a2
or
movea.l (variable), a2
am I missing something? Obviously I'm trying to load a RAM address into A2, but it dies here with "invalid syntax."
Posted: Sun May 10, 2009 5:53 am
by Chilly Willy
That would be
movea.l variable,a2
movea.l variable.w,a2
movea.l variable.l,a2
Without .w or .l, the assembler picks one or the other based on the address of the variable. Using .w or .l explicitly tells the assembly to use short or long absolute addressing. The RAM and ROM in the Genesis are placed so that the lower 32 KB of ROM and upper 32 KB of RAM can be addressed with short absolute addressing to make programs smaller and faster (4 fewer cycles on short absolute addressing).
If you wanted the address of the variable in the register, you'd do
lea variable,a2
lea variable.w,a2
lea variable.l,a2
movea.w #variable,a2
movea.l #variable,a2
Posted: Sun May 10, 2009 6:12 am
by powerofrecall
So basically with movea I have to reference it as an immediate, with lea I can reference directly?
The differing addressing modes on 68k confuse the hell out of me; I'm new to it. Sometimes I wonder if I should stick to C
As background I'm no asm guru on any CPU, the only ones I "get" are the most basic like 6502 mnemonics.
Posted: Sun May 10, 2009 8:35 am
by Chilly Willy
Sounds like you need to read the programmer's reference again.
http://www.freescale.com/files/archives ... 000PRM.pdf
You'll find an explanation of the addressing modes in section 2 (page 42). I highly recommend learning the 68000 assembly if you wish to program on the Genesis. If you just can't wrap your head around assembly, try Stef's mini DevKit. It lets you do the programming in C.
viewtopic.php?t=14
Or if you're more into BASIC, try BEX.
http://devster.proboards.com/index.cgi? ... asiegaxorz
Posted: Sun May 10, 2009 3:58 pm
by powerofrecall
Haha, thanks man for not making too much fun of me. I get how asm works and how memory-mapped hardware works in general (I used to hack around on GBA stuff), so I think I can learn. I went with easy68k because it has built in if/then/for macros for people like me.
I actually have Stef's kit and it is fantastic for just banging out stuff. Still, I'm wanting to do a "demo" style demo with raster effects and such and asm is actually cleaner than a bunch of goofy C pointer math

My inner nerd wants to understand it, too...
Posted: Sun May 10, 2009 7:20 pm
by Chilly Willy
Well, one thing you could do is write the code in C, then look at the assembly generated. That's how some people learn asm. Not me, but others.

Posted: Sun May 10, 2009 7:43 pm
by TmEE co.(TM)
such ASM does not look too good..... too much stack use too I believe

Posted: Mon May 11, 2009 12:08 am
by Chilly Willy
Among other issues, which is why I generally don't do that. I've only looked at c generated assembly when I wanted specific info about the ABI.