0

I have produced a dump of 32-bit instructions in hex from an assembler I implemented. A subset of the instruction dump is show below:

enter image description here

The opcodes for the instructions are of lengths 4, 7, 8, 9, and 11. They are always the first bits in the instruction. I'm having trouble understanding how I would decode the instructions if the opcodes are of different lengths?

For example: When I read a single instruction, how would I know how many bits I should read for the opcode?

Here is an image of the instruction formats: format

Thank you

Anviori
  • 15
  • 8
  • How can we know? I assume there is a logic in the opcodes, otherwise no processor can decode them. Maybe if he first 3 bits are 111, the length is 7 and so on. But with the information that you give, it is impossible to give you any advice. – Alain Merigot Apr 08 '19 at 04:35
  • The rest of the fields in the instructions are all operands or immediate's. There is no additional information in the instruction other than the opcode. I've added a picture of the instruction formats. – Anviori Apr 08 '19 at 06:43
  • You must look at the instruction description. For instance, with a rapid scan of the sony document, I noticed that all 10 bits opcode instruction start with 001. There is probably a similar logic for other instructions. – Alain Merigot Apr 08 '19 at 07:06
  • Yes, I've tried to find a pattern like that. Since the smallest opcode is 4 bits, there must be a pattern within the first 4 bits of each instruction; but there isn't (that I can see). Some instructions (of different opcode lengths) have the same first 4 bits. – Anviori Apr 08 '19 at 07:39
  • There **is** a logic. Otherwise the processor is unable decode instructions. Try to find the minimum pattern length that can determine pattern size and use a look up table. – Alain Merigot Apr 08 '19 at 07:48
  • I figured it out, I posted the answer. Thanks for your help. – Anviori Apr 08 '19 at 09:00

1 Answers1

0

I figured it out. I read the maximum number of opcode bits (11) for all instructions, and ignore the bits that don't make sense (i.e the bits that wouldn't result in a possible opcode).

Anviori
  • 15
  • 8