Assembly Language Question

Discussion in 'Embedded Systems and Microcontrollers' started by gary1wang, Jan 29, 2012.

  1. gary1wang

    Thread Starter Member

    Sep 18, 2008
    23
    0
    Code ( (Unknown Language)):
    1.  
    2. AREA     bigger, CODE, READONLY
    3.             LDR pc, Reset_Addr
    4.             SPACE 0x1c
    5. Reset_Addr
    6.             DCD        Reset_Handler
    7.             SPACE 0xdc
    8.             ENTRY
    9.  
    10.             EXPORT Reset_Handler
    11. Reset_Handler
    12. mystart
    13.             LDR R1, Value1;    Load the first value to be compared
    14.             LDR R2, Value2; Load the second value to be compared
    15.             CMP R1, R2; Compare them
    16.             BHI Done; If R1 contains the highest
    17.             MOV R1, R2; Otherwise overwrite R1
    18. Done
    19.             STR R1, Result; Store the Result
    20. Stop B Stop
    21.  
    22. Value1 DCD 0x12345678; Vaule to be compared
    23. Value2 DCD 0x87654321; Value to be compared
    24.            
    25.  
    26.  
    27.             AREA Result, Data, READWRITE
    28.             SPACE 0x4c
    29.  
    30.             END
    31.  

    Guys, I am new on assembly language. i do not get Stop B Stop. I thought it just Stop b.
     
    Last edited by a moderator: Jan 29, 2012
  2. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    The first "Stop" is the label of the instruction. The assembler will convert the label "Stop" into an instruction address. The "B" is the operation code (OPCODE) for a branch instruction. The second occurrence of "Stop" is the destination of the branch which happens to be the very same instruction that was just executed.

    This construct represents an infinite loop of one instruction that branches to itself. It's usefulness depends on the context and whatever else may be going on.
     
Loading...