decoder for 8051

Status
Not open for further replies.

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
You have listed the specifications for the 8051 but I don't think you understand it very well.

You need hands-on experience with an actual 8051 device. Re-read post #29. I notice you didn't "like" it. Do you have a problem with learning by experimenting with a real device? I promise you, it is the best way to get a solid understanding. I don't think you have a solid understanding yet, despite the months you have spent working at it. You could have been months ahead in your understanding if you had just done some experimentation. You get immediate feedback on whether you got it right or not, and you can examine the code generated by the assembler.

If you won't use a real 8051 for some reason, you can use a simulator.

Do what I suggested in post #29. You will save yourself months of wasted time.
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,968
Joined
Jun 21, 2012
Messages
4,968
Learning how computers work by only reading a computer-theory book is like learning how to bake a cake by only reading recipes from a cookbook. It just doesn't work that way. Hands-on practical experience as you accumulate a sound grounding in theory, is the ONLY tried-and-true learning experience. That is why science courses have laboratory as well as lecture sessions.

Do yourself a favor and do the lab work. Or is it your opinion that such labor is somehow inappropriate? Or do you not have access to a laboratory for your studies? Quit trying to learn it all from books and "go let the smoke out" of some real world components, even if you have to purchase the parts yourself and experiment at home. In fact, I strongly recommend experimenting at home. There was never enough time in a formal school laboratory session for me to get anything interesting accomplished. Buy or build a logic probe with pulse-sensing capability and use it every day.

Well, that's just my opinion, but it is backed up by more than sixty years of hands-on experience as well as a formal education.
(/END RANT)
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
You have listed the specifications for the 8051 but I don't think you understand it very well.

You need hands-on experience with an actual 8051 device. Re-read post #29. I notice you didn't "like" it. Do you have a problem with learning by experimenting with a real device? I promise you, it is the best way to get a solid understanding. I don't think you have a solid understanding yet, despite the months you have spent working at it. You could have been months ahead in your understanding if you had just done some experimentation. You get immediate feedback on whether you got it right or not, and you can examine the code generated by the assembler.

If you won't use a real 8051 for some reason, you can use a simulator.

Do what I suggested in post #29. You will save yourself months of wasted time.
as you said I followed your opinion. I already wrote some code for LED, motor , switches
look this post https://www.electronicspoint.com/threads/led-blinking-with-switch.270342/#post-1622878
https://www.electronicspoint.com/threads/blink-led.270332/#post-1622755
https://www.electronicspoint.com/threads/machine-language-to-assembly-language.269930/#post-1620224

now I don't want create alu for 8051
I want to learn basic

Code:
c c c c  t t  s s s s  t t  d d d d
0 0 0 1  0 0  0 1 1 0  0 0  0 0 1 1  move #6,R3
KrisBlueNZ: That's right. Source is immediate 6,
and destination is register 3.

Q how we design ALU from instruction set ?
my answer - If the data is 4 bit then we can use 4 bit alu
according to this instruction set we are dealing with 4 bit data so I think I have to use 4 bit alu
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
And did you get any of them working?

Have you looked at the assembler output and matched the instructions to the instruction set documentation? Do you understand what the CPU core is doing at each step of the code?

Have you tried changing the code to do new things?

Have you tried all the other instructions?
Q how we design ALU from instruction set ?
my answer - If the data is 4 bit then we can use 4 bit alu
according to this instruction set we are dealing with 4 bit data so I think I have to use 4 bit alu
You are trying to jump the gun again. You need to understand the 8051 and other processors more thoroughly before you will be ready to start designing your own core!
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
And did you get any of them working?

Have you looked at the assembler output and matched the instructions to the instruction set documentation? Do you understand what the CPU core is doing at each step of the code?

Have you tried changing the code to do new things?

Have you tried all the other instructions?
as you suggest me I read about 8051 instruction set

8051 has 8 bit Instruction set, 4 bit for opcde and 4 bit for operand
I don’t understand how to specifiy addressing mode, soure , and destination for 8051 ?

I have done few changes in instruction that I have posted
Instruction word size is 24 bit

4 bit opcode + address of source + 8 bit source +address of destination + 8 bit destination

Addressing mode

00 immediate addressing mode

01 register addressing mode

10 direct addressing mode

11 indirect addressing mode

Source specification

00 x x x x x x x x immediate addressing mode

01 x x x x x x x x register addressing mode

10 x x x x x x x x direct addressing mode

11 x x x x x x x x indirect addressing mode

Destination specification

00 x x x x x x x x immediate addressing mode

01 x x x x x x x x register addressing mode

10 x x x x x x x x direct addressing mode

11 x x x x x x x x indirect addressing mode

Example of mov opcode using Immediate , register and direct addressing mode

mov A,#3 immediate addressing mode
mov R1,#5 immediate addressing mode
mov A,(9) register addressing mode
mov R1(9) register addressing mode
mov A, R1 direct addresing mode
mov R1,A direct addressing mode
mov @ R1,A indirect addressing
Mov @ A, R1 indirect addressing
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
mov A,#3 immediate addressing mode

That is not a sufficient example.

