Silly 68k question
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 237
- Joined: Fri Apr 17, 2009 7:35 pm
- Location: USA
Silly 68k question
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."
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."
my album - last thursday died last week
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
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
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
-
- Very interested
- Posts: 237
- Joined: Fri Apr 17, 2009 7:35 pm
- Location: USA
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.
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.
my album - last thursday died last week
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
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
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
-
- Very interested
- Posts: 237
- Joined: Fri Apr 17, 2009 7:35 pm
- Location: USA
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...
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...
my album - last thursday died last week
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
such ASM does not look too good..... too much stack use too I believe
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm