Long standing assembler bugs fixed, new path system. Make compatibility update.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
; A Fibonacci number generating program that uses two bytes to store the value.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
start:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
; A Fibonacci number generating program that uses four bytes to store the value.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
start:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
; A Fibonacci number generating program that uses only one byte to store the value.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
start:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
; The initial pattern is a glider. ANSI terminal control codes redraw the field
|
||||
; in place. Press Ctrl-C to stop the emulator.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; This program asks the user for input, then prints whatever they input back to the console again.
|
||||
; It stores the input string in a buffer in the Data Memory.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# SplitBit Programs Makefile
|
||||
# Anachronaut
|
||||
#
|
||||
# Builds every SplitBit program into build/, and keeps track of which libraries
|
||||
# each one includes so that editing a library reassembles whatever depends on it.
|
||||
#
|
||||
# make Assemble everything.
|
||||
# make clean Throw away build/.
|
||||
# make run-hello Assemble and run one program.
|
||||
|
||||
ASM ?= ../Assembler
|
||||
EMU ?= ../SplitBit
|
||||
BUILD ?= build
|
||||
|
||||
# Libraries are included by bare name, so the assembler is told where to find them.
|
||||
INCLUDES = -I Libraries
|
||||
|
||||
# The programs worth building. Files in Libraries/ are left out because they have no
|
||||
# entry point of their own, and the ones in testPrograms/ are covered by 'make test'
|
||||
# in the parent directory.
|
||||
PROGRAMS = \
|
||||
hello.asm \
|
||||
printHello.asm \
|
||||
inputTest.asm \
|
||||
replCalculator.asm \
|
||||
Fibonacci/8bitFibonacci.asm \
|
||||
Fibonacci/16bitFibonacci.asm \
|
||||
Fibonacci/32bitFibonacci.asm \
|
||||
primeSieve/8bitSieve.asm \
|
||||
primeSieve/16bitSegmentedSieve.asm \
|
||||
gameOfLife/16x16Life.asm
|
||||
|
||||
BINARIES = $(PROGRAMS:%.asm=$(BUILD)/%.bin)
|
||||
DEPENDENCIES = $(BINARIES:.bin=.d)
|
||||
|
||||
all: $(BINARIES)
|
||||
|
||||
# -M writes out which source files went into the binary, in the form of a make rule.
|
||||
$(BUILD)/%.bin: %.asm
|
||||
@mkdir -p $(@D)
|
||||
$(ASM) $(INCLUDES) -M $(@:.bin=.d) -o $@ $<
|
||||
|
||||
# Assemble and run a single program, as in 'make run-hello'.
|
||||
run-%: $(BUILD)/%.bin
|
||||
$(EMU) $<
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD)
|
||||
|
||||
# Pull in the dependency rules written by -M above, so that touching a library
|
||||
# reassembles every program that includes it.
|
||||
-include $(DEPENDENCIES)
|
||||
|
||||
.PHONY: all clean
|
||||
@@ -9,7 +9,7 @@
|
||||
;
|
||||
; Output is hexadecimal (0002 through FFFD), separated by spaces.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
; This is an implementation of The Sieve of Eratosthenes that finds all the primes between 2 and 255.
|
||||
|
||||
#Include ../Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
; 10/27/2024
|
||||
|
||||
; Include the subroutine file.
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
; Whitespace is optional. Supported operators are + - * & | and ^.
|
||||
; Arithmetic wraps to eight bits. Enter Q to quit.
|
||||
|
||||
#Include Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; This program asks the user for input, then prints whatever they input back to the console again.
|
||||
; It stores the input string in a buffer in the Data Memory.
|
||||
|
||||
#Include ../Libraries/print.asm
|
||||
#Include print.asm
|
||||
|
||||
#Program
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
; A test for the new math subroutines.
|
||||
|
||||
#Include ../Libraries/print.asm
|
||||
#Include ../Libraries/int8.asm
|
||||
#Include ../Libraries/int16.asm
|
||||
#Include print.asm
|
||||
#Include int8.asm
|
||||
#Include int16.asm
|
||||
|
||||
#Program
|
||||
start:
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
; Tests LDD and STD, the instructions that move a Data Pointer through Data Memory.
|
||||
;
|
||||
; STD writes a pointer into memory, LDD reads one back out. Together they let a
|
||||
; program build and walk a table of addresses, which is the reason the CPU has
|
||||
; more than one Data Pointer to walk it with.
|
||||
;
|
||||
; Correct output is:
|
||||
; Hello
|
||||
; World
|
||||
; H
|
||||
|
||||
#Program
|
||||
|
||||
start:
|
||||
; Build a two entry address table at runtime.
|
||||
SETD.0 Slot0
|
||||
SETD.1 Hello
|
||||
STD.1.0 ; Write the address in DP1 to the memory addressed by DP0.
|
||||
SETD.0 Slot1
|
||||
SETD.1 World
|
||||
STD.1.0
|
||||
|
||||
; Walk the table, following each entry in turn.
|
||||
SETD.0 Slot0
|
||||
LDD.1.0 ; DP1 becomes the address stored at DP0.
|
||||
CALL printDP1
|
||||
DPUP.0 0d02 ; Step DP0 over the two byte entry.
|
||||
LDD.1.0
|
||||
CALL printDP1
|
||||
|
||||
; A pointer can also follow itself, which is what LDD with one pointer means.
|
||||
SETD.0 Slot0
|
||||
LDD.0.0 ; DP0 becomes the address it was pointing at.
|
||||
LDA.0
|
||||
OUTA 0x00
|
||||
INIA 0x0A
|
||||
OUTA 0x00
|
||||
HALT
|
||||
|
||||
printDP1:
|
||||
; Print the string addressed by DP1. DP1 is preserved across the CALL, so the
|
||||
; caller gets it back untouched.
|
||||
LDA.1
|
||||
BRA printDone
|
||||
OUTA 0x00
|
||||
INCD.1
|
||||
BRI printDP1
|
||||
printDone:
|
||||
INIA 0x0A
|
||||
OUTA 0x00
|
||||
RET
|
||||
|
||||
#Data
|
||||
|
||||
Hello:
|
||||
"Hello"
|
||||
|
||||
World:
|
||||
"World"
|
||||
|
||||
; The table itself. Two entries, two bytes each, filled in at run time.
|
||||
Slot0:
|
||||
0x00 0x00
|
||||
Slot1:
|
||||
0x00 0x00
|
||||
@@ -1,6 +1,6 @@
|
||||
; Tests for the printing subroutines provided by print.asm
|
||||
|
||||
#Include ../Libraries/print.asm
|
||||
#Include print.asm
|
||||
#Include printDigitTest.asm
|
||||
#Include printDecimalTest.asm
|
||||
#Include printHexTest.asm
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
; Tests address tables written down by the assembler.
|
||||
;
|
||||
; Naming a label in the Data Segment places its two byte address there. That is
|
||||
; what lets a program lay down a table of addresses ahead of time and walk it
|
||||
; with LDD, rather than having to build the table at run time with STD.
|
||||
;
|
||||
; The label after the table also checks that the assembler counts those two
|
||||
; bytes when it works out the addresses of everything that follows.
|
||||
;
|
||||
; Correct output is:
|
||||
; one
|
||||
; two
|
||||
; three
|
||||
; AFTER
|
||||
|
||||
#Program
|
||||
|
||||
start:
|
||||
SETD.0 Table
|
||||
INIB 0d3 ; Three entries in the table.
|
||||
|
||||
nextEntry:
|
||||
LDD.1.0 ; DP1 becomes the address held in this table slot.
|
||||
CALL printDP1
|
||||
DPUP.0 0d02 ; Step DP0 over the two byte slot.
|
||||
DECB
|
||||
BRB tableDone
|
||||
BRI nextEntry
|
||||
|
||||
tableDone:
|
||||
; Anything placed after the table has to be where the assembler said it was.
|
||||
SETD.2 After
|
||||
CALL printDP2
|
||||
HALT
|
||||
|
||||
printDP1:
|
||||
LDA.1
|
||||
BRA print1Done
|
||||
OUTA 0x00
|
||||
INCD.1
|
||||
BRI printDP1
|
||||
print1Done:
|
||||
INIA 0x0A
|
||||
OUTA 0x00
|
||||
RET
|
||||
|
||||
printDP2:
|
||||
LDA.2
|
||||
BRA print2Done
|
||||
OUTA 0x00
|
||||
INCD.2
|
||||
BRI printDP2
|
||||
print2Done:
|
||||
INIA 0x0A
|
||||
OUTA 0x00
|
||||
RET
|
||||
|
||||
#Data
|
||||
|
||||
One:
|
||||
"one"
|
||||
Two:
|
||||
"two"
|
||||
Three:
|
||||
"three"
|
||||
|
||||
; The table. Each of these names becomes the two byte address of that string.
|
||||
Table:
|
||||
One
|
||||
Two
|
||||
Three
|
||||
|
||||
After:
|
||||
"AFTER"
|
||||
Reference in New Issue
Block a user