Assembly Language Question

Thread Starter

gary1wang

Joined Sep 18, 2008
23
Rich (BB code):
AREA     bigger, CODE, READONLY
            LDR pc, Reset_Addr
            SPACE 0x1c
Reset_Addr 
            DCD        Reset_Handler
            SPACE 0xdc
            ENTRY

            EXPORT Reset_Handler
Reset_Handler
mystart
            LDR R1, Value1;    Load the first value to be compared
            LDR R2, Value2; Load the second value to be compared
            CMP R1, R2; Compare them
            BHI Done; If R1 contains the highest
            MOV R1, R2; Otherwise overwrite R1
Done
            STR R1, Result; Store the Result
Stop B Stop

Value1 DCD 0x12345678; Vaule to be compared
Value2 DCD 0x87654321; Value to be compared
           


            AREA Result, Data, READWRITE
            SPACE 0x4c

            END

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:

Papabravo

Joined Feb 24, 2006
21,225
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.
 
Top