Discussion:
ARM assembly instruction
(too old to reply)
b***@googlemail.com
2006-12-27 00:51:12 UTC
Permalink
I am facing some difficulty understanding the ARM assembler
instrucitons :
1. What does the following snippet means ? Especially the add r0,
pc,#-(8+.-StackData) . Is " . " and "pc " different ?
add r0, pc,#-(8+.-StackData) @ @ where to read values (relative)
ldmia r0, {r1-r6}
StackData:
.word AT91_SVC_Stack_Begin
.word AT91_IRQ_Stack_Begin
.word AT91_FIQ_Stack_Begin
.word AT91_ABT_Stack_Begin
.word AT91_UND_Stack_Begin
.word AT91_USER_Stack_Begin

2.
An assembly line " .word 0x55AA55AA " translates into "strpl r5, [sl,
#1450]! " . HOW ? and what does it mean ?

3.
whts are the meanings of labels, .equ, .word, .global and .extern ? (
in terms of scope and memory allocation with clear explanation on what
goes to what segments ). I have a clear understanding of the equivalent
in highlevel, but kinda stumped by the assembler. I had quite an
extensive look at GNU "as" with lil success.

4
in a symbol file what are the meaning of following :
"a"
"A"
"t"
"T"
"d"
"D" and how do they relate to labels, .equ, .word, .global and .extern
?

Hope some1 can throw some lite.
Nishu
2006-12-27 08:29:49 UTC
Permalink
Post by b***@googlemail.com
I am facing some difficulty understanding the ARM assembler
This are assembly directives not instructions. You have to understand
the gnu assembly directives before you write any assembly program.

-N
Dominic
2006-12-27 10:17:01 UTC
Permalink
Post by b***@googlemail.com
I am facing some difficulty understanding the ARM assembler
1. What does the following snippet means ? Especially the add r0,
pc,#-(8+.-StackData) . Is " . " and "pc " different ?
ldmia r0, {r1-r6}
.word AT91_SVC_Stack_Begin
.word AT91_IRQ_Stack_Begin
.word AT91_FIQ_Stack_Begin
.word AT91_ABT_Stack_Begin
.word AT91_UND_Stack_Begin
.word AT91_USER_Stack_Begin
It loads r0 (the destination register) with the result of adding the current
value of the program counter (which is the instruction's address + 8) and
an immediate operand (#-(8+.-StackData)).
'.' is "5.4 The Special Dot Symbol", which "refers to the current address
that `as' is assembling into". One difference between the PC and . is that
the value of . is determined at compile time.
This effectively loads r0 with the address of StackData. The same could have
been achieved using the "ADR <reg>, <label>" pseudo opcode offered by gas.
Post by b***@googlemail.com
2.
An assembly line " .word 0x55AA55AA " translates into "strpl r5, [sl,
#1450]! " . HOW ? and what does it mean ?
It's just a coincidence that this value translates to a valid opcode. The
pattern 0x55aa55aa is often used as a visible separation mark, or as a
dummy value, just like 0xdeadbeef or 0x0badc0de,
Post by b***@googlemail.com
3.
whts are the meanings of labels, .equ, .word, .global and .extern ? (
in terms of scope and memory allocation with clear explanation on what
goes to what segments ). I have a clear understanding of the equivalent
in highlevel, but kinda stumped by the assembler. I had quite an
extensive look at GNU "as" with lil success.
A label allows you to reference a location within your assembly, like the
StackData in your above example. No memory is being allocated and
visibility is limited to the current assembly file, I suppose.
.equ assigns a value to a symbol. No memory allocated, no visibility
outside.
.word puts a machine word at the current position in the assembly. The
section is the same as the rest of the assembly, unless you specify
different sections in your assembly.
.global makes a symbol visible to the linker and therefor other parts of
your program
.extern should be ignored on GAS. All undefined symbols are treated as
extern, and have to be resolved by the linker.

Of course, all of these questions could have been answered by running:
info gas
/<searchstring>
Post by b***@googlemail.com
4
"a"
"A"
"t"
"T"
"d"
"D" and how do they relate to labels, .equ, .word, .global and .extern
?
No idea what you're talking about.

Best regards,

Dominic
Laurent
2006-12-27 10:51:57 UTC
Permalink
Post by b***@googlemail.com
4
"a"
"A"
"t"
"T"
"d"
"D" and how do they relate to labels, .equ, .word, .global and .extern
?
Find the documentation for UNIX nm command. For instance
man nm.


Laurent
druck
2006-12-27 12:29:26 UTC
Permalink
Post by b***@googlemail.com
I am facing some difficulty understanding the ARM assembler
1. What does the following snippet means ? Especially the
add r0,pc,#-(8+.-StackData) . Is " . " and "pc " different ?
Its easier to understand as

add r0,pc,#StackData - 8 - .

Which loads R0 with the address of StackData, calculated as relative to the
PC which is 8 bytes beyond the current instruction address signified, by the
'.'.
Post by b***@googlemail.com
An assembly line " .word 0x55AA55AA " translates into
"strpl r5, [sl, #1450]! " . HOW ? and what does it mean ?
Its a common marker value (4 bytes of alternative 1's and 0's in binary),
which isn't a likely to be either valid instruction or a user data value.

---druck
--
The ARM Club Free Software - http://www.armclub.org.uk/free/
The 32bit Conversions Page - http://www.quantumsoft.co.uk/druck/
Continue reading on narkive:
Loading...