22 April 2016, 00:03 | #1 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 63
|
68K assembler/disassembler syntax
What is that 68K assembler/disassembler syntax looking like exactly? My current disassembler supports 80x86-sytle addressing modes, and the official 68K addressing modes.
The problem is that nobody seems to be using that official syntax with expressions like "(imm,An)", or am I wrong there, and some people do use that syntax? If not, then I'll drop that syntax. More common seem to be expressions like "imm(An)" for 68000 code, but I've no idea what kind of expressions would be used for the extra addressing modes of the later 680xx revisions - could somebody complete the table below? Code:
Mode 80x86 68K/Official 68K/Common? 000rrr Dn Dn Dn 001rrr An An An 010rrr [An] (An) (An) 011rrr [An]+ (An)+ (An)+ 100rrr -[An] -(An) -(An) 101rrr [d16+An] (d16,An) d16(An) 110rrr [d8+An+Xn] (d8,An,Xn) ? 110rrr [bd+An+Xn] (bd,An,Xn) ? 110rrr [[bd+An+Xn]+od] ([bd,An,Xn],od) ? 110rrr [[bd+An]+Xn+od] ([bd,An],Xn,od) ? 111000 [xxx] (xxx).W ? 111001 [xxx] (xxx).L ? 111010 [addr] (d16,PC) d16(PC) 111011 [addr+Xn] (d8,PC,Xn) ? 111011 [addr+Xn] (bd,PC,Xn) ? 111011 [[addr+Xn]+od] ([bd,PC,Xn],od) ? 111011 [[addr]+Xn+od] ([bd,PC],Xn,od) ? 111100 xxx #<xxx> ? And, the Index can be 16bit, also without officially defined syntax. I guess the above example would then look as "Xn.w*4"? There seems to be also a MIT syntax (with percent-symbols preceeding all register names, like "%d0"), is there anybody using that syntax? Or are there more variants that should be supported in assemblers/disassemblers/debuggers? Oh, and are there any common pseudo opcodes, like PUSH/POP or whatever? I haven't looked into directives yet, only spotted something like "dc.b" here or there. Is there some document that lists the most imporant 68K assembler directives? |
22 April 2016, 01:53 | #2 | |||||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Quote:
(d8,An,Xn) or d8(An,Xn) (d8,PC,Xn) or d8(PC,Xn) Index register scaling did not exist on the 68000 but is generally accepted in old style syntax. Index registers and all the addressing modes should be documented in the 68000PRM. https://www.nxp.com/files/archives/d.../M68000PRM.pdf Quote:
Quote:
Quote:
http://sun.hasenbraten.de/vasm/release/vasm.pdf |
|||||
22 April 2016, 10:41 | #3 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 840
|
MIT syntax is not meant for human consumption...
|
22 April 2016, 11:07 | #4 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,343
|
Read various assembler manuals to see which directives they support. The "official" Amiga Macro Assembler was written by Metacomco and marketed by Commodore in the Amiga's early days, and many assemblers aim to be compatible with that.
|
22 April 2016, 12:49 | #5 | |||
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 63
|
Okay, I will avoid supporting MIT syntax.
There are old and new 68K syntaxes? I have a "M68000 8-/16-/32-Bit Microprocessors User’s Manual Ninth Edition" from 1993, it doesn't cover 68020 instructions, but the syntax looks the same as in documents that do cover newer instructions. But well, it's a "Ninth Edition", maybe older versions did use different syntax (?) Just guessing: "d16(An)" = old syntax ? (d16,An)" = new syntax ? Quote:
Oh, and I got that "(d16,PC) = d16(PC)" wrong. Official specs do actually say "(d16,PC)". But the more common form seems to be "addr(PC)", with "addr" being a 32bit address, and "(PC)" just hinting that it shall be encoded as relative address, with automatically calculated "d16" displacement. So, I am quite sure that assemblers would recognize this: addr(PC) But when enclosing everything in brackets, would an assembler treat it as... (addr,PC) or (d16,PC) ? Quote:
Quote:
|
|||
22 April 2016, 13:29 | #6 | |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 63
|
Quote:
Aside from directives it's also covering the "imm(An)" syntax. And, surprisingly, "addr(PC)" and "addr(PC,Xn) are just spelled as "addr" and "Addr(Xn)", which looks nicer, but might cause problems when needing to distinguish between absolute and relative addressing. Especially as absolute addresses "(addr).W" and "(addr).L" are just spelled as "addr", too. Hmmm, the MIT and vasm manuals also mention "ZDn" register operands (=for indicating not to use register Dn). Which is somewhere between nonsense & useful for knowing the exact opcode size/cycles. Last edited by nocash; 22 April 2016 at 19:48. |
|
22 April 2016, 17:43 | #7 | |||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Motorola used the old syntax during the 68000/68010 era and updated to the new syntax with the 68020 ISA. Some of the new 68020 addressing modes are less readable with the old syntax so most official documentation was updated. The M68000PRM (Programmer's Reference Manual) I linked to is from Motorola and official documentation. It describes in detail all the new addressing modes and uses the new style syntax. It is a good "newer" 68k reference but has some errors which were never corrected. Quote:
Quote:
The dc.<size> and ds.<size> are the most common directives. Section and CPU directives may be necessary also but a disassembler only uses a few directives. |
|||
22 April 2016, 21:17 | #8 | ||
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 63
|
Quote:
Quote:
At least, I've spotted it that way here: http://wandel.ca/homepage/execdis/exec_disassembly.txt (see the various places that contain "(PC)" as operand) - or is that some big exception, and nobody else uses that notation? Oh, or is one of the assembler directives allowing to select this or that notation? |
||
22 April 2016, 21:24 | #9 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,343
|
Assemblers convert label references to offsets automatically when PC-relative addressing is used.
|
22 April 2016, 21:58 | #10 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 63
|
Uh, but when is PC-relative addressing being used? Sorry, that question does probably sound stupid. But...
Does one just specify "label" or "(label)" and the assembler does automatically "know" if the address is relative addressable (ie. in cases where "label" is located within the same code segment)? That's about how it's described in the AmigaDOS manual. Or could/should one specify it as "label(PC)" or "(label,PC)" to indicate that relative addressing is wanted? That's how it's done in the exec_disassembly. Also spotted something similar here: http://eab.abime.net/showthread.php?t=75779 - "move.w _joy_tableX(PC,d0.w),_dx_joy" Last edited by nocash; 22 April 2016 at 22:10. |
22 April 2016, 22:22 | #11 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,343
|
Yes the programmer specifies for example
Code:
move.l (SomeValue,PC),D0 ... SomeValue: dc.l $12345678 |
22 April 2016, 22:54 | #12 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 63
|
Ah, great, then both variants are working (or working optionally, at least).
The "(SomeValue,PC)" was just what I meant when originally coming up with "(addr,PC)". Only thing that isn't completely clear to me is what happens if "SomeValue" is not a "label", but rather some absolute immediate address value. Like assigning it as "SomeValue EQU $FC05B4", and then using "(SomeValue,PC)" as opcode operand. Or right using "($FC05B4,PC)" as opcode operand. Not that it would make too much sense to use that kind of code... except maybe for assembling things like kernel patches, then it might be nice if the assembler would convert $FC05B4 into a PC-relative 16bit offset. |
22 April 2016, 23:11 | #13 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 840
|
You typically specify it as an absolute address(in reloc form unless you use the ORG directive) or label
Code:
move.l SOMEVAR,d0 Motorola had some misplaced ideas about code re-use and non-self modifying that made them only let you do reads in pc mode. Now, that matches unix type code segments that are read-only so it is not the worst of ideas, but you could have envisioned a segment with read-only parts and read-write parts. And during the design in pre-1979 not only did it not have an MMU, the world wasn't all unix either. Last edited by NorthWay; 23 April 2016 at 19:58. Reason: Typo |
23 April 2016, 00:35 | #14 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
|
Any Assembler worth its salt will assume you're not an ass and assemble exactly what you write.
This cheat sheet contains tables adapted from my Motorola 68000 Programmer's Manual, with EAs and cycle times. They will fill in the fields marked "?" in your table. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Disassembler | copse | Coders. General | 86 | 01 January 2023 20:34 |
CAPE 68k assembler | videofx | request.Apps | 1 | 17 May 2014 14:42 |
Looking for ArtOfNoise Playroutine (68k assembler) | Herpes | Coders. Asm / Hardware | 5 | 05 September 2012 00:10 |
VBCC assembler linking syntax? | NovaCoder | Coders. General | 2 | 20 May 2011 03:04 |
A good 68K disassembler | TikTok | request.Apps | 11 | 23 January 2002 03:49 |
|
|