Yesterday, 11:58 | #1 |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 274
|
Disassembling/executing instructions with unused bits
How does the 68000 decode instructions with unused bits? Is this well-defined or undefined behaviour?
For example ORI.B $#ff,D1assembles to two words: 0001 00FF. The upper byte in the second word is not required to define the byte-sized instruction. What should happen if the CPU/disassembler/emulator encounters non-zero bits in there? For example: 0001 FFFF. Will the $ff00 bits in the second word simply be ignored (by the spec), or will the decoder class this as an illegal instruction. Sorry if this is in the manual - I couldn't find any information on it. Last edited by hop; Yesterday at 11:59. Reason: Clarity |
Yesterday, 13:54 | #2 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,271
|
The unused bits are just ignored (by all M68K versions), same with 000/010 and the previously unused bits in the extension word (scale/full extension word bit). The latter is at least documented (68000PRM 2.4).
An emulator should obviously behave the same way or it will fail on actual code. A good disassembler will reproduce the original instruction, i.e. preserve the unused bits. Otherwise you can't reassemble the same binary. Maybe via a dc.w sequence if the original instruction can't be accurately re-used in context (e.g. for the extension word thing) |
Yesterday, 14:48 | #3 |
Registered User
Join Date: Apr 2021
Location: Sydney
Posts: 8
|
You'd have to tell a disassembler which cpu the code was intended for, else it won't know the right thing to do with bits that are undefined on 68000 and used for something new on the 68020 or later.
|
Yesterday, 20:42 | #4 |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 274
|
Thanks for the great advice. The reassembly is just what caught me out.
|
Today, 08:51 | #5 |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 274
|
A solution might be to ensure that the disassembler disassembles
0001 1234to ORI.B #$1234,D1and the assembler assembles this back to 0001 1234. This avoids DCdirectives which obfuscate how the CPU would decode the machine code. |
Today, 12:03 | #6 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,871
|
Is this instructions or data’s that the disassembler set as instructions ? Sometimes its not code and should be set as dc.x
|
Currently Active Users Viewing This Thread: 4 (3 members and 1 guests) | |
aros-sg, Minuous, phx |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bug? Black Unused Display | Zilog | support.WinUAE | 4 | 28 October 2020 21:11 |
HDD: Wipe (Zero) unused Blocks | bladecgn | support.Apps | 7 | 01 November 2018 16:01 |
Error when executing PGA Europe | 1time | project.WHDLoad | 1 | 25 March 2010 18:57 |
Selling some unused parts | McVenco | MarketPlace | 3 | 18 October 2008 15:16 |
Unused Connectors/Ports | BippyM | support.Hardware | 16 | 26 July 2006 13:56 |
|
|