Show us the entire instruction in binary and describe the elements of it
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
That is not a sufficient example.

Show us the entire instruction in binary and describe the elements of it
ok look the following zip file and tell me whats wrong with this code
 

Attachments

  • Instruction word structur1.zip
    10.6 KB · Views: 90

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
OK, so as per your document, the instruction

move R3 #6 (load immediate data 6 to R3 register)

is encoded as

c c c c t t s s s s t t d d d d
0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1
Source is immediate 6,
destination is register 3
Immediate addressing mode

Now tell me:

1) how long is an instruction word?
2) how many words in length is this instruction?
3) are some instructions longer or shorter?
4) what does the above imply for the PC during the fetching of the instruction?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
That's not for the 8051 though? According to what I've read, the first 5 bits are the instruction, the next three are the destination register.

It looks like everything you've written from post 43 onwards is wrong. Please show me your source for this information.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Start from here. (And please don't make stuff up. It really annoys me when you waste my time)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
MOV R3, #6

is {01111} {011} {00000110} <-- that's what it is really.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Ok look my another effort
I think It should be correct
 

Attachments

  • file.zip
    13.8 KB · Views: 175

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
It looks like you've simply copied the contents of the web site I pointed you at.

Please show you understand by encoding a few instructions yourself.

Perhaps you can tell me about the number of bits used to define the register used in various mov instructions and why it differs.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
It looks like you've simply copied the contents of the web site I pointed you at.

Please show you understand by encoding a few instructions yourself.

Perhaps you can tell me about the number of bits used to define the register used in various mov instructions and why it differs.
Ok look following file 2
 

Attachments

  • file2.zip
    14.4 KB · Views: 78

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Vead. STOP JUST COPYING THE WEBSITE.

Do some work for yourself.

And by the way, that's the last zip file I download. Type it in the message.

Now, answer the question:

Please show you understand by encoding a few instructions yourself.

Perhaps you can tell me about the number of bits used to define the register used in various mov instructions and why it differs.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Vead. STOP JUST COPYING THE WEBSITE.

Do some work for yourself.

And by the way, that's the last zip file I download. Type it in the message.

Now, answer the question:
5+3= 8 bit mov with registers Rn
7+1=8 bit mov with internal data RAM
8+0=8 bit mov with accumulator


we are using Mov instruction with Register R0-R7
MOV A, Rn
MOV Rn, #immediate
MOV Rn, direct
MOV direct, Rn
MOV Rn, A



7+1=8 bit 1 bit specify destination
MOV @Ri, A
MOV @Ri, direct
MOV A, @Ri
MOV direct, @Ri

we are using An internal data RAM location (0-255) addressed indirectly through R0 or R1.

8+0 = 8 bit
MOV A, #immediate
MOV A, direct
MOV direct, A


we are using mov instruction with A accumulator
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,968
Joined
Jun 21, 2012
Messages
4,968
Okay. Let's reset this thread to the beginning:
can anyone tell me which decoder is used for 8051 microcontroller ?
This microcontroller uses an 8-bit (one byte) operational code (op code) that allows for 256 separate instructions. Of this number, 255 are actually defined op codes. For each of the defined op codes, none, one, or two additional bytes are required to form a complete instruction. Each instruction is fetched from program memory at consecutive addresses, starting at an address stored in the program counter. The first byte fetched is the op code. This is "decoded" by an "8-bit decoder" that is actually an address in a read-only-memory (ROM). The data at that address are microcoded instructions that determine how a state machine behaves. The state machine, synchronized by the microprocessor clock, fetches whatever additional bytes are necessary to complete the instruction, increments the program counter for the next instruction, and sets up data paths to registers, accumulator, memory, ALU, program status register, and input/output ports as needed to execute the current instruction.

There is NO decoder, per se, that is used to read an op code! The 8051 is a state machine controlled by microcode.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
OK, now you're placing your answer in the thread that's better. If you can try to answer the question it would be even betterer!

Please show you understand by encoding a few instructions yourself.

Perhaps you can tell me about the number of bits used to define the register used in various mov instructions and why it differs.

why not encode MOV R4, #5 and MOV R3, A, and MOV A, @R1?
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
OK, now you're placing your answer in the thread that's better. If you can try to answer the question it would be even betterer!



why not encode MOV R4, #5 and MOV R3, A, and MOV A, @R1?
For the mov instruction there is no need to arithmetic and logic unit . we can simply store data into respective registers
data can be directly store into memory or registers
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Okay. Let's reset this thread to the beginning:

This microcontroller uses an 8-bit (one byte) operational code (op code) that allows for 256 separate instructions. Of this number, 255 are actually defined op codes. For each of the defined op codes, none, two, or three bytes
I think first I have to use ALU then I interface decoder with alu
I am explaining my work for ALU

ALU 8 bit
source , destination
source 1 8 bit
source 2 8 bit
destination 8 bit
alu carry
operation code from decoder

so we know the source of ALU
data from accumulator
data from ram memory
data from register

how does alu source 1 know that It need to store the value of accumulator , register or memory ?
 
Status
Not open for further replies.
Top