Skip to main content
gamedev.net
🔒 Locked

Could someone please compile this code??

Started by Unspoken Magi 12 replies 750+ views
Original Post
Unspoken Magi
Unspoken Magi
Could someone please compile this code?? This is just to see if my assembly code can interface C code on an ARM processor. (GBA) I''ve been searching for ARM compilers, but each seems to have its own set of problems, which prevent me from compiling my code correctly (if at all). ...and Windows winsuck compilers for ARM are pretty hard to find, considering most of them are for linux. I tried to compile this code with gcc for ARM, but it just hangs the compiler.. The target architecture is arm7tdmi or anything close to that, as long as it is 32-bit ARM and not 26-bit. It should be compiled like this:
  
gcc -ffreestanding -fwritable-strings -marm7tdmi -mthumb-interwork -c -O2 -Wall -g -o Main.o Main.c
ld -nostdlib -o Kernel.cof -O2 -s -T Kernel-arm.ld Main.o
  
Sources below:

Kernel-arm.ld


  
OUTPUT_FORMAT("coff-go32") <<<--- Not sure whether this should coff-go32 or something arm-specific.. as long as its COFF; if COFF doesn''t work, binary is fine
ENTRY("entry")
SECTIONS {
    .text 0x02000000 :
    {   code = .;
        *(.text)
        . = ALIGN(256); }
    .data :
    {   data = .;
        *(.data)
        . = ALIGN(256); }
    .bss :
    {   bss = .;
        *(.bss)
        *(COMMON)
        . = ALIGN(256); }
    end = .; }
  

Main.c


  
int main(void)
{
	int i;

	while(1)
	{
		i++;
	}

	return i;
}
  

[Enter the Unspoken Realm]
Xtremehobo
Xtremehobo
hmm.. I''ve had no luck getting ARM programs (for the GBA ) to compile either
*bump*
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
dorix
dorix
I've built it for you.

Linky

I couldn't find the coff-go32 target, so I built it twice -- with coff-arm-big (Kernel.cof) and coff-arm-little (Kernel-little.cof). Difference is endian.

Built with Linux Devkit-Advance -- not sure which version, but it uses gcc 3.1 and binutils 2.12.1.

I had to use "-mcpu=arm7tdmi" instead of "-marm7tdmi".

Hope this helps;

- dorix

[edited by - dorix on April 26, 2003 11:36:17 PM]
smart_idiot
smart_idiot
Not that I know what I''m doing, but I think you should use ''-march'' instead of ''-mcpu''.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
dorix
dorix
To be honest, I *really* don''t know what I''m doing -- I don''t know the first thing about ARM architecture.

Anyways, there''s no -march= option for arm7tdmi, so I left -march out. If somebody can suggest the appropriate -march= option for this target, I''ll recompile.

BTW, I just recompiled using the -mbig-endian and -mlittle-endian flags to match the different targets I used in the Kernel-arm.ld file.

- dorix


dorix
dorix
Want it compiled again without optimization?

Just done so. objdump shows this:

> /usr/local/devkitadv/bin/arm-agb-elf-objdump -d Kernel-big.cof

Kernel-big.cof: file format coff-arm-big

/usr/local/devkitadv/bin/arm-agb-elf-objdump: Kernel-big.cof: no symbols
Disassembly of section .text:

02000000 <.text>:
2000000: e1a0c00d mov ip, sp
2000004: e92dd800 stmdb sp!, {fp, ip, lr, pc}
2000008: e24cb004 sub fp, ip, #4 ; 0x4
200000c: e24dd004 sub sp, sp, #4 ; 0x4
2000010: e1a00000 nop (mov r0,r0)
2000014: e51b3010 ldr r3, [fp, -#16]
2000018: e2833001 add r3, r3, #1 ; 0x1
200001c: e50b3010 str r3, [fp, -#16]
2000020: eafffffb b 0x2000014
...
Disassembly of section .glue_7:
Disassembly of section .glue_7t:

- dorix
dorix
dorix
That makes it easier. Let me know if you want any changes to the code recompiled and I''ll do that.

- dorix

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.