extract assembling line

This commit is contained in:
sfja 2025-04-01 17:15:37 +02:00
parent af0214739c
commit 0bdbaa7f1f
7 changed files with 574 additions and 541 deletions

View File

@ -8,7 +8,6 @@ C_FLAGS = \
-Wall -Wextra -Wpedantic -Wconversion \
-pedantic -pedantic-errors \
-Wno-unused-variable \
-Wno-unused-parameter \
-I. \
L_FLAGS = -pthread

1106
asm/asm.c

File diff suppressed because it is too large Load Diff

View File

@ -114,7 +114,7 @@ typedef struct {
uint16_t offset;
} Line;
uint16_t assemble_to_binary(
uint16_t assemble_lines_with_labels(
uint16_t* out, const Line* lines, size_t lines_size);
Line s_label(int label);

View File

@ -105,6 +105,7 @@ Line s_jnz_l(Reg op1_reg, int op2_label)
{
return (Line) {
.ty = LineTy_Jnz_Label,
.op1 = (Ex) { .reg = (uint16_t)op1_reg },
.op2 = (Ex) { .label = op2_label },
};
}

View File

@ -7,7 +7,7 @@
-pedantic
-pedantic-errors
-Wno-unused-variable
-Wno-unused-parameter
# -Wno-unused-parameter
# -Wno-unused-function
-I.

View File

@ -203,7 +203,7 @@ void write_program(FILE* fp)
printf("assembling program...\n");
uint16_t program_size
= assemble_to_binary(program, program_asm, program_asm_size);
= assemble_lines_with_labels(program, program_asm, program_asm_size);
printf("done!\n");
printf("program size = %d\n", program_size);

View File

@ -1,5 +1,6 @@
#include "vm.h"
#include "common/arch.h"
#include "common/op_str.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>