Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
ARM assembler register read
Jump...
Cancel
Locked
Locked
Replies
5 replies
Subscribers
118 subscribers
Views
7948 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
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
ARM assembler register read
Dennis Gabler
over 12 years ago
Note: This was originally posted on 11th September 2010 at
http://forums.arm.com
Hello All,
I need a quick example of how to place a value from a hardware register (0x70001234 for example) into a register such as R0
then compare it to a constant such as 0xE0680003 and do a branch based on equality.
So far I have had no luck getting something this simple to work.
Thanks,
Dennis
Parents
MARIO VISPERAS
over 12 years ago
Note: This was originally posted on 11th September 2010 at
http://forums.arm.com
[font="Courier New"]load_compare_RAM
; ldr r0, = 0xE0680003 ; constant to be compared with
ldr r0, [pc, #0x14] ; get the constant at [pc + 20d] = 0xE0680003
; ldr r1, = 0x70001234 ; RAM addr
ldr r1, [pc, #0x14] ; get the constant at [pc + 20d] = 0x70001234. This is the RAM addr
ldr r2, [r1, #0] ; offsset = 0. Read RAM
CMP r0, r2 ;
BEQ eq_cmp ; jump to next block if Z
neq_cmp
B next_block1
eq_cmp
B next_block2
DCD 0xE0680003 ; DCD = .word
DCD 0x70001234 ; DCD = .word
next_block1
; next block1 of codes here
next_block2
; next block2 of codes here[/font]
; #############################
; the 2 commented lines are the pseudo instructions. If you enable them, you do not
; need the line below each of them. In this case, you would also not need the 2 DCD lines.
;
; The active codes above are a manual way of creating a literal pool (of constants). If you use
; the pseudo-instr, you let the assembler do all the work for you.
;
; This web page removes all my nice spaces in the assembly codes and compresses them.
Cancel
Vote up
0
Vote down
Cancel
Reply
MARIO VISPERAS
over 12 years ago
Note: This was originally posted on 11th September 2010 at
http://forums.arm.com
[font="Courier New"]load_compare_RAM
; ldr r0, = 0xE0680003 ; constant to be compared with
ldr r0, [pc, #0x14] ; get the constant at [pc + 20d] = 0xE0680003
; ldr r1, = 0x70001234 ; RAM addr
ldr r1, [pc, #0x14] ; get the constant at [pc + 20d] = 0x70001234. This is the RAM addr
ldr r2, [r1, #0] ; offsset = 0. Read RAM
CMP r0, r2 ;
BEQ eq_cmp ; jump to next block if Z
neq_cmp
B next_block1
eq_cmp
B next_block2
DCD 0xE0680003 ; DCD = .word
DCD 0x70001234 ; DCD = .word
next_block1
; next block1 of codes here
next_block2
; next block2 of codes here[/font]
; #############################
; the 2 commented lines are the pseudo instructions. If you enable them, you do not
; need the line below each of them. In this case, you would also not need the 2 DCD lines.
;
; The active codes above are a manual way of creating a literal pool (of constants). If you use
; the pseudo-instr, you let the assembler do all the work for you.
;
; This web page removes all my nice spaces in the assembly codes and compresses them.
Cancel
Vote up
0
Vote down
Cancel
Children
No data