It's easy to compile C source code into an executable: gcc hello.c -o hello
. In contrast, this is how I am currently turning an assembly program into an executable:
cpp -P hello.S > hello.s # Run preprocessor.
as hello.s -o hello.o # Assemble.
ld hello.o -o hello # Link.
Is there a way to do all of this using one command?
The OS is Debian 10.1 Buster running on a mipsel (32-bit MIPS little endian) machine.
For reference, this is hello.S
, a MIPS assembly program that requires the use of the C preprocessor:
#include <regdef.h>
#include <sys/syscall.h>
.data
mymsg: .asciiz "Hello\n"
.text
.global __start
__start:
li a0, 1
la a1, mymsg
li a2, 6
li v0, SYS_write
syscall
li a0, 1
li v0, SYS_exit
syscall