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 > inline assembly error

#177020 - blessingta@hotmail.co.uk - Fri Nov 25, 2011 11:11 am

why wont this insertion work?

asm
(
//@ DEFINING DATA IN ASSEMBLY
.align 2
word_var: //@ int word_var= 0xCAFEBABE
.word 0xCAFEBABE
sArray: //@ int sArray[4]= { 1,2,3,4 }
.word 1, 2, 3, 4 //@ NO comma at the end!!
);

#177021 - blessingta@hotmail.co.uk - Fri Nov 25, 2011 12:19 pm

Plus what is the assembly operation for bjarne stroustrup's ++?

#177022 - blessingta@hotmail.co.uk - Fri Nov 25, 2011 12:40 pm

this edit wont work either:
Code:
   asm
   (
"word_var:               /* int word_var= 0xCAFEBABE*/"
    ".word   0xCAFEBABE"
"sArray:                 /* int sArray[4]= { 1,2,3,4 }*/"
".word   1, 2, 3, 4      /* NO comma at the end!!*/"
   );
   


Quote:
> "make"
main.c
arm-eabi-gcc -MMD -MP -MF /g/YEAR2/Console_Programming_CONPRG/Course_Work/gba/ASM/32BITS/build/main.d -g -Wall -O3 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -I/g/YEAR2/Console_Programming_CONPRG/Course_Work/gba/ASM/32BITS/include -I/D/devkitPro/libgba/include -I/g/YEAR2/Console_Programming_CONPRG/Course_Work/gba/ASM/32BITS/build -c /g/YEAR2/Console_Programming_CONPRG/Course_Work/gba/ASM/32BITS/source/main.c -o main.o
C:\Users\cam01468\AppData\Local\Temp\ccghdj18.s: Assembler messages:
C:\Users\cam01468\AppData\Local\Temp\ccghdj18.s:286: Error: junk at end of line, first unrecognized character is `s'
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:01

#177023 - Dwedit - Fri Nov 25, 2011 5:22 pm

For inline ASM:

Use input, output, and clobber lists so the compiler can figure out how to pass variables in and out of your ASM code.

Use \n at the end of every line.

This page has good information: ARM GCC Inline Assembler Cookbook
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#177024 - sverx - Fri Nov 25, 2011 5:26 pm

Quote:
If we have more than one instructions, we write one per line in double quotes, and also suffix a \n and \t to the instruction. This is because gcc sends each instruction as a string to as(GAS) and by using the newline/tab we send correctly formatted lines to the assembler.


http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s4

edit: Dwedit was faster.
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary