Thumb instruction set generation...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Thumb instruction set generation...
- To: arm-gnu@xxxxxxxxxxxxxxxx
- Subject: Thumb instruction set generation...
- From: Patrick Bellasi <derkling@xxxxxxxxxxxxx>
- Date: Thu, 9 Sep 2004 11:50:56 +0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm compiling a toy .c source with:
arm-none-elf-gcc (GCC) 3.4.0 20040409 (CodeSourcery ARM Q1A 2004)
using those switch:
-mcpu=arm7tdmi -mthumb-interwork
In the genarated code I expect to get sometimes a switching between ARM and
Thumb instruction set, i.e following a BX instr.
It seem to me that the generated code isn't conform to the THUMB instruction
set specifications...
This is a piece of code I'm getting:
...
00008280 <main+0x64> bx lr
00008284 <fact> mov ip, sp
00008288 <fact+0x4> stmdb sp!, {fp, ip, lr, pc}
0000828c <fact+0x8> sub fp, ip, #4 ; 0x4
00008290 <fact+0xc> sub sp, sp, #8 ; 0x8
00008294 <fact+0x10> str r0, [fp, #-16]
00008298 <fact+0x14> ldr r3, [fp, #-16]
0000829c <fact+0x18> cmp r3, #0 ; 0x0
000082a0 <fact+0x1c> beq 000082b4 <fact+0x30>
000082a4 <fact+0x20> ldr r3, [fp, #-16]
000082a8 <fact+0x24> cmp r3, #1 ; 0x1
000082ac <fact+0x28> beq 000082b4 <fact+0x30>
000082b0 <fact+0x2c> b 000082c0 <fact+0x3c>
000082b4 <fact+0x30> mov r3, #1 ; 0x1
000082b8 <fact+0x34> str r3, [fp, #-20]
000082bc <fact+0x38> b 000082e0 <fact+0x5c>
000082c0 <fact+0x3c> ldr r3, [fp, #-16]
000082c4 <fact+0x40> sub r3, r3, #1 ; 0x1
000082c8 <fact+0x44> mov r0, r3
000082cc <fact+0x48> bl 00008284 <fact>
000082d0 <fact+0x4c> mov r3, r0
000082d4 <fact+0x50> ldr r2, [fp, #-16]
000082d8 <fact+0x54> mul r3, r2, r3
000082dc <fact+0x58> str r3, [fp, #-20]
000082e0 <fact+0x5c> ldr r0, [fp, #-20]
000082e4 <fact+0x60> sub sp, fp, #12 ; 0xc
000082e8 <fact+0x64> ldmia sp, {fp, sp, lr}
000082ec <fact+0x68> bx lr
...
Well, at 0x8280 we have the first BX inst.
So, from that point following the processor have to execute THUMB code (if
lr[0]==1 of course)... and so, till the next BX at 0x82ec we have to find
ONLY THUMB instructions. It isn't?
At 0x8288... just two instr after the firse BX we have that instr:
00008288 <fact+0x4> stmdb sp!, {fp, ip, lr, pc}
BUT: that kind of multiple store isn't allowed on thumb mode... it was to be
a:
stmia sp!, {fp, ip, lr, pc}
There are other non thumb instr in the above code...
Is that a problem of the compiler, or concerning the decompiler
(arm-none-elf-objdump 2.15.91 20040504)...
or I'm in wrong?!?
I'm referring to that specs:
- - ARM Instruction Set Quick Reference Card v2.1
- - Thumb Instruction Set Quick Reference Card v2.1
Thank's in advance,
Patrick
- --
<---------------------------------------------------------------------------------------------------------->
DERKLING
LRU 338214 (http://counter.li.org)
make linux | more > user-firendly
<---------------------------------------------------------------------------------------------------------->
Patrick Bellasi <derkling_at_users.sourceforge.net>
Student (Politecnico di Milano)
Comp.Sci & Soft.Eng
Contacts:
- Room +39 02 23952621
- Home +39 0342 621043 (week-ends)
- ICQ 344672588
- MSN pbellasi@xxxxxxxx
Privacy:
- PGP 0x72ABC1EE (www.keyserver.net)
pub 1024D/72ABC1EE 2003-12-04 Patrick Bellasi (PGP key for poste.it)
<patrick.bellasi@xxxxxxxx>
Primary key fingerprint: 3958 7B5F 36EC D1F8 C752 9589 C3B7 FD49 72AB
C1EE
<---------------------------------------------------------------------------------------------------------->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBQEOqeGk3pQ7APA8RAuVTAJ9TYJ6VW/xhA9wDQ92HEQdCtq2nFQCfQG2y
pVSsThH1orpMI1XAhhlqYVc=
=K/BV
-----END PGP SIGNATURE-----