Connect with us

decoder for 8051

Discussion in 'General Electronics Discussion' started by vead, Oct 23, 2014.

Thread Status:
Not open for further replies.
Scroll to continue with content
  1. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    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.
     
    vead and hevans1944 like this.
  2. hevans1944

    hevans1944 Hop - AC8NS

    4,606
    2,151
    Jun 21, 2012
    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)
     
    Allen Bong, vead and KrisBlueNZ like this.
  3. vead

    vead

    473
    14
    Nov 27, 2011
    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: Nov 14, 2014
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    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?
    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 likes this.
  5. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    That is not a sufficient example.

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

    vead

    473
    14
    Nov 27, 2011
    ok look the following zip file and tell me whats wrong with this code
     

    Attached Files:

  8. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    OK, so as per your document, the instruction

    is encoded as

    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?
     
  9. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    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.
     
  10. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    Start from here. (And please don't make stuff up. It really annoys me when you waste my time)
     
  11. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    MOV R3, #6

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

    vead

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

    Attached Files:

    • file.zip
      File size:
      13.8 KB
      Views:
      175
  13. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    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.
     
  14. vead

    vead

    473
    14
    Nov 27, 2011
    Ok look following file 2
     

    Attached Files:

  15. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    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:

     
  16. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  17. hevans1944

    hevans1944 Hop - AC8NS

    4,606
    2,151
    Jun 21, 2012
    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, 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: Nov 19, 2014
    vead likes this.
  18. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    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?
     
  19. vead

    vead

    473
    14
    Nov 27, 2011
    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
     
  20. vead

    vead

    473
    14
    Nov 27, 2011
    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 ?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Thread Status:
Not open for further replies.
Electronics Point Logo
Continue to site
Quote of the day

-