Page 1 of 1

( ) around absolute short addressing mode

Posted: Wed Aug 18, 2021 2:17 am
by Okie
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?

Re: ( ) around absolute short addressing mode

Posted: Wed Aug 18, 2021 3:55 pm
by Chilly Willy
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).

Re: ( ) around absolute short addressing mode

Posted: Wed Aug 18, 2021 4:52 pm
by Okie
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 .

Re: ( ) around absolute short addressing mode

Posted: Wed Aug 18, 2021 5:56 pm
by Chilly Willy
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.

Re: ( ) around absolute short addressing mode

Posted: Tue Aug 24, 2021 9:00 pm
by Okie
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?

Re: ( ) around absolute short addressing mode

Posted: Wed Aug 25, 2021 10:56 am
by HardWareMan
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

Re: ( ) around absolute short addressing mode

Posted: Mon Sep 20, 2021 6:30 pm
by Miquel
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)

Re: ( ) around absolute short addressing mode

Posted: Thu Sep 30, 2021 1:57 am
by Miquel
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.

Re: ( ) around absolute short addressing mode

Posted: Fri Nov 19, 2021 6:38 pm
by Okie
Thank you very much Miquel. Sorry for late reply been doing disassembly stuff on s3k. I will look at the response tonight. Thanks 😊