refactor Makefile and update CPU struct: rename stack pointer field for clarity

This commit is contained in:
2025-12-21 18:52:11 +03:00
parent 45b96c4390
commit 1a3647c557
2 changed files with 15 additions and 25 deletions
+14 -24
View File
@@ -1,32 +1,22 @@
cc := gcc CC = gcc
CFLAGS := -std=c11 -Wall -Wextra -Wpedantic -O2 CFLAGS = -Wall -Wextra -O3 -Iinclude
CFLAGS_DEBUG := -std=c11 -Wall -Wextra -Wpedantic -g -O0 SRC_DIR = src
OBJ_DIR = build
BIN_DIR = bin
SRC_DIR := src SOURCES = $(wildcard $(SRC_DIR)/*.c)
BUILD_DIR := build OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
BIN_DIR := bin TARGET = $(BIN_DIR)/mos6502
TARGET := $(BIN_DIR)/mos6502
SRC := $(shell find $(SRC_DIR) -name '*.c')
OBJ := $(SRC:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
all: $(TARGET) all: $(TARGET)
$(TARGET): $(OBJ) $(TARGET): $(OBJECTS)
@mkdir -p $(BIN_DIR) @mkdir -p $(BIN_DIR)
$(cc) $(OBJ) -o $(TARGET) $(CC) $(OBJECTS) -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(BUILD_DIR) @mkdir -p $(OBJ_DIR)
@mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@
$(cc) $(CFLAGS) -c $< -o $@
debug: CFLAGS=$(CFLAGS_DEBUG)
debug: clean $(TARGET)
clean: clean:
rm -rf $(BUILD_DIR) $(BIN_DIR) rm -rf $(OBJ_DIR) $(BIN_DIR)
rebuild: clean all
.PHONY: all clean rebuild debug
+1 -1
View File
@@ -8,7 +8,7 @@ typedef struct
uint8_t A; // accumulator uint8_t A; // accumulator
uint8_t X; // index X uint8_t X; // index X
uint8_t Y; // index y uint8_t Y; // index y
uint8_t S; // stack pointer uint8_t SP; // stack pointer
uint8_t PC; // program counter uint8_t PC; // program counter
uint8_t P; // status flags uint8_t P; // status flags
} CPU6502; } CPU6502;