compiler opitions for machine code

support for the ARM toolchain
Post Reply
lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

compiler opitions for machine code

Post by lazyprogramer » Wed Aug 24, 2011 1:26 pm

Hi,
I have a question about devkitARM and maybe you can help me:
What do I have to do when I want to compile an assembly language script like this:

Code: Select all

.syntax unified
    .global main
main:
    push    {ip, lr}
    ldr     r0, =message
    bl      printf
    mov     r0, #0      @ Return 0.
    pop     {ip, pc}
message:
    .asciz  "Hello, world.\n"
straightly into machine code (which is later stored in RAM to execute)?
Do I have to use arm-eabi-gcc or gcc? I want to compile the code for ARM11 processor.

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: compiler opitions for machine code

Post by elhobbs » Wed Aug 24, 2011 2:01 pm

there is more to it than copying it to ram. you need to relocate the code or load it at a fixed address. your code has depenancies. printf for one, and printf has dependancies. you can include the depenancies in your output file, but that would most likely conflict with versions already in your main program. you could export depandancies from your main program and import then when the binary is loaded. essentially you are looking for dll support. if your platform has it then use it. if it has it and you do not want to use it then it starts to sound like you are up to something unscrupulous.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: compiler opitions for machine code

Post by WinterMute » Wed Aug 24, 2011 3:43 pm

The answer depends largely on what you're actually targeting. You'll need a suitable linkscript & crt0 for your target and a library which provides printf for it.

We can't really offer much guidance without knowing what you're building code for but if this is for 3DS then please go away until such times as we have a method for running 3DS native code.
Help keep devkitPro toolchains free, Donate today

Personal Blog

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: compiler opitions for machine code

Post by lazyprogramer » Wed Aug 24, 2011 7:42 pm

Actually I don't want to use dll files and I think the system doesn't support it.
To say the truth, I wanted to build code for the 3DS.
What is the problem if we want to compile this HelloWorld asm for the 3DS system? Could we use devkitARM at least?

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: compiler opitions for machine code

Post by lazyprogramer » Sat Aug 27, 2011 8:47 pm

@
printf has dependancies
:
What about rewriting printf? This could be done easily.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: compiler opitions for machine code

Post by WinterMute » Sat Aug 27, 2011 11:09 pm

Before you have printf you must have the means to output a single character, before you output a single character you must have the ability to run code ...

In theory, yes devkitARM can compile code for the 3DS, given that there is no known way to boot our own code in 3DS mode we have no way to test anything. Until there's a way to run code there is no basis for discussing 3DS code.
Help keep devkitPro toolchains free, Donate today

Personal Blog

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: compiler opitions for machine code

Post by lazyprogramer » Sun Aug 28, 2011 7:47 pm

Before you have printf you must have the means to output a single character, before you output a single character you must have the ability to run code ...

In theory, yes devkitARM can compile code for the 3DS, given that there is no known way to boot our own code in 3DS mode we have no way to test anything. Until there's a way to run code there is no basis for discussing 3DS code.
So I would have to rewrite put() and writing a new character set...
Writing crt0 isn't possible yet, right?

If we can edit savefiles and find an exploit we could run code.

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: compiler opitions for machine code

Post by mtheall » Sun Aug 28, 2011 9:19 pm

If we can edit savefiles and find an exploit we could run code.
That's a big if. Seriously, this conversation should never happen until we get to the point where code is runnable, so I don't know why you keep trying to get ahead of something that doesn't exist yet.

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: compiler opitions for machine code

Post by lazyprogramer » Mon Aug 29, 2011 7:30 pm

Also for put() we have to communicate with the 3DS' GPU and we don't know anything about it...

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: compiler opitions for machine code

Post by lazyprogramer » Sat Sep 03, 2011 12:02 pm

I've writen a console (including printf), but for display anything on the screen I have to find out more about the PICA200 and display memory.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests