Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 783
Timothée HENRY Avatar asked Apr 05 '12 12:04

Timothée HENRY


2 Answers

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à.

like image 138
cli_hlt Avatar answered Nov 11 '22 22:11

cli_hlt


@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++]
like image 45
debris Avatar answered Nov 11 '22 21:11

debris