URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Subversion Repositories eco32
Compare Revisions
- This comparison shows the changes necessary to convert path
/eco32/trunk
- from Rev 8 to Rev 9
- ↔ Reverse comparison
Rev 8 → Rev 9
/simtest/Makefile.run
0,0 → 1,64
# |
# Makefile to run some simulator tests |
# |
|
BUILD = .. |
|
LOGFILE = run.log |
|
DSKNAME = system.disk |
DSKSIZE = 14000 |
MBRNAME = mbr.bin |
|
.PHONY: all clean |
|
all: |
@echo "Please choose one of the following targets:" |
@echo " run-rom00 (test ROM byte order)" |
@echo " run-rom01 (one example of each instruction)" |
@echo " run-rom02 (terminal output, polled)" |
@echo " run-rom03 (terminal echo, polled)" |
@echo " run-rom04 (\"Hello, world!\")" |
@echo " run-rom05 (\"Hello, world!\", on terminal 1)" |
@echo " run-rom06 (crossed echo with two terminals)" |
@echo " run-rom07 (string output to output device)" |
@echo " run-rom10 (console character attributes)" |
@echo " run-romboot (ROM bootstrapping disk)" |
@echo " clean" |
|
$(DSKNAME): |
./mkdisk $(DSKNAME) $(DSKSIZE) |
./wrtmbr $(DSKNAME) $(MBRNAME) |
|
run-rom00: |
$(BUILD)/bin/sim -i -r rom00.bin |
|
run-rom01: |
$(BUILD)/bin/sim -i -r rom01.bin |
|
run-rom02: |
$(BUILD)/bin/sim -i -r rom02.bin -t 1 |
|
run-rom03: |
$(BUILD)/bin/sim -i -r rom03.bin -t 1 |
|
run-rom04: |
$(BUILD)/bin/sim -i -r rom04.bin -t 1 |
|
run-rom05: |
$(BUILD)/bin/sim -i -r rom05.bin -t 2 |
|
run-rom06: |
$(BUILD)/bin/sim -i -r rom06.bin -t 2 |
|
run-rom07: |
$(BUILD)/bin/sim -i -r rom07.bin -o $(LOGFILE) |
|
run-rom10: |
$(BUILD)/bin/sim -i -r rom10.bin -c |
|
run-romboot: $(DSKNAME) |
$(BUILD)/bin/sim -i -r romboot.bin -t 1 -d $(DSKNAME) |
|
clean: |
rm -f *~ $(LOGFILE) $(DSKNAME) |
/simtest/disk/mkdisk/mkdisk.c
0,0 → 1,75
/* |
* mkdisk.c -- make an empty physical disk |
*/ |
|
|
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdarg.h> |
|
|
#define SECTOR_SIZE 512 |
#define MIN_NUMBER_SECTORS 100 |
#define SECTORS_PER_MB ((1 << 20) / SECTOR_SIZE) |
#define DATA_BYTE 0xE5 |
|
|
void error(char *fmt, ...) { |
va_list ap; |
|
va_start(ap, fmt); |
fprintf(stderr, "Error: "); |
vfprintf(stderr, fmt, ap); |
fprintf(stderr, "\n"); |
va_end(ap); |
exit(1); |
} |
|
|
void usage(void) { |
fprintf(stderr, "Usage: mkdisk <file name> <n>[M]\n"); |
fprintf(stderr, " <n>: decimal number of sectors\n"); |
fprintf(stderr, " if 'M' appended: megabytes instead of sectors\n"); |
fprintf(stderr, " (sector size is always %d bytes)\n", SECTOR_SIZE); |
exit(1); |
} |
|
|
int main(int argc, char *argv[]) { |
FILE *dskFile; |
int numSectors; |
unsigned char sectorBuffer[SECTOR_SIZE]; |
int i; |
|
if (argc != 3) { |
usage(); |
} |
numSectors = atoi(argv[2]); |
i = strlen(argv[2]) - 1; |
if (argv[2][i] == 'M') { |
numSectors *= SECTORS_PER_MB; |
} |
if (numSectors < MIN_NUMBER_SECTORS) { |
error("this disk is too small to be useful (minimum size is %d sectors)", |
MIN_NUMBER_SECTORS); |
} |
dskFile = fopen(argv[1], "wb"); |
if (dskFile == NULL) { |
error("cannot open file '%s' for write", argv[1]); |
} |
fprintf(stdout, |
"Creating disk '%s' with %d sectors (around %d MB)...\n", |
argv[1], numSectors, |
(numSectors + SECTORS_PER_MB / 2) / SECTORS_PER_MB); |
for (i = 0; i < SECTOR_SIZE; i++) { |
sectorBuffer[i] = DATA_BYTE; |
} |
for (i = 0; i < numSectors; i++) { |
if (fwrite(sectorBuffer, SECTOR_SIZE, 1, dskFile) != 1) { |
error("write error on file '%s', sector %d", argv[1], i); |
} |
} |
fclose(dskFile); |
return 0; |
} |
/simtest/disk/mkdisk/Makefile
0,0 → 1,36
# |
# Makefile for disk creator |
# |
|
BUILD = ../../../build |
|
CC = gcc -m32 |
CFLAGS = -g -Wall |
LDFLAGS = -g |
LDLIBS = -lm |
|
SRCS = mkdisk.c |
OBJS = $(patsubst %.c,%.o,$(SRCS)) |
BIN = mkdisk |
|
.PHONY: all install clean |
|
all: $(BIN) |
|
install: $(BIN) |
mkdir -p $(BUILD)/simtest |
cp $(BIN) $(BUILD)/simtest |
|
$(BIN): $(OBJS) |
$(CC) $(LDFLAGS) -o $(BIN) $(OBJS) $(LDLIBS) |
|
%.o: %.c |
$(CC) $(CFLAGS) -o $@ -c $< |
|
depend.mak: |
$(CC) -MM -MG $(CFLAGS) $(SRCS) > depend.mak |
|
-include depend.mak |
|
clean: |
rm -f *~ $(OBJS) $(BIN) depend.mak |
/simtest/disk/mkmbr/mbr.s
0,0 → 1,49
; |
; mbr.s -- the master boot record |
; |
|
; $8 I/O base address |
; $9 temporary value |
; $10 character |
; $11 pointer to string |
; $29 stack pointer |
; $31 return address |
|
.set tba,0xF0300000 ; terminal base address |
|
start: |
sub $29,$29,4 ; save return register |
stw $31,$29,0 |
add $8,$0,tba ; set I/O base address |
add $11,$0,msg ; pointer to string |
loop: |
ldbu $10,$11,0 ; get char |
beq $10,$0,stop ; null - finished |
jal out ; output char |
add $11,$11,1 ; bump pointer |
j loop ; next char |
stop: |
ldw $31,$29,0 ; restore return register |
add $29,$29,4 |
jr $31 ; return |
|
out: |
ldw $9,$8,8 ; get status |
and $9,$9,1 ; xmtr ready? |
beq $9,$0,out ; no - wait |
stw $10,$8,12 ; send char |
jr $31 ; return |
|
msg: |
.byte 0x0D, 0x0A |
.byte "Error: This is the default MBR, " |
.byte "which cannot load anything." |
.byte 0x0D, 0x0A |
.byte "Please replace the disk, or " |
.byte "write an operating system onto it." |
.byte 0x0D, 0x0A |
.byte 0x0D, 0x0A, 0 |
|
.locate 512-2 |
sign: |
.byte 0x55, 0xAA |
/simtest/disk/mkmbr/Makefile
0,0 → 1,27
# |
# Makefile for assembling the master boot record |
# |
|
BUILD = ../../../build |
|
SFILES = $(wildcard *.s) |
OBJFILES = $(patsubst %.s,%.o,$(SFILES)) |
BINFILES = $(patsubst %.s,%.bin,$(SFILES)) |
|
.PHONY: all install clean |
.PRECIOUS: $(OBJFILES) |
|
all: $(BINFILES) |
|
install: $(BINFILES) |
mkdir -p $(BUILD)/simtest |
cp $(BINFILES) $(BUILD)/simtest |
|
%.bin: %.o |
$(BUILD)/bin/ld -h -rc 0xC0000000 -o $@ $< |
|
%.o: %.s |
$(BUILD)/bin/as -o $@ $< |
|
clean: |
rm -f *~ *.bin *.o |
/simtest/disk/wrtmbr/Makefile
0,0 → 1,36
# |
# Makefile for a program which writes the master boot record to the disk |
# |
|
BUILD = ../../../build |
|
CC = gcc -m32 |
CFLAGS = -g -Wall |
LDFLAGS = -g |
LDLIBS = -lm |
|
SRCS = wrtmbr.c |
OBJS = $(patsubst %.c,%.o,$(SRCS)) |
BIN = wrtmbr |
|
.PHONY: all install clean |
|
all: $(BIN) |
|
install: $(BIN) |
mkdir -p $(BUILD)/simtest |
cp $(BIN) $(BUILD)/simtest |
|
$(BIN): $(OBJS) |
$(CC) $(LDFLAGS) -o $(BIN) $(OBJS) $(LDLIBS) |
|
%.o: %.c |
$(CC) $(CFLAGS) -o $@ -c $< |
|
depend.mak: |
$(CC) -MM -MG $(CFLAGS) $(SRCS) > depend.mak |
|
-include depend.mak |
|
clean: |
rm -f *~ $(OBJS) $(BIN) depend.mak |
/simtest/disk/wrtmbr/wrtmbr.c
0,0 → 1,76
/* |
* wrtmbr.c -- write the master boot record to the disk |
*/ |
|
|
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdarg.h> |
|
|
#define SECTOR_SIZE 512 |
|
|
void error(char *fmt, ...) { |
va_list ap; |
|
va_start(ap, fmt); |
fprintf(stderr, "Error: "); |
vfprintf(stderr, fmt, ap); |
fprintf(stderr, "\n"); |
va_end(ap); |
exit(1); |
} |
|
|
void usage(char *myself) { |
fprintf(stderr, |
"Usage: %s <disk file> <master boot record file>\n", |
myself); |
exit(1); |
} |
|
|
int main(int argc, char *argv[]) { |
FILE *diskFile; |
FILE *bootFile; |
unsigned char sectorBuffer[SECTOR_SIZE]; |
|
if (argc != 3) { |
usage(argv[0]); |
} |
diskFile = fopen(argv[1], "r+b"); |
if (diskFile == NULL) { |
error("cannot open disk file '%s'", argv[1]); |
} |
bootFile = fopen(argv[2], "rb"); |
if (bootFile == NULL) { |
error("cannot open boot sector file '%s'", argv[2]); |
} |
if (fseek(bootFile, 0, SEEK_END) != 0) { |
error("cannot position to end of boot sector file"); |
} |
if (ftell(bootFile) != SECTOR_SIZE) { |
error("'%s' is not a proper boot sector file (wrong length)", argv[2]); |
} |
if (fseek(bootFile, 0, SEEK_SET) != 0) { |
error("cannot position to start of boot sector file"); |
} |
if (fread(sectorBuffer, SECTOR_SIZE, 1, bootFile) != 1) { |
error("cannot read data from boot sector file"); |
} |
fclose(bootFile); |
if (sectorBuffer[SECTOR_SIZE - 2] != 0x55 || |
sectorBuffer[SECTOR_SIZE - 1] != 0xAA) { |
error("'%s' is not a proper boot sector file (no signature)", argv[2]); |
} |
if (fseek(diskFile, 0, SEEK_SET) != 0) { |
error("cannot position to start of disk file"); |
} |
if (fwrite(sectorBuffer, 1, SECTOR_SIZE, diskFile) != SECTOR_SIZE) { |
error("cannot write boot sector to disk file"); |
} |
fclose(diskFile); |
return 0; |
} |
/simtest/disk/Makefile
0,0 → 1,25
# |
# Makefile for building disk tools for simulator tests |
# |
|
BUILD = ../build |
|
DIRS = mkdisk mkmbr wrtmbr |
|
.PHONY: all install clean |
|
all: |
for i in $(DIRS) ; do \ |
$(MAKE) -C $$i all ; \ |
done |
|
install: |
for i in $(DIRS) ; do \ |
$(MAKE) -C $$i install ; \ |
done |
|
clean: |
for i in $(DIRS) ; do \ |
$(MAKE) -C $$i clean ; \ |
done |
rm -f *~ |
/simtest/rom/rom01.s
0,0 → 1,77
; |
; rom01.s -- one example of each ECO32 instruction |
; |
|
add $5,$2,$13 |
add $5,$2,13 |
sub $5,$2,$13 |
sub $5,$2,13 |
|
mul $5,$2,$13 |
mul $5,$2,13 |
mulu $5,$2,$13 |
mulu $5,$2,13 |
div $5,$2,$13 |
div $5,$2,13 |
divu $5,$2,$13 |
divu $5,$2,13 |
rem $5,$2,$13 |
rem $5,$2,13 |
remu $5,$2,$13 |
remu $5,$2,13 |
|
and $5,$2,$13 |
and $5,$2,13 |
or $5,$2,$13 |
or $5,$2,13 |
xor $5,$2,$13 |
xor $5,$2,13 |
xnor $5,$2,$13 |
xnor $5,$2,13 |
|
sll $5,$2,$13 |
sll $5,$2,13 |
slr $5,$2,$13 |
slr $5,$2,13 |
sar $5,$2,$13 |
sar $5,$2,13 |
|
ldhi $5,L1 |
|
L1: |
beq $5,$2,L1 |
bne $5,$2,L2 |
ble $5,$2,L1 |
bleu $5,$2,L2 |
blt $5,$2,L1 |
bltu $5,$2,L2 |
bge $5,$2,L1 |
bgeu $5,$2,L2 |
bgt $5,$2,L1 |
bgtu $5,$2,L2 |
|
j L1 |
jr $5 |
jal L2 |
jalr $5 |
L2: |
|
trap 0x1234DEAD |
rfx |
|
ldw $5,$2,13 |
ldh $5,$2,13 |
ldhu $5,$2,-13 |
ldb $5,$2,13 |
ldbu $5,$2,-13 |
|
stw $5,$2,13 |
sth $5,$2,-13 |
stb $5,$2,13 |
|
mvfs $5,1 |
mvts $5,1 |
tbs |
tbwr |
tbri |
tbwi |
/simtest/rom/rom10.s
0,0 → 1,30
; |
; rom10.s -- output to console using every possible attribute |
; |
|
; $8 row number |
; $9 column number |
; $10 temporary |
; $11 attribute/character |
|
.set dsp_base,0xF0100000 |
|
add $8,$0,0 ; start with row = 0 |
add $9,$0,0 ; start with col = 0 |
add $11,$0,0x0000+'A' ; char is always 'A' |
next: |
; addr = dsp_base + (row * 128 + column) * 4 |
sll $10,$8,7 |
add $10,$10,$9 |
sll $10,$10,2 |
stw $11,$10,dsp_base ; write to display memory |
add $11,$11,0x0100 ; next attribute (bits 15:8) |
add $9,$9,1 ; next col |
add $10,$0,16 |
bne $9,$10,next |
add $9,$0,0 ; reset col |
add $8,$8,1 ; next row |
add $10,$0,16 |
bne $8,$10,next |
stop: |
j stop |
/simtest/rom/rom02.s
0,0 → 1,18
; |
; rom02.s -- terminal output, polled |
; |
|
.set tba,0xF0300000 ; terminal base address |
|
add $8,$0,tba ; set terminal base address |
L1: |
add $10,$0,'a' ; set char to ASCII 'a' |
L2: |
ldw $9,$8,8 ; load transmitter status word into $9 |
and $9,$9,1 ; extract LSB - 'transmitter ready' |
beq $9,$0,L2 ; loop while not ready |
stw $10,$8,12 ; load char into transmitter data register |
add $10,$10,1 ; next char |
sub $9,$10,'z'+1 ; check if above 'z' |
bne $9,$0,L2 ; no - loop |
j L1 ; else reset to 'a' |
/simtest/rom/rom03.s
0,0 → 1,18
; |
; rom03.s -- terminal echo, polled |
; |
|
.set tba,0xF0300000 ; terminal base address |
|
add $8,$0,tba ; set terminal base address |
L1: |
ldw $9,$8,0 ; load receiver status into $9 |
and $9,$9,1 ; check receiver ready |
beq $9,$0,L1 ; loop while not ready |
ldw $10,$8,4 ; load receiver data into $10 |
L2: |
ldw $9,$8,8 ; load transmitter status into $9 |
and $9,$9,1 ; check transmitter ready |
beq $9,$0,L2 ; loop while not ready |
stw $10,$8,12 ; load char into transmitter data |
j L1 ; all over again |
/simtest/rom/rom04.s
0,0 → 1,31
; |
; rom04.s -- Hello, world! |
; |
|
; $8 I/O base address |
; $9 temporary value |
; $10 character |
; $11 pointer to string |
; $31 return address |
|
.set tba,0xF0300000 |
|
add $8,$0,tba |
add $11,$0,hello |
loop: |
ldbu $10,$11,0 |
stop: |
beq $10,$0,stop |
jal out |
add $11,$11,1 |
j loop |
|
out: |
ldw $9,$8,8 |
and $9,$9,1 |
beq $9,$0,out |
stw $10,$8,12 |
jr $31 |
|
hello: |
.byte "Hello, world!", 0x0D, 0x0A, 0 |
/simtest/rom/romboot.s
0,0 → 1,267
; |
; romboot.s -- the ROM bootstrap |
; |
|
.set termbase,0xF0300000 ; terminal base address |
.set diskbase,0xF0400000 ; disk base address |
.set diskbuffer,0xF0480000 ; disk buffer address |
.set virtbase,0xC0000000 ; base of kernel virtual addresses |
.set virtboot,0xC0000000 ; where to start the bootstrap sector |
.set stacktop,0xC0100000 ; where the stack is located |
|
.set PSW,0 |
.set TLB_INDEX,1 |
.set TLB_ENTRY_HI,2 |
.set TLB_ENTRY_LO,3 |
.set TLB_ENTRIES,32 |
|
.code |
|
reset: |
j start |
|
interrupt: |
j interrupt |
|
miss: |
j miss |
|
start: |
mvts $0,PSW ; disable interrupts and user mode |
mvts $0,TLB_ENTRY_LO ; invalidate all TLB entries |
add $8,$0,virtbase ; by impossible virtual page number |
add $9,$0,$0 |
add $10,$0,TLB_ENTRIES |
tlblp: |
mvts $8,TLB_ENTRY_HI |
mvts $9,TLB_INDEX |
tbwi |
add $8,$8,0x1000 ; all entries must be different |
add $9,$9,1 |
bne $9,$10,tlblp |
add $29,$0,stacktop ; set stack pointer |
add $4,$0,signon ; show sign-on message |
jal mout |
cmdlp: |
add $4,$0,prompt ; show prompt |
jal mout |
jal echo |
sub $8,$2,0x0D ; '<ret>'? |
beq $8,$0,rcmdlp |
sub $8,$2,'b' ; 'b'? |
beq $8,$0,boot |
add $4,$0,'?' ; unknown command |
jal cout |
rcmdlp: |
jal crlf |
j cmdlp |
|
boot: |
jal crlf |
add $8,$0,diskbase ; check if disk present |
add $9,$0,1000000 ; retry count |
boot1: |
ldw $16,$8,0 ; get status |
and $10,$16,0x20 ; check if disk ready |
bne $10,$0,boot2 ; ready - exit loop |
sub $9,$9,1 |
bne $9,$0,boot1 ; try again |
j nodsk ; enough retries - error |
boot2: |
ldw $16,$8,12 ; check if capacity greater than 0 |
beq $16,$0,nodsk ; no - report error |
add $4,$0,dfmsg ; say that we found a disk |
jal mout |
add $4,$16,$0 ; and how many sectors it has |
jal wout |
add $4,$0,sctmsg |
jal mout |
add $8,$0,diskbase ; try to load the boot sector |
add $9,$0,1 ; sector count |
stw $9,$8,4 |
add $9,$0,0 ; first sector |
stw $9,$8,8 |
add $9,$0,1 ; start command |
stw $9,$8,0 |
dskwt: |
ldw $9,$8,0 |
and $9,$9,0x10 ; done? |
beq $9,$0,dskwt |
ldw $9,$8,0 |
and $9,$9,0x08 ; error? |
bne $9,$0,dskerr |
add $8,$0,diskbuffer ; copy sector |
add $9,$0,virtboot |
add $10,$0,512 |
dskcp: |
ldw $11,$8,0 |
stw $11,$9,0 |
add $8,$8,4 |
add $9,$9,4 |
sub $10,$10,4 |
bne $10,$0,dskcp |
add $8,$0,virtboot ; signature present? |
ldbu $9,$8,512-2 |
sub $9,$9,0x55 |
bne $9,$0,nosig |
ldbu $9,$8,512-1 |
sub $9,$9,0xAA |
bne $9,$0,nosig |
jalr $8 ; finally... lift off |
j cmdlp ; in case we ever return to here |
|
nodsk: |
add $4,$0,dnfmsg ; there is no disk |
jal mout |
j cmdlp |
|
dskerr: |
add $4,$0,demsg ; disk error |
jal mout |
j cmdlp |
|
nosig: |
add $4,$0,nsgmsg ; no signature |
jal mout |
j cmdlp |
|
crlf: |
sub $29,$29,4 |
stw $31,$29,0 |
add $4,$0,0x0D |
jal cout |
add $4,$0,0x0A |
jal cout |
ldw $31,$29,0 |
add $29,$29,4 |
jr $31 |
|
mout: |
sub $29,$29,8 |
stw $31,$29,4 |
stw $16,$29,0 |
add $16,$4,$0 |
mout1: |
ldbu $4,$16,0 |
beq $4,$0,mout2 |
jal cout |
add $16,$16,1 |
j mout1 |
mout2: |
ldw $16,$29,0 |
ldw $31,$29,4 |
add $29,$29,8 |
jr $31 |
|
wout: |
sub $29,$29,8 |
stw $31,$29,4 |
stw $16,$29,0 |
add $16,$4,$0 |
slr $4,$16,16 |
jal hout |
add $4,$16,$0 |
jal hout |
ldw $16,$29,0 |
ldw $31,$29,4 |
add $29,$29,8 |
jr $31 |
|
hout: |
sub $29,$29,8 |
stw $31,$29,4 |
stw $16,$29,0 |
add $16,$4,$0 |
slr $4,$16,8 |
jal bout |
add $4,$16,$0 |
jal bout |
ldw $16,$29,0 |
ldw $31,$29,4 |
add $29,$29,8 |
jr $31 |
|
bout: |
sub $29,$29,8 |
stw $31,$29,4 |
stw $16,$29,0 |
add $16,$4,$0 |
slr $4,$16,4 |
jal nout |
add $4,$16,$0 |
jal nout |
ldw $16,$29,0 |
ldw $31,$29,4 |
add $29,$29,8 |
jr $31 |
|
nout: |
sub $29,$29,4 |
stw $31,$29,0 |
and $4,$4,0x0F |
add $4,$4,0x30 |
sub $8,$4,0x3A |
blt $8,$0,nout1 |
add $4,$4,7 |
nout1: |
jal cout |
ldw $31,$29,0 |
add $29,$29,4 |
jr $31 |
|
cin: |
add $8,$0,termbase |
cin1: |
ldw $9,$8,0 |
and $9,$9,1 |
beq $9,$0,cin1 |
ldw $2,$8,4 |
jr $31 |
|
cout: |
add $8,$0,termbase |
cout1: |
ldw $9,$8,8 |
and $9,$9,1 |
beq $9,$0,cout1 |
stw $4,$8,12 |
jr $31 |
|
echo: |
sub $29,$29,4 |
stw $31,$29,0 |
jal cin |
add $4,$0,$2 |
jal cout |
ldw $31,$29,0 |
add $29,$29,4 |
jr $31 |
|
signon: |
.byte 0x0D, 0x0A |
.byte "ROM Bootstrap Version 1" |
.byte 0x0D, 0x0A, 0x0D, 0x0A, 0 |
|
prompt: |
.byte "#" |
.byte 0 |
|
dnfmsg: |
.byte "Disk not found!" |
.byte 0x0D, 0x0A, 0 |
|
dfmsg: |
.byte "Disk with 0x" |
.byte 0 |
|
sctmsg: |
.byte " sectors found, booting..." |
.byte 0x0D, 0x0A, 0 |
|
demsg: |
.byte "Disk error!" |
.byte 0x0D, 0x0A, 0 |
|
nsgmsg: |
.byte "MBR signature missing!" |
.byte 0x0D, 0x0A, 0 |
/simtest/rom/rom05.s
0,0 → 1,31
; |
; rom05.s -- Hello, world! (on terminal 1 instead of terminal 0) |
; |
|
; $8 I/O base address |
; $9 temporary value |
; $10 character |
; $11 pointer to string |
; $31 return address |
|
.set tba,0xF0300010 |
|
add $8,$0,tba |
add $11,$0,hello |
loop: |
ldbu $10,$11,0 |
stop: |
beq $10,$0,stop |
jal out |
add $11,$11,1 |
j loop |
|
out: |
ldw $9,$8,8 |
and $9,$9,1 |
beq $9,$0,out |
stw $10,$8,12 |
jr $31 |
|
hello: |
.byte "Hello, world!", 0x0D, 0x0A, 0 |
/simtest/rom/rom06.s
0,0 → 1,28
; |
; rom06.s -- "crossed" echo with two terminals, polled |
; |
|
.set tba,0xF0300000 ; terminal base address |
|
add $8,$0,tba ; set terminal base address |
L1: |
ldw $9,$8,0 ; load receiver status into $9 |
and $9,$9,1 ; check receiver ready |
beq $9,$0,L3 ; not ready - check other terminal |
ldw $10,$8,4 ; load receiver data into $10 |
L2: |
ldw $9,$8,24 ; load transmitter status into $9 |
and $9,$9,1 ; check transmitter ready |
beq $9,$0,L2 ; loop while not ready |
stw $10,$8,28 ; load char into transmitter data |
L3: |
ldw $9,$8,16 ; load receiver status into $9 |
and $9,$9,1 ; check receiver ready |
beq $9,$0,L1 ; not ready - check other terminal |
ldw $10,$8,20 ; load receiver data into $10 |
L4: |
ldw $9,$8,8 ; load transmitter status into $9 |
and $9,$9,1 ; check transmitter ready |
beq $9,$0,L4 ; loop while not ready |
stw $10,$8,12 ; load char into transmitter data |
j L1 ; all over again |
/simtest/rom/rom07.s
0,0 → 1,28
; |
; rom07.s -- string output to output device |
; |
|
; $8 I/O base address |
; $9 temporary value |
; $10 character |
; $11 pointer to string |
; $31 return address |
|
.set oba,0xFF000000 |
|
add $8,$0,oba |
add $11,$0,hello |
loop: |
ldbu $10,$11,0 |
stop: |
beq $10,$0,stop |
jal out |
add $11,$11,1 |
j loop |
|
out: |
stw $10,$8,0 |
jr $31 |
|
hello: |
.byte "Hello, world!", 0x0D, 0x0A, 0 |
/simtest/rom/Makefile
0,0 → 1,27
# |
# Makefile for assembling different system ROMs |
# |
|
BUILD = ../../build |
|
SFILES = $(wildcard *.s) |
OBJFILES = $(patsubst %.s,%.o,$(SFILES)) |
BINFILES = $(patsubst %.s,%.bin,$(SFILES)) |
|
.PHONY: all install clean |
.PRECIOUS: $(OBJFILES) |
|
all: $(BINFILES) |
|
install: $(BINFILES) |
mkdir -p $(BUILD)/simtest |
cp $(BINFILES) $(BUILD)/simtest |
|
%.bin: %.o |
$(BUILD)/bin/ld -h -rc 0xE0000000 -o $@ $< |
|
%.o: %.s |
$(BUILD)/bin/as -o $@ $< |
|
clean: |
rm -f *~ *.bin *.o |
/simtest/rom/rom00.s
0,0 → 1,36
; |
; rom00.s -- test ROM byte order |
; |
|
.byte 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 |
.byte 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F |
.byte 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 |
.byte 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F |
.byte 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 |
.byte 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F |
.byte 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 |
.byte 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F |
.byte 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 |
.byte 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F |
.byte 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 |
.byte 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F |
.byte 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 |
.byte 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F |
.byte 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 |
.byte 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F |
.byte 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 |
.byte 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F |
.byte 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 |
.byte 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F |
.byte 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7 |
.byte 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF |
.byte 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7 |
.byte 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF |
.byte 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7 |
.byte 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF |
.byte 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7 |
.byte 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF |
.byte 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7 |
.byte 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF |
.byte 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7 |
.byte 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF |
/simtest/Makefile
0,0 → 1,27
# |
# Makefile for building ROMs and disk tools for simulator tests |
# |
|
BUILD = ../build |
|
DIRS = rom disk |
|
.PHONY: all install clean |
|
all: |
for i in $(DIRS) ; do \ |
$(MAKE) -C $$i all ; \ |
done |
|
install: |
for i in $(DIRS) ; do \ |
$(MAKE) -C $$i install ; \ |
done |
mkdir -p $(BUILD)/simtest |
cp Makefile.run $(BUILD)/simtest/Makefile |
|
clean: |
for i in $(DIRS) ; do \ |
$(MAKE) -C $$i clean ; \ |
done |
rm -f *~ |
/Makefile
4,7 → 4,7
|
VERSION = 0.23 |
|
DIRS = doc binutils sim |
DIRS = doc binutils sim simtest |
BUILD = `pwd`/build |
|
.PHONY: all compiler builddir clean dist |