Question

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!

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top