Fix hello.asm.lisp, update others

This commit is contained in:
zongor 2025-09-21 12:50:05 -07:00
parent 91061fe3c0
commit 2f08c6893c
6 changed files with 19 additions and 19 deletions

View File

@ -1,6 +1,6 @@
# --- CONFIGURABLE DEFAULTS ---
PLATFORM ?= linux
BUILD_MODE ?= debug # 'debug' or 'deploy'
BUILD_MODE ?= debug # 'debug' or 'release'
# --- DIRECTORIES ---
SRC_DIR := src
@ -24,7 +24,7 @@ CORE_CFLAGS := $(BASE_CFLAGS) -std=c89 -ffreestanding -nostdlib -fno-builtin
PLATFORM_CFLAGS := $(BASE_CFLAGS)
# --- MODE & PLATFORM SPECIFIC FLAGS ---
ifeq ($(BUILD_MODE), deploy)
ifeq ($(BUILD_MODE), release)
CORE_CFLAGS += -O2 -DNDEBUG
PLATFORM_CFLAGS += -O2 -DNDEBUG
LDFLAGS += -s
@ -49,8 +49,8 @@ ifeq ($(PLATFORM), emscripten)
PLATFORM_CFLAGS += -s USE_SDL=2 -s WASM=1
LDFLAGS += -s USE_SDL=2 -s WASM=1
# For deploy: optimize, strip debug, minimize size
ifeq ($(BUILD_MODE), deploy)
# For release: optimize, strip debug, minimize size
ifeq ($(BUILD_MODE), release)
PLATFORM_CFLAGS += -O2
LDFLAGS += -O2 --closure 1
else
@ -74,7 +74,7 @@ VM_SOURCES := \
$(SRC_DIR)/vm/device.c \
$(SRC_DIR)/vm/str.c
ifeq ($(BUILD_MODE), deploy)
ifeq ($(BUILD_MODE), release)
PLATFORM_SOURCE := $(ARCH_DIR)/main.c \
$(ARCH_DIR)/devices.c
else
@ -91,7 +91,7 @@ PLATFORM_OBJ := $(PLATFORM_SOURCE:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# --- DEPENDENCIES ---
DEPS := $(VM_OBJS:.o=.d) $(PLATFORM_OBJ:.o=.d)
.PHONY: all debug deploy clean clean-all help
.PHONY: all debug release clean clean-all help
# Default target
all: $(TARGET)
@ -100,9 +100,9 @@ all: $(TARGET)
debug: BUILD_MODE = debug
debug: $(TARGET)
# 'deploy' target — just set BUILD_MODE and build
deploy: BUILD_MODE = deploy
deploy: $(TARGET)
# 'release' target — just set BUILD_MODE and build
release: BUILD_MODE = release
release: $(TARGET)
# --- COMPILE VM CORE (freestanding) ---
$(BUILD_DIR)/vm/%.o: $(SRC_DIR)/vm/%.c
@ -149,7 +149,7 @@ help:
@echo "Targets:"
@echo " make -> debug build (default: linux)"
@echo " make debug -> same as above"
@echo " make deploy -> optimized, stripped build"
@echo " make release -> optimized, stripped build"
@echo " make clean -> clean current platform"
@echo " make clean-all→ clean all platforms"
@echo ""

View File

@ -41,5 +41,5 @@ print_section "zre ($FILENAME.t.ul)"
echo "test input" | time ../build/old/zre -t "$FILENAME.ul"
# Undâr Implementation
#print_section "zre ($FILENAME.asm.lisp)"
# echo "test input" | time ../build/linux/zre-linux-release "../test/$FILENAME.asm.lisp"
print_section "undar ($FILENAME.asm.lisp)"
echo "test input" | time ../build/linux/undar-linux-release "../test/$FILENAME.asm.lisp"

View File

@ -6,7 +6,7 @@
(call &add)
(pop $0)
(int-to-string $1 $0)
(load $3 &terminal-str)
(load-immediate $3 &terminal-str)
(string-length $2 $1)
(syscall DEVICE-WRITE $3 $1 $2)
(halt))

View File

@ -5,7 +5,7 @@
(call &fib)
(pop $0)
(int-to-string $1 $0)
(load $2, &terminal-str)
(load-immediate $2, &terminal-str)
(string-length $4, $3)
(syscall DEVICE-WRITE, $2, $1, $4)
(halt))

View File

@ -1,10 +1,10 @@
((code
(label main
(load $0 &terminal-str)
(load $1 &hello-str)
(load-immediate $0 &terminal-str)
(load-immediate $1 &hello-str)
(string-length $2 $1)
(syscall DEVICE_WRITE $0 $1 $2)
(load $3 &new-line)
(syscall DEVICE-WRITE $0 $1 $2)
(load-immediate $3 &new-line)
(string-length $4 $3)
(syscall DEVICE-WRITE $0 $3 $4)
(halt)))

View File

@ -11,7 +11,7 @@
(add-int $1 $1 $3)
(jump-gt-eq-int $4 $1 $2)
(real-to-nat $1 $0)
(load $6 &terminal-str)
(load-immediate $6 &terminal-str)
(load $7 &help)
(string-length $8 $7)
(syscall DEVICE-WRITE $6 $7 $8)