Determine opcode of instruction 8051

Thread Starter

antiantianti

Joined Aug 4, 2016
45
Hi
I was solving some homeworks and I need help to find the op code of this instructions I know it might not seem complicated for you and how can you need help to solve this but i am a beginner I literally dont know
first exmaple ADD A, R3 Opcode = 00101rrr = 00101011B=2BH (1-byte instruction) I foudn the same result ut I looked up a table . but why is this instruction a 1 byte instruction
(2) MOV P2, A Opcode=11110101 aaaaaaaa = F5H, A0H How did they find this result tried googling but in vain (2-byte instruction) and why is it a two byte instruction


Thanks a lot
 

JohnInTX

Joined Jun 26, 2012
3,796
It is because in the first case, ADD, the destination register is always A(ccumulator) and it is register to register so the entire operation is can be encoded in the first 5 bits of the opcode, leaving the other 3 to specify one of eight general purpose registers in the current bank.
In the second case, MOV can have several addressing options, register-to-register, immediate etc. It takes more bits to encode that. In this particular one case the instruction is MOV A,direct. It moves A(ccumulator) to one of 256 bytes in the direct addressing space, specified by the 2ed byte. A is always the source so it doesn't have to be encoded but you DO need the 2ed byte as the address of the destination. see pp 2-52 of the attached document.

Attached is the 8051 Programmer's Guide. All this is explained in detail in Chapter 2, starting on pp2-28
7.8MB file size.

Have fun.
BTW: it is helpful to specify the processor you are using when asking a question.
 

Attachments

Last edited:

shteii01

Joined Feb 19, 2010
4,667
1. Use punctuation to present information in meaningful manner.
2. Use spacing to present information in meaningful manner.
3. Program Counter (PC).
 
Top