This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

help about opcode

hello
i have an opcode of BNE branch which is 1AFFFFF9 and i want to know to which address go this branch i mean how i know what is the next address executed

Parents
  • You want to know what address the jump will jump to, don't you?

    You have found that the FFFFF9 is an offset.

    You know that an offset is applied to some "base" address to give a resulting address - how do you think that would be applied in the case of this branch instruction...?

    It's time for you to do some thinking, rather than just wait for answers to be handed to you on a plate.

Reply
  • You want to know what address the jump will jump to, don't you?

    You have found that the FFFFF9 is an offset.

    You know that an offset is applied to some "base" address to give a resulting address - how do you think that would be applied in the case of this branch instruction...?

    It's time for you to do some thinking, rather than just wait for answers to be handed to you on a plate.

Children
  • do you mean how reach to the target address it is my quetion an i get the answer in the forum which you refer to it

    Target Address = PC + 8 words(offset)

  • i want to ask you andy
    look at this assembly code

    IF (a == b) AND (c == d)
    THEN e = e + 1;
    -------------
    CMP r0,r1 Compare a and b
    CMPEQ r2,r3 If a == b THEN compare c and d
    ADDEQ r4,r4,#1 if c == d then increment e by 1

    The next instruction, CMPEQ r2,r3,performs a comparison only if the result of the first line was true how the processor linked the first and the second and the third instruction with each other!

  • You really need to look a the instruction set a little more.
    Where is the EQ status bit set?
    The second line says compare R2,R3 AND the EQ status bit.
    The same with the third line. Add only if the EQ bit is 1.
    Remember, almost all insructions in the ARM can be conditional.
    Bradford

  • insructions--insructions-- instructions.
    Wish I could type.
    Bradford

  • thank you Bradford for your help

    that's mean before the execution of The second instructon it must check the first instruction CMP r0,r1 (instruction set).

    but up till now i don't understand the relation between the first and the second instruction can you give me an example

  • What do you mean by "relation" here?

    As far as the CPU is concerned, it just executes instructions in order (until changed by some kind of branch or interrupt) - so there is no "relation" between instructions other than the order in which they appear in memory.

    Unless you're thinking of some other meaning of "relation" here?

    The order in which instructions appear in memory is determined by the programmer as the order needed to achieve the purpose of the program.

    In the case of a High-Level Language (HLL), the compiler will synthesise the high-level operations with an appropriate sequence of low-level (machine) instructions.

    Does that answer your question?
    If not, you need to explain the question more clearly...

  • A number of processors have support for conditional processing of instructions. That means that when they reach the instruction (in this case the second instruction), it checks a processor flag to decide if it should process the instruction or treat it as a NOP instruction and continue to the third instruction.

    The second instruction in this case is only performing a comparison if the first instruction found a match.

    The third instruction is also conditional. So it will only perform an ADD if the previous two instructions both compared equal. So the add only happens if instr1 arg1 == arg2 and instr2 arg1 == arg2.

    If instruction 2 sees a difference, then both second and third instructions will be treated as "NOP" instructions. If first instruction matches, and second instruction sees a mismatch, then the third instruction will be treated as a "NOP".

    So the only relation involved is that the conditional instructions will be processed or not, based on the result of previous instructions.

  • Indeed.

    But note that the decision to execute or not relies only on the flags - there is no relation between the instructions themselves.

    In other words, it doesn't matter what instruction set the flags; it's only the state of the flags that matters.

    I hope the distinction is not too subtle that it gets lost in translation...

  • thank you very much for your help