How to understand the first line of the DCPU-16 specs assembly example?
Asked Answered
S

2

9

I am trying to understand the specs, but fail to understand the first line of the example given:

SET A, 0x30              ; 7c01 0030

Here is what I understood from the specs:

  • the first word (7c01) fully defines the instruction
  • the operator is 0x1 which is the command SET a, b
  • b = 111100 = 0x3C (when I convert into Hex) = literal value 0x3C
  • a = 000000 = register A

So I understand the instruction as SET A, 0x3C

Can anyone advise where I go wrong?

Sheehan answered 5/4, 2012 at 12:31 Comment(2)
Where does b = 111100 come from? From my point of view b = 110000 = 0x30...Weeks
@Weeks Hum, now I have 0x7c01 = 0111110000000001 which gives me b=011111=1F ?!Reinhold
W
9

Ah ok from the comments I finally got my answer.

You are missing the "Values" section from the spec, there it says:

Values:
....
0x1f: next word (literal)

So we have:

0x7c01 = 0111110000000001

0001 = SET
000000 = register A
011111 = 1F -> next word -> [PC++]

Next word is 0x0030... voilà.

Weeks answered 5/4, 2012 at 13:2 Comment(0)
K
1

@cli_hlt is almost correct

dcpu documentation says:

In a basic instruction, the lower five bits of the first word of the instruction are the opcode, and the remaining eleven bits are split into a five bit value b and a six bit value a.

b is always handled by the processor after a, and is the lower five bits. In bits (in LSB-0 format), a basic instruction has the format: aaaaaabbbbbooooo

so the correct answer is:

0x7c01 = 0111110000000001

00001 = SET
00000 = register A
011111 = 1F -> next word -> [PC++]
Kranz answered 9/7, 2015 at 21:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.