views:

179

answers:

2

I'm implementing whole set of 8051 instructions in VHDL from scratch. Most of things went well but stumbled on these 2 instructions:

JB bit,rel
00100000 bit_address rel_address

CJNE A,#data,rel
10110100 immediate_data rel_address

Any help or hint is greatly appreciated. Thank you in advance!

+1  A: 

Maybe you could get some hints from http://www.cs.ucr.edu/~dalton/i8051/i8051syn/ ?

csl
Thanks for quick reply ;) I'm looking at it now :)
Viet
+2  A: 

The relative address is supplied by the programmer. This is typically computed by the assembler from labels.

Your asm file will contain:

   ...asm code
   ...asm code
   JB some_bit, some_label
   ...more asm code
   ...more asm code
   ...more asm code
some_label:
   ...more asm code
   ...more asm code

The assembler will analyse the code between the JB instruction and the label and compute the number of bytes of offset needed to get to the label, this is the number it feeds to the JB instruction.

Here is a good explanation of the 8051 instructions.

mocj
Thank you very much for help. I'm looking into it.
Viet