(Solved) I can't compile ASM

Hello everyone.

After almost a year of Fire Emblem hacking (I think?), I decided finally to try ASM. So, I followed the Ultimate Tutorial and downloaded and installed everything in the ASM chapter. The second step was to compile an alredy written code. So, I did as the tutorial said, but…

First, it didn’t recognised the files (arm-eabi-as, etc…). I managed to fix this looking at the folder and modifying the .bat file to add a -none- between the arm- and -eabi. It was fixed… or not? No, it wasn’t. Now, the console opens and just displays an empty screen. It makes an .elf file and an empty .symbols.log in the folder.

Now I don’t know what to do. I have tried to reinstall devkitPro, restarting the computer, running as admin, compatibility mode… But nothing works. I don’t know what this could be. I have alredy expent too much time with this. So, I’m asking you, more experienced developers… what could this be? I’m using Windows 10, if it matters.

It should give an error or warning message which allows us to help you.

No error or anything. Just makes the files and displays an empty screen:
https://gyazo.com/b21d57d00c4a856696da23edaa45d797

Probably a stupid question, but did you change all instances of “arm-eabi” to “arm-none-eabi” in the batch file? There’s 3 of them, and while I never encountered your particular error, doing that fixed it for me.

I did. I’m currently using:
[spoiler]
@echo off
SET startDir=C:\devkitPro\devkitARM\bin\

@rem Assemble into an elf
SET as="%startDir%arm-none-eabi-as.exe"
%as% -g -mcpu=arm7tdmi -mthumb-interwork %1 -o “%~n1.elf”

@rem Print symbol table
SET readelf="%startDir%arm-none-eabi-readelf.exe"
%readelf% -s “%~n1.elf” > “%~n1.symbols.log”

@rem Extract raw assembly binary (text section) from elf
SET objcopy="%startDir%arm-none-eabi-objcopy.exe"
%objcopy% -S “%~n1.elf” -O binary “%~n1.dmp”

echo y | del “%~n1.elf”
pause[/spoiler]

Mine doesn’t have “.exe” at the end of each SET line

[spoiler]
@echo off

SET startDir=C:\devkitPro\devkitARM\bin\

@rem Assemble into an elf
SET as="%startDir%arm-none-eabi-as"
%as% -g -mcpu=arm7tdmi -mthumb-interwork %1 -o “%~n1.elf”

@rem Print symbol table
SET readelf="%startDir%arm-none-eabi-readelf"
%readelf% -s “%~n1.elf” > “%~n1.symbols.log”

@rem Extract raw assembly binary (text section) from elf
SET objcopy="%startDir%arm-none-eabi-objcopy"
%objcopy% -S “%~n1.elf” -O binary “%~n1.dmp”

echo y | del “%~n1.elf”
pause
[/spoiler]

Still not working :cry: It does the same with or without the .exe

Can’t help then, sorry :frowning:

If you cannot solve the problem, try another compiler like GNUARM or Goldroad.

I can’t find GNUARM, so I tried Goldroad. It displays an error:
[spoiler]
error : line 1 : unrecognised token
.org 0x00

assembled with 1 errors
[/spoiler]
It assembles as a .gba file, but I don’t think that’s important. However, when I open the file with HxD, the hex code is completly different from the tutorial .dmp file. I haven’t tried it, but I don’t think it will work (being totally different from the “correct” version).

Yeah, you are right. I met the same problem with you: an empty screen. Though I compiled some source files successfully before, none of them still works now. Quite strange.

As for the goldroad, have you read the example code? Different compilers have different rules to follow. For example, in goldroad @pool instead of .pool is supposed to be used. You need to learn its own grammar rules if you decide to use a compiler.

About goldroad, I don’t know assembly, I was jut trying to assemble an alredy made file, so I don’t know which things I should correct and how. I looked at the example code and tried to modify some things here and there, but… still not working correctly (even assembling “without errors” made a different file from the correct version). So, I don’t know what to do.

Please walk me through the exact set of steps you’re taking to attempt to compile.

The issue with using other assemblers is that the “directives” (the lines beginning with a dot) are not necessarily equivalent between every tool, and you’ll have to feel your way through it yourself by reading the official documentation (etc) instead of following the tutorial.

Okay.

(Of course, I installed devkitPro before anything)
1 - I downloaded the default batch file. I dragged and dropped the .asm file on it. It didn’t worked because it couldn’t find “arm-eabi-as”, “arm-eabi-as”, “arm-eabi-readelf”, “arm-eabi-objcopy”. I solved it adding a “none” (as seen in the firsts posts).
2 - Now it displayed an empty screen. I tried reinstalling devkitPro and running the “arm-none-eabi-as” etc as admin and also in compatibility mode. Still not working.
3 - I tried with Goldroad. I opened a command prompt and typed “goldroad (file).asm” it compiled with errors (the .org error described above). Then, I tried modifing the file to make things look more like the example file, but it was just a trial and error thing, as I don’t know anything about how it works.

So, this is everything I’ve tried so far. I will look for some Goldroad documentation a bit understandable (for an ASM noob level) as @CT075 said, to see what can I do. (But, of course, the best would be solving the devkitPro issue, so I can follow a more Fire Emblem-oriented tutorial)

EDIT: Good news, everyone! I managed to compile it without modifications and errors. Looking for Goldenroad tutorials I casually found this (Is this spam? If it is, I will remove it). It’s Pokemon-oriented, but, at least with the example code, seems to work.

So, thanks everyone who helped. Let’s hope it works perfectly always.

I fixed it.

Instead of running that .bat, compile it yourself.
arm-none-eabi-as -g -mcpu=arm7tdmi -mthumb-interwork Hector.asm -o Hector.elf
arm-none-eabi-objcopy -S Hector.elf -O binary Hector.dmp
Now it works well.

As for the goldroad, change the 1st line from .thumb to @thumb and delete the 2nd line, it will be assembled successfully.

One more thing I can tell you:
Don’t expect 2 compilers to generate the totally same binary files. They both work.

2 Likes

It worked! Thank you for your help!

while this is true in the literal sense, these aren’t compilers - these are assemblers. A difference in compilers is typically due to optimization levels (there are a few different ways the line if (func1()) { func2(); } can be compiled depending on how you like your branches). In this case, however, an assembler merely assembles the code you write - every single opcode has an exact representation, and if those varied between assemblers then they wouldn’t work. Things like directives, etc, can cause a few differences (well, if you’re assembling to an executable I suppose all the differences would be in things like file headers) but for the most part the “business logic” (the actual code binary itself) should be identical.

1 Like

A simple thing: If you type “nop”, the assembler can convert it to “mov r0.r0” or other things. They cannot be totally same, though important parts are the same as you said. It doesn’t affect anything. They both work.
Of course, there is a very strong (generally one-to-one) correspondence between the assembly language and the architecture’s machine code instructions.
PS: devkitPro can also be used as a C compiler, while goldroad cannot.

i forgot about nop (for the record, though, in several assemblers .nop is a directive!), but devkitPro as a C compiler uses gcc (a compiler) as a back-end, whereas goldroad is strictly a set of assemblers