( ) around absolute short addressing mode

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Okie
Interested
Posts: 37
Joined: Wed Jun 30, 2021 7:31 pm
Location: United States Of America

( ) around absolute short addressing mode

Post by Okie » Wed Aug 18, 2021 2:17 am

So in Megadrive disassembles, they write move.b ($FFFFF600).w,d0 .
Why do they add parentheses around the address ( Screen Mode in case ); after all, we are not indirect referencing an address register. Is it really necessary to make it an absolute short addressing mode (XXX).w? I could swear the binary of this opcode is the sane without parenthesis (tested with snasm) . Or is it because Assemblers like Snasm allow periods in labels , so they want to declare explicitly that ".w" isn't part of the label. Is this some efficient way to save time for assembling so it doesn't have to scan right to left the .w to see that the .w mean s its a word or something?

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: ( ) around absolute short addressing mode

Post by Chilly Willy » Wed Aug 18, 2021 3:55 pm

There are a number of different syntax formats for the 680x0, depending on who did the original assembler. Most assemblers tend to stick with Motorola format, but you will see others. The parenthesis are standard for showing memory access. a0 and (a0) are not the same thing - (a0) means the memory pointed to by a0. Similarly, (abs).size is the memory pointed to by abs.size. You can do (abs).l (a long absolute address), or (abs).w (a word absolute address - the word is sign extended to a long before being used).

Okie
Interested
Posts: 37
Joined: Wed Jun 30, 2021 7:31 pm
Location: United States Of America

Re: ( ) around absolute short addressing mode

Post by Okie » Wed Aug 18, 2021 4:52 pm

I thought parenthesis for indirect referring is only for address registers .

if you are reffering to to an address like $FFFFFFFF , doesn’t the $ state that it is the value stored at the address $FFFFFFFF ?

Say A byte at $Ffffffff value is 0xF4

Code: Select all

Move.b $FFFFFFFF,D0
Wouldn’t this move the byte value at memory address $FFFFFFFF to do ... move 0xF4 to do

As opposed to $FFFFFFFF , would that be an immediate value?

Code: Select all

Move.b #$FFFFFFFF,D0 
Moves the Low byte of value #$FFFFFFFF TO DO SO DO = FF

Just wondering because if that was the case, the () wouldn’t be necessary but please tell me if I am wrong. I tested with snasm and without () seemed to still seemed to get the value at the address .

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: ( ) around absolute short addressing mode

Post by Chilly Willy » Wed Aug 18, 2021 5:56 pm

Most assemblers will treat ABS.x and (ABS).x the same, but some will throw an error for one or the other. Consult the docs for the assembler your using, especially if it allows setting the syntax used. It should tell you what variants are allowed and which are not.

Okie
Interested
Posts: 37
Joined: Wed Jun 30, 2021 7:31 pm
Location: United States Of America

Re: ( ) around absolute short addressing mode

Post by Okie » Tue Aug 24, 2021 9:00 pm

Thanks. So what I had been taught that a # indicated an immediate value , so $FFFF doesn't have a # in front so that is enough to indicate it is an address and not a hex value literally . Why is () necessary for some assemblers if not having a # denotes an address?

HardWareMan
Very interested
Posts: 745
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: ( ) around absolute short addressing mode

Post by HardWareMan » Wed Aug 25, 2021 10:56 am

Everyone should stick with official docs, specifically M68000 Family Programmer's Reference Manual. At the page 2-20 (61 in the PDF) there summary table of all available addressing modes.
Image

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: ( ) around absolute short addressing mode

Post by Miquel » Mon Sep 20, 2021 6:30 pm

The ($FFFFF600).w means to pack the value in a word (16 bits) instead of a long (32bits), which -depending on the compiler- it will do by default. It works because this cpu will always do sign extension while expanding address.

Edit: My mistake (thanks guardian angel)
HELP. Spanish TVs are brain washing people to be hostile to me.

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: ( ) around absolute short addressing mode

Post by Miquel » Thu Sep 30, 2021 1:57 am

ok, let's try it again, I think I read it to fast last time.
Okie wrote:
Wed Aug 18, 2021 4:52 pm
if you are reffering to to an address like $FFFFFFFF , doesn’t the $ state that it is the value stored at the address $FFFFFFFF ?
Not exactly, the '$' means exactly the same as "0x" on a C/C++ compiler, it just entails that the following number is in hexadecimal notation, nothing more.
Okie wrote:
Wed Aug 18, 2021 2:17 am
Why do they add parentheses around the address ( Screen Mode in case ); after all, we are not indirect referencing an address register.
By default all indirections in 68k go in between parentheses, no matter if is an immediate address or a register. Then most compilers allow to omit the parentheses in case of immediate address. Why? Perhaps because in older grammars that was the way, and habits are hard to change.
Okie wrote:
Wed Aug 18, 2021 2:17 am
Is it really necessary to make it an absolute short addressing mode (XXX).w?
No
Okie wrote:
Wed Aug 18, 2021 2:17 am
Or is it because Assemblers like Snasm allow periods in labels , so they want to declare explicitly that ".w" isn't part of the label. Is this some efficient way to save time for assembling so it doesn't have to scan right to left the .w to see that the .w mean s its a word or something?
No, you can write it as "move.b ($FFFFF600).w,d0" or "move.b ($FFFFF600.w),d0"; doesn't matter (again depending on the compiler).

MY OPINION: In fact the second way is more correct in case you want to expand the cpu grammar. Take for example a new instruction like:
move (0x1111.l,(0x4444.w,a1)), d0

Also "move 4(a0), d0", "move (4,a0), d0" and "move 2+4/2(a0), d0" are all valid and the same. The later is specially useful in case of parametrized macros.
Okie wrote:
Tue Aug 24, 2021 9:00 pm
Why is () necessary for some assemblers if not having a # denotes an address?
Imagine writing the instruction "move (a0,4),d0" without parentheses.
HELP. Spanish TVs are brain washing people to be hostile to me.

Okie
Interested
Posts: 37
Joined: Wed Jun 30, 2021 7:31 pm
Location: United States Of America

Re: ( ) around absolute short addressing mode

Post by Okie » Fri Nov 19, 2021 6:38 pm

Thank you very much Miquel. Sorry for late reply been doing disassembly stuff on s3k. I will look at the response tonight. Thanks 😊

Post Reply