# Decoding instructions 8051

#### wave12

Joined Nov 29, 2021
14
Hi, I have a question about 8051
I have an instruction which at adress 0020H and codded as 80F0H
what would be the value of PC?
i don't understand how can i decode it

#### Papabravo

Joined Feb 24, 2006
18,431
Hi, I have a question about 8051
I have an instruction which at adress 0020H and codded as 80F0H
what would be the value of PC?
i don't understand how can i decode it
You need to establish which of two possible orderings a 16-bit word can be placed in a byte addressable memory. It has been too long since I had a need to know this, and I cannot remember which way it went. Other members of the Intel family put the least significant byte of a word in the lowest address. After the instruction is fetched, the PC will be at address 00022H.

#### GetDeviceInfo

Joined Jun 7, 2009
2,095
because you are within the interrupt vectors table, it really depends on the instruction at the entry point of the interrupt.

#### MrChips

Joined Oct 2, 2009
26,124
The interrupt vector table begins a 0000H.
Address 0000H is a 3-byte entry which normally would be a LJMP instruction.

Assuming that you are not using the rest of the table for interrupts, the instruction
80 F0 = SJMP F0

Since SJMP is a relative jump, it would be executed as SJMP (PC + 2 - 16)
Since PC = 0020H = 32
PC will become 0012H

#### wave12

Joined Nov 29, 2021
14
Thank you so much all for the explanation !

#### wave12

Joined Nov 29, 2021
14
The interrupt vector table begins a 0000H.
Address 0000H is a 3-byte entry which normally would be a LJMP instruction.

Assuming that you are not using the rest of the table for interrupts, the instruction
80 F0 = SJMP F0

Since SJMP is a relative jump, it would be executed as SJMP (PC + 2 - 16)
Since PC = 0020H = 32
PC will become 0012H
Can you please explain from where did you find 16?

#### MrChips

Joined Oct 2, 2009
26,124
It is not 16. It is -16.
The instruction opcode is 80 F0.
80 is the opcode for SJMP, meaning Short Jump.
F0 is the 8-bit relative address. This is encoded in an 8-bit signed integer having values from -128 to plus 127.
7F = 127
7E = 126
:
01 = 1
00 = 0
FF = -1
FE = -2
:
F0 = -16
:
81 = -127
80 = -128

• absf and wave12