30 lines
693 B
C
30 lines
693 B
C
#include <common.h>
|
|
#include <fcntl.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#include <ain48.h>
|
|
|
|
i32 asm_main(i32 argc, char *argv[]) {
|
|
if (argc != 3) {
|
|
log_err("Usage: asm source.a48s dest.bin");
|
|
return 1;
|
|
}
|
|
int soruce_file = open(argv[1], O_RDONLY);
|
|
if (soruce_file < 0) {
|
|
log_err_errno("Failed to open file `%s`", argv[1]);
|
|
return 1;
|
|
}
|
|
struct stat statres;
|
|
if (fstat(soruce_file, &statres) < 0) {
|
|
log_err_errno("Failed to stat file `%s`", argv[1]);
|
|
return 1;
|
|
}
|
|
if (statres.st_size == 0) {
|
|
log_err("Cannot assemble an empty file");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|