gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > trouble with compilation

#163314 - moonlightcheese - Mon Sep 29, 2008 2:35 pm

i'm using devkitadv and i'm trying to compile some assembly. the compiler works fine for compiling C, but this program won't compile:

move16.s:
Code:
.arm
.section .text

   MOV   PC,R1

makefile:
Code:
path=..\..\devkitadv\bin
gcc -o move16.elf move16.s


output:
Code:
E:\CS3243\examples>make.bat

E:\CS3243\examples>path=..\..\devkitadv\bin

E:\CS3243\examples>gcc -o move16.elf move16.s
../../devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/lib/crt0.o: In function `__FarProcedure':
../../devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/lib/crt0.o(.text+0x1f0): undefined reference to `main'
collect2: ld returned 1 exit status


i'm not sure what's wrong...

#163315 - Griffin - Mon Sep 29, 2008 2:56 pm

You need a main function for gcc.. Probably..
Have you tried the equivalent compilation with gas?

#163318 - moonlightcheese - Mon Sep 29, 2008 3:19 pm

Griffin wrote:
You need a main function for gcc.. Probably..
Have you tried the equivalent compilation with gas?

all i have at my disposal is devkitadv. this is actually for a school project and i'm afraid i don't have time to muck around with compilers. i believe devkitadv has the ability to compile assembly, as indicated on the site's FAQ, but i can't seem to get it to compile any sample code or anything in assembly.

if it's necessary, i can try to setup devkitpro again although last time i had some trouble with it...

and i'm not sure how to compile with gas, nor do i have time to set it up unless it's as simple as "apt-get install gas" or something to that effect. i need to spend this time on development. the first part of this project is due next weekend and i'm doing the best i can just to get a compiler to work...

#163321 - Griffin - Mon Sep 29, 2008 4:16 pm

With devkitarm you have arm-eabi-gcc and arm-eabi-as, I guess that gas would be arm-elf-as for you, if that doesn't work then look around your devkitadv/bin directory.

#163324 - moonlightcheese - Mon Sep 29, 2008 5:12 pm

Griffin wrote:
With devkitarm you have arm-eabi-gcc and arm-eabi-as, I guess that gas would be arm-elf-as for you, if that doesn't work then look around your devkitadv/bin directory.

my temporary fix is just to use inline assembly and hopefully everything will work properly. for the first part of this assignment, i basically have to be able to store a program on a process control block of my own design, store the data portion of the program on the appropriate stack, switch the program's first instruction into the PC, ... basically implement OS context switching. i think i bit off more than i can chew for this project (x.O)

inevitably, i'll have to get devkitpro installed since everyone seems to be on the same page there.

thanks for the response.

#163330 - Cearn - Mon Sep 29, 2008 6:25 pm

Both PREFIX-as and PREFIX-gcc will assemble assembly, but the linker will still need a function/label called main for the boot code to jump to. If you don't have one already, make one.

Code:
    .text
    .align
    .thumb_func
    .global main
main:
    [your code here]

    @ Return 0
    mov     r0, #0
    bx      lr

#163335 - moonlightcheese - Mon Sep 29, 2008 8:41 pm

Cearn wrote:
Both PREFIX-as and PREFIX-gcc will assemble assembly, but the linker will still need a function/label called main for the boot code to jump to. If you don't have one already, make one.

Code:
    .text
    .align
    .thumb_func
    .global main
main:
    [your code here]

    @ Return 0
    mov     r0, #0
    bx      lr


AWESOME! i tried using main, but didn't declare it as a global section. now it works. additionally i got devkitarm working this time. a reinstallation fixed it up, and i just tested compiling assembly with arm-eabi-as.exe and it works as expected, creating an a.out.

thanks for the help everyone! i'm on my way to a gba operating system :D

#163348 - Dwedit - Tue Sep 30, 2008 9:53 am

It's not a "global section", it's a "global" in that the symbol is exported so the linker can see it.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#163351 - moonlightcheese - Tue Sep 30, 2008 12:49 pm

Dwedit wrote:
It's not a "global section", it's a "global" in that the symbol is exported so the linker can see it.

duly noted.

man i'm rusty... but then my only risc assembly experience is with a SPARC machine for a class i took over a year ago. getting some good practice in now though :D