maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N810 (https://talk.maemo.org/forumdisplay.php?f=28)
-   -   Need help understanding arm assembly (https://talk.maemo.org/showthread.php?t=68887)

cookiedemkp 2011-01-24 22:48

Need help understanding arm assembly
 
Hello, I bought this bookand went without reading it for a while. But recently, I started reading it again and wished to use it to practice on my N810 Wimax. Then, I realized that the book strictly covers the x86 architecture :rolleyes: i.e. the assembly instructions outputted from objdump and gdb are assembly from the x86 architecture and therefore the arm architecture assembly shown on my n810 doesnt make sense to me since im used to x86.

So my question is: is there some way that the assembly can be outputted as x86 instructions? I do realize that what I'm asking is probably impossible, so a follow-up question would be: What would be a good way to "migrate" from x86 to arm assembly?

Any help is appreciated! :)

anthonie 2011-01-24 23:04

Re: Need help understanding arm assembly
 
As far as I know to output asm code written for one architecture can not be outputted as code for another architecture. There´s a reason why we have to declare the target architecture at the beginning of each piece of code written.

That being said, I have bookmarked some sites I found, just last week, with information on asm for arm7. I don´t have access to that machine right now, but tomorrow I should be able to post them. Provided you´re interested and it is what you asked for. ;)

Either way, happy to see someoe with an interest in asm!

cookiedemkp 2011-01-24 23:10

Re: Need help understanding arm assembly
 
Thanks for the info and yes im very interested in asm. I really like seeing the lower-level instructions and understanding the logical flow of the program and, although I do love if(){ do this } loops, I, being a math and logic oriented person, love seeing how the branches are performed in assembly and i really love using gdb :)

maacruz 2011-01-24 23:25

Re: Need help understanding arm assembly
 
Google search, second result: http://www.coranac.com/tonc/text/asm.htm

cookiedemkp 2011-01-24 23:38

Re: Need help understanding arm assembly
 
Quote:

Originally Posted by maacruz (Post 927753)
Google search, second result: http://www.coranac.com/tonc/text/asm.htm

Thanks for the link. Definitely a great start!

anthonie 2011-01-24 23:47

Re: Need help understanding arm assembly
 
Quote:

Originally Posted by maacruz (Post 927753)
Google search, second result: http://www.coranac.com/tonc/text/asm.htm

That´s one! Cheers. The links to the other ones I bookmarked are mentioned here as well.


I seem to get different results when I google from my n900...

anthonie 2011-01-25 15:08

Re: Need help understanding arm assembly
 
Turns out I had some more links bookmarked. Here you go...

http://www.arm.com/miscPDFs/9658.pdf

http://www.eetimes.com/discussion/ot...n-to-ARM-thumb

http://www.heyrick.co.uk/assembler/

cookiedemkp 2011-01-26 00:28

Re: Need help understanding arm assembly
 
Thank you for all the resources :)

After reading through some of these documents, I realize it will take some time to learn arm assembly, so could someone possibly give me a "leg up" so to speak? I've attached the source code for a C program and the output of gdb and I would like if someone could help me understand the logical flow of the program. Like if you could step me through the program and explain each step?

cookiedemkp 2011-01-26 00:35

Re: Need help understanding arm assembly
 
Thank you for all the resources :)

After reading through some of these documents, I realize it will take some time to learn arm assembly, so could someone possibly give me a "leg up" so to speak? Here is the source code for a C program and the output of gdb and I would like if someone could help me understand the logical flow of the program. Like if you could step me through the programs disassembly and explain each step?

Main.c:
Code:

#include <stdio.h>
int main()

{
 
  printf("Hello, world!\n");

  return 0;

}

GDB output:
Code:

(gdb) break main
Breakpoint 1 at 0x838c: file main.c, line 5.
(gdb) run
Starting program: /home/user/a.out

Breakpoint 1, main () at main.c:5
5          printf("Hello, world!\n");
(gdb) disassemble main
Dump of assembler code for function main:
0x00008380 <main+0>:        mov        r12, sp
0x00008384 <main+4>:        push        {r11, r12, lr, pc}
0x00008388 <main+8>:        sub        r11, r12, #4        ; 0x4
0x0000838c <main+12>:        ldr        r0, [pc, #8]        ; 0x839c <main+28>
0x00008390 <main+16>:        bl        0x82cc <printf>
0x00008394 <main+20>:        mov        r0, #0        ; 0x0
0x00008398 <main+24>:        ldm        sp, {r11, sp, pc}
0x0000839c <main+28>:        andeq        r8, r0, r8, lsr #8
End of assembler dump.
(gdb) x/s 0x8428
0x8428:        "Hello, world!\n"

My main problem with understanding the disassembly is that my last command reveals the "Hello, world!\n" string at the address 0x00008428, yet I see nowhere in the programs disassembly where it points to this address to printf() it?

Again, any help is appreciated! :p

maacruz 2011-01-26 08:30

Re: Need help understanding arm assembly
 
Just read carefully again the section about inmediate values in the link I provided. I won't spare you the pleasure of discovering how it is right under your nose.


All times are GMT. The time now is 07:04.

vBulletin® Version 3.8.8