Pergunta

This is my first attempt at dpcu, I'm checking machine code generated by dpcu-16 assembly

I am using this emulator : http://dcpu.ru/

I am trying to compare code generated by

SET A, 0x1E
SET A, 0x1F

code generated is as follow :

fc01 
7c01 001f 

I don't get why operand size changes between those two values

Foi útil?

Solução

0x1F (dec:31) is no longer a short literal (values -1 to 30), so it has to be read as a "next word" argument.

The opcodes are thus:

SET A, 0x1E
SET =             00001
A   =        00000
1E  =  111111
op  =  1111110000000001 = fc01


SET A, 0x1F
SET =             00001
A   =        00000
NW  =  011111
op  =  0111110000000001 = 7c01 + 001f

Outras dicas

That emulator appears to be using the next version of the DCPU-16 spec, which specifies that the same-word literal value for a permits values from 0xFFFF (-1) to 0x1E (30). This means that to get any literal value outside this range the assembler has to use the next-word literal syntax, which makes the operand one byte bigger.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top