[solved] Help what 68000 instruction is that OoCode  - Page 1
Forum section: electronics / general

author: pelule
author_rank: Frequent Contributor
timestamp: April 02, 2017, 09:31:46 pm
content: I am working an analysing a 68k firmware and become confused regarding which instruction is the following opcode:The following opcode---ADR----- ---OPCODE---000007A8 2E78 0000000007AC 2C78 0004give following disassembler and assembler outputsES-1800 in-circuit emulator:000007A8 2E78 0000 MOVE.L $0,A7000007AC 2C78 0004 MOVE.L $4,A6dis68k program:000007A8 2E78 0000 MOVEA.L $0,A7000007AC 2C78 0004 MOVEA.L $4,A6The ONDA online disassembler:000007a8 2e 78 00 00 moveal 0x00000000,%sp000007ac 2c 78 00 04 moveal 0x00000004,%fpThe masm68k generates the following:0007A8 2E79 0000 0000 MOVE.L $0,A7 ; assembler output0007A8 2E79 0000 0000 MOVEA.L $0,A7 ; assembler output0007AC 2C79 0000 0004 MOVE.L $4,A6 ; assembler output0007AC 2C79 0000 0004 MOVEA.L $4,A6 ; assembler outputLink to 68k Programmers Reference:http://www.nxp.com/files/archives/doc/ref_manual/M68000PRM.pdfBoth, the 68k Programmers Reference and the 68k Opcode Table are not helping.Any experiance 68k fellow out there, ablle to help?/PeLuLe

author: rstofer
author_rank: Super Contributor
timestamp: April 02, 2017, 10:42:36 pm
content: 2E78 is a MOVE LONG IMMEDIATE Absolute Short 0 -> Address Register 7Break down the instruction like it's shown in the map (starting from the high order bit)00 10 111 001 111 000 - 0x2E7800 -> MOVE10 -> LONG111 -> Register 7 is the destination001 -> Address Register - so A7111 -> IMMEDIATE000 -> Absolute Shortfollowed by the constant 0x0000http://www.scarpaz.com/Attic/Didattica/Scarpazza-2005-68k-1-addressing.pdf

author: helius
author_rank: Super Contributor
timestamp: April 02, 2017, 11:21:18 pm
content: The Motorola standard assembly code would beMOVEA.L #0,A7. The 68000 makes the distinction between "data writeable" and "address writeable" operands, because "data" writes update the condition codes, and "address" writes do not. Typically, each instruction can update either address registers or data, but not both (there are a few exceptions to this rule, like ADDQ and SUBQ). Moving a word into an address register requires a MOVEA instruction; with the .L size field, it affects all 32 bits of the destination A register. (The .W size field would only affect the lower 16 bits.)You will see different syntax and mnemonics with different assembler tools since they follow different conventions. Besides Motorola, the Intel and AT&T conventions were also widespread, and the portability of software like Unix meant that they were adapted for the 68000. Another thing to keep in mind is that assemblers include "pseudo-opcodes": mnemonics that are not translated literally into machine language, but expand into sequences of other instructions, possibly conditionally. Many assemblers would automatically amendMOVE.L #0,A6toMOVEA.L #0,A6because address registers always require MOVEA and this is a simple substitution that shouldn't cause an error.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: April 03, 2017, 04:35:40 am
content: Quote from: pelule on April 02, 2017, 09:31:46 pmAccording to my disassembler, this is:-Code:MOVE.L $0004.W, A6The '.W' is necessary to distinguish between Word and Long immediate operands. This syntax is accepted by Hisoft Devpac. I don't know about masm68k (never heard of it and Google isn't helping).

author: pelule
author_rank: Frequent Contributor
timestamp: April 03, 2017, 06:07:47 pm
content: Many thanks for the great help - both instruction work:000007A8 2E78 0000 MOVE.L $0000.W, A7000007AC 2C78 0004 MOVE.L $0004.W, A6The masm68k generates the correct code..It is the Motorola MSDOS running 68000 makro cross-assembler V2.53 from 1989 (supporting 68000/68010/680020))The Motorola Programmer Reference is not that clear on that instruction option.I checked the reference table before. It leads to the MOVEA instruction, but the .W immediate adress option is not mentioned.I sadly remember the great Philips documentation for the MCS-51 family. Not just listed all possible combination but also showed suitable examples.

author: ale500
author_rank: Frequent Contributor
timestamp: April 03, 2017, 06:42:13 pm
content: QuoteIt is not an immediate operand but a word address, mode is 111 and register 000. Absolute short addressing mode: it loads from that sign-extended address.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: April 04, 2017, 04:51:39 am
content: Quote from: ale500 on April 03, 2017, 06:42:13 pmYou're right! (immediate would have a '#' in front of the number). It's been a while since I programmed the 68000 and it's hard to remember all the variations between different CPUs!So I cranked up the old Amiga 1200 and amazingly it still goes. Browsed through the assembler source I wrote in 1997, and it was like looking at someone else's code. Might get back into it if I can think of a goodexcusereason... after finishing this Z80 project I am working on.