Review ntsys-assembler.h
This commit is contained in:
parent
b7590e11b0
commit
7b7e22e68f
BIN
hello_user.exe
BIN
hello_user.exe
Binary file not shown.
@ -95,13 +95,13 @@ int ntsys_compile_asm_stadion2(
|
||||
size_t* mem_pos,
|
||||
char** labels,
|
||||
word_t* labels_pos,
|
||||
size_t labels_count,
|
||||
size_t* labels_count,
|
||||
dword_t* fsz,
|
||||
byte_t num
|
||||
) {
|
||||
char* st = NULL;
|
||||
while ((st = ntsys_get_str(st, fp)) != NULL) {
|
||||
if (ntsys_asm_from_string(mem_pos, st, tmp, num, labels, labels_pos, &labels_count, fsz) != EXIT_SUCCESS) {
|
||||
if (ntsys_asm_from_string(mem_pos, st, tmp, num, labels, labels_pos, labels_count, fsz) != EXIT_SUCCESS) {
|
||||
free(st);
|
||||
fclose(fp);
|
||||
fclose(tmp);
|
||||
@ -119,6 +119,11 @@ int ntsys_compile_asm_stadion2(
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#define ntsys_load_image_from_file(file, num) ( ntsys_compile_asm_stadion2( \
|
||||
fp, (file), lb_size, &mem_pos, \
|
||||
labels, labels_pos, &labels_count, &fsz, (num) \
|
||||
) != EXIT_SUCCESS )
|
||||
|
||||
int ntsys_compile_asm(char* filename, char* asm_out) {
|
||||
FILE* fp = fopen(filename, "r");
|
||||
if (fp == NULL) {
|
||||
@ -144,10 +149,7 @@ int ntsys_compile_asm(char* filename, char* asm_out) {
|
||||
fclose(fp);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ntsys_compile_asm_stadion2(
|
||||
fp, tmp, lb_size, &mem_pos,
|
||||
labels, labels_pos, labels_count, &fsz, 0
|
||||
) != EXIT_SUCCESS) return EXIT_FAILURE;
|
||||
if (ntsys_load_image_from_file(tmp, 0) != EXIT_SUCCESS) return EXIT_FAILURE;
|
||||
fclose(tmp);
|
||||
rewind(fp);
|
||||
FILE* fw = fopen(asm_out, "wb");
|
||||
@ -156,10 +158,7 @@ int ntsys_compile_asm(char* filename, char* asm_out) {
|
||||
fclose(fp);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ntsys_compile_asm_stadion2(
|
||||
fp, fw, lb_size, &mem_pos,
|
||||
labels, labels_pos, labels_count, &fsz, 1
|
||||
) != EXIT_SUCCESS) return EXIT_FAILURE;
|
||||
if (ntsys_load_image_from_file(fw, 1) != EXIT_SUCCESS) return EXIT_FAILURE;
|
||||
fflush(fw);
|
||||
fclose(fp);
|
||||
size_t i = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user