This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Has there a easy way that I can say it's one byte length(16 bits) or two bytes length(32 bits) instruction if I only checked the first byte(16 bits)?

Hi, everyone

   Is there have a instruction pattern in c28x family ? Cos I want to predicate how long the next instruction is.  For example, if I got

   first byte of instruction looks like 1010 1011 1000 0001, can I just know whether it's complete or still have 1 byte followed?

   Thanks for any advise

  • Zheng,

    I don't believe there is any easy way to determine the op-code length.  There is no bit in the op-code that specifies 16 or 32 bits.  I don't think there is even a discernible pattern.  For example:

             INTR NMI (16 bits): 0111 0110 0001 0110

    AND IER, #IERMASK (32 bits): 0111 0110 0010 0110 + CCCC CCCC CCCC CCCC

               ESTOP1 (16 bits): 0111 0110 0010 0100

    Looking at the first two instructions above, you'd try to differentiate between them using bits 5:4 of the MSW.  But this fails when you bring in the last instructions where bits 5:4 of the MSW match those of the second instruction.  Bottom line: no easy way to tell the instruction length.  You'd need to make a table of op-codes and then do a table lookup.  However, note that you just need to look up the MSW in the table.  The LSW does not contain information pertaining to the length.

    Regards,

    David

  • Thanks David, looks like I  do need the op-code table thing. By the way Do you know where can I get such table or something easy to copy & paste ? You know just  record all of them from the manual one by one is a real typing work.

  • Zheng,

    I've never seen a listing of the op-codes.  I think you will have to manually pull them out of the user's guide.  It's not as straightforward as just making a list because the critical bits in the op-code vary.  The rest of the op-code is a memory address, register specifier, etc.

    I wonder why you care about this.  I mean, what difference does it make whether the next instruction is 1 or 2 words long in your execution path?  You're going to burn up a lot of cycles figuring out that length, and I don't see what good the information is anyway.  What's the motivation here?

    Regards,

    David

  • David,
    I'm porting c28x to gdb. In the disassembling part, I think it's need to know the instruction length. there's a function under opcodes that looks like: int print_insn_tic28x (bfd_vma pc, disassemble_info *info), and returns the instruction length.
    Regards,
    Che