Writing the opcode of a command in hexadecimal form

Discussion in 'Homework Help' started by ambageo, Jan 9, 2012.

  1. ambageo

    Thread Starter New Member

    Dec 16, 2011
    4
    0
    Hi to all of you!
    I've been given a hypothetical 8-bit microprocessor whose instruction set is the following opcode format (8 or 16 bits)

    I_TYPE INST {1stparameter}{2ndparameter ADDR_MODE}{2ndparameter}

    I have to find the opcode of the instruction LDR R0,(R3) and write it in hexadecimal form
    Below are the codes that are relevant to the command.
    the LDR is a MOVE instruction and it has INST code 0. All MOVE instructions have an I_TYPE 00. Additionally, R0 has the code 00 and R3 has 11.
    Finally,I've been given that when in an indirect addressing (R), then the ADDR_MODE is code 100.
    So,from what I've understood so far, the opcode must be:

    I_TYPE INST {1stparameter}{2ndparameter ADDR_MODE}{2ndparameter}
    00 0 0 100 11
    so, the opcode in binary form will be 000010011. Am I right in that?
    If so,this opcode is 9 bits long,therefore it requires 2 bytes in order to be stored,right?
    The other thing is that I must give this opcode in hexadecimal form. What is the correct way of doing it? Should I convert the whole binary 000010011 to hex, or should I take the two different parts that are stored in different bytes and convert them separately?

    I'de be very grateful if someone could explain this to me, as it is the very first part of my exercise and I have to find 3 more opcodes like the one above (hopefully without having to ask for each one of them!)

    Thanks in advance!
     
  2. Dar89

    New Member

    Jan 9, 2012
    2
    0
    There is a little error in your opcode, the right is: 0000010011.To covert this in exadecimal you can divide the number in groups of 4,starting from right.Then you convert every group in exadecimal.So all zeros-0001-0011=>0-0-1-3 so the number in hexadecimal (on 2 bytes) is 0013.
     
  3. ambageo

    Thread Starter New Member

    Dec 16, 2011
    4
    0
    Yes,you're right about that, I forgot a zero, thank you! Apart from the binary-to-hex-conversion, is the way I'm dealing the rest of the exercise right?
     
Loading...