Introduction to arm. Word pseudocommands

Source: Internet
Author: User

The word in arm is 32bit (different from x86)

--------------------------------------

In start. s of uboot:

Ldr pc, _ undefined_instruction
_ Undefined_instruction:. Word undefined_instruction

That is, the value at the _ undefined_instruction address is taken out to the PC.

_ Undefined_instruction address. A 32bit value is defined with. Word. (The Code address corresponding to undefined_instruction)

===================== The following article is good

[Original article address: http://linux.chinaunix.net/techdoc/?top/2007/03/12/952053.shtml]

Arm Assembly pseudocommand. Word
We often encounter some troublesome pseudocommands starting,
As for. globl _ start. balign. Align. Data. Text and so on, the most bt is as follows:
_ Undefined_instruction:. Word undefined_instruction
This. Word is confusing. Technical staff on the Internet did not bother to answer the question. For more information, see gnu asm. I checked it and explained the. Word as follows:
Http://tigcc.ticalc.org/doc/gnuasm.html#SEC49
. Word
Syntax:. Word expressions
This directive expects zero or more expressions, of any section, separated by commas. For each expression, as emits a 16-bit number for this target.
And as.info documents:
7.92. Word expressions
This directive expects zero or more expressions, of any section, separated by commas.
The size of the number emitted, and its byte order, depend on what target computer
The Assembly is.
Warning: special treatment to support Compilers
Machines with a 32-bit address space, but that do less than 32-bit addressing, require
The following special treatment. If the machine of interest to you does 32-bit addressing
(Or doesn't require it; see Chapter 8 [machine dependencies], page 61), you can ignore this
Issue.
In order to assemble compiler output into something that works, as occasionally does
Strange things to '. word' ctictives. direves ves of the form'. Word sym1-sym2' are often
Emitted by compilers as part of Jump tables. Therefore, when as assembles a directive
The form '. Word sym1-sym2', and the difference between sym1 and sym2 does not fit in 16
BITs, as creates a secondary jump table, immediately before the next label. This secondary
Jump table is preceded by a short-jump to the first byte after the secondary table. This
Short-jump prevents the flow of control from accidentally falling into the new table. Inside
The table is a long-jump to sym2. the original '. word'ins ins sym1 minus the address
The long-jump to sym2.
If there were several occurrences of '. Word sym1-sym2' before the secondary jump table,
All of them are adjusted. If there was a'. Word sym3-sym4 ', that also did not fit in sixteen
BITs, a long-jump to sym4 is wrongly ded in the secondary jump table, and the. Word directives
Are adjusted to contain sym3 minus the address of the long-jump to sym4; and so on, for
Your entries in the original jump table as necessary.
After reading it, I still feel confused.
I disassemble the binfile and want to find out what the. Word is doing in this way.
Original Assembler: (start. s)
. Globl _ start
_ Start: B Reset
Ldr pc, _ undefined_instruction
Ldr pc, _ software_interrupt
Ldr pc, _ prefetch_abort
Ldr pc, _ data_abort
Ldr pc, _ not_used
Ldr pc, _ IRQ
Ldr pc, _ FIQ
_ Undefined_instruction:. Word undefined_instruction
_ Software_interrupt:. Word software_interrupt
_ Prefetch_abort:. Word prefetch_abort
_ Data_abort:. Word data_abort
_ Not_used:. Word not_used
_ IRQ:. Word IRQ
_ FIQ:. Word FIQ
. Balignl 16, 0 xdeadbeef
_ Text_base:
. Word text_base
. Globl _ armboot_start
_ Armboot_start:
. Word _ start
. Globl _ bss_start
_ Bss_start:
. Word _ bss_start
. Globl _ bss_end
_ Bss_end:
. Word _ end
Reset:
/*
* Set the CPU to svc32 Mode
*/
Mrs r0, CPSR
Bic r0, R0, # 0x1f
ORR r0, R0, #0xd3
Msr cpsr, R0
Corresponding disassembly:
00000000 [0xea000012] B 0x50
00000004 [0xe59ff014] ldr pc, 0x00000020; = #0x33f80140
00000008 [0xe59ff014] ldr pc, 0x00000024; = #0x33f801a0
0000000c [0xe59ff014] ldr pc, 0x00000028; = #0x33f80200
00000010 [0xe59ff014] ldr pc, 0x0000002c; = #0x33f80260
00000014 [0xe59ff014] ldr pc, 0x00000030; = #0x33f802c0
00000018 [0xe59ff014] ldr pc, 0x00000034; = #0x33f80320
2017001c [0xe59ff014] ldr pc, 0x00000038; = #0x33f80380
00000020 [0x33f80140] mvnccs r0, #0x10 ;? Rn = 0x8
00000024 [0x33f801a0] mvnccs r0, #0x28 ;? Rn = 0x8
00000028 [0x33f80200] mvnccs r0, #0, 4 ;? Rn = 0x8
2017002c [0x33f80260] mvnccs r0, #6 ;? Rn = 0x8
00000030 [0x33f802c0] mvnccs r0, # 0xc ;? Rn = 0x8
00000034 [0x33f80320] mvnccs r0, #0x80000000 ;? Rn = 0x8
00000038 [0x33f80380] mvnccs r0, #2 ;? Rn = 0x8
2017003c [0 xdeadbeef] cdple P14, 0xa, C11, C13, C15, 7
00000040 [0x33f80000] mvnccs r0, #0 ;? Rn = 0x8
00000044 [0x33f80000] mvnccs r0, #0 ;? Rn = 0x8
00000048 [0x33f96650] mvnccs R6, #0x5000000 ;? Rn = 0x9
2017004c [0x33f9ab80] mvnccs R10, #0x20000 ;? Rn = 0x9
00000050 [0xe10f0000] Mrs r0, CPSR
00000054 [0xe3c0001f] Bic r0, R0, # 0x1f
00000058 [0xe38000d3] Orr r0, R0, #0xd3
2017005c [0xe129f000] MSR cpsr_cf, R0
In this case,
_ Undefined_instruction:. Word undefined_instruction
The corresponding disassembly of this sentence is:
Mvnccs r0, #0x10;
So I am even more confused.
Go to chinaunix for help. Fortunately, I met an enthusiastic netizen, Wheelz, and gave me a detailed answer.
The post link is as follows:
Http://www.linuxforum.net/forum/showflat.p...K&Number=563178
Now let's sum up the answers of Wheelz and talk about the role of this. Word.
Word expression is to put a word value in the current position. This value is expression.
For example,
_ Rwtcon:
. Word 0x15300000
Put a value of 0x15300000 at the current address, that is, _ rwtcon.
The Assembly statement translated into Intel is:
_ Rwtcon DW 0x15300000
Put the expression value at the current position. So it turns out.
PS:
Paste a ###role.
# DEFINE _ syscall0 (type, name )\
Type name (void )\
{\
Long _ res ;\
_ ASM _ volatile ("int $0x80 "\
: "= A" (_ res )\
: "0" (_ nR _ # Name ));\
If (_ res> = 0 )\
Return (type) _ res ;\
Errno =-_ res ;\
Return-1 ;\
}
_ NR _ # name indicates the system call number. # indicates two macro expansions. replace "name" with the actual system call name, and then replace _ nR _... expand. for example, name = IOCTL is _ nr_ioctl.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.