Initial commit, can read from a list of files passed.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
; comments are ignored
|
||||||
|
; This is a very simple test file for an assemblier.
|
||||||
|
mov r1, 5 ; move the immediate value 5 into r1
|
||||||
|
add r1, 5 ; add 5 into r1
|
||||||
|
int 21 ; maybe that will call some string drawing BIOS-like routine
|
||||||
|
ret ; return from 'call' if there were such a thing
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_file(char*);
|
||||||
|
|
||||||
|
int main(int argc, char* args[]) {
|
||||||
|
const char *input_files[argc - 1];
|
||||||
|
|
||||||
|
if (argc == 1) {
|
||||||
|
printf("Input files required.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for (int i = 1; i < argc; i++) {
|
||||||
|
// input_files[i - 1] = args[i];
|
||||||
|
// print_file(args[i]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
print_file(args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_file(char* file_path) {
|
||||||
|
FILE *file;
|
||||||
|
char* line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
ssize_t bytes_read;
|
||||||
|
|
||||||
|
file = fopen(file_path, "r");
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
printf("Failed to open '%s' for reading.\n", file_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while((bytes_read = getline(&line, &len, file)) != -1) {
|
||||||
|
printf("%s", line);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
if (line) free(line);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user