OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /eco32/tags/eco32-0.25/simtest/rom
    from Rev 37 to Rev 248
    Reverse comparison

Rev 37 → Rev 248

/rom08.s
0,0 → 1,36
;
; rom08.s -- string output with delay loop
;
 
; $8 I/O base address
; $9 temporary value
; $10 character
; $11 pointer to string
; $31 return address
 
.set oba,0xF0300000
 
add $8,$0,oba
add $11,$0,hello
loop:
ldbu $10,$11,0
stop:
beq $10,$0,stop
jal out
add $11,$11,1
jal delay
j loop
 
out:
stw $10,$8,12
jr $31
 
delay:
add $9,$0,0x00200000
del1:
sub $9,$9,1
bne $9,$0,del1
jr $31
 
hello:
.byte "Hello, world!", 0x0D, 0x0A, 0
/rom09.s
0,0 → 1,41
;
; rom09.s -- string output with timing loop
;
 
; $8 I/O base address
; $9 temporary value
; $10 character
; $11 pointer to string
; $12 timer base address
; $13 timer value
; $31 return address
 
.set oba,0xF0300000
.set tba,0xF0000000
 
add $8,$0,oba
add $12,$0,tba
add $11,$0,hello
loop:
ldbu $10,$11,0
stop:
beq $10,$0,stop
jal out
add $11,$11,1
jal timing
j loop
 
out:
stw $10,$8,12
jr $31
 
timing:
ldw $13,$12,8
sub $9,$13,0x03C00000
tim1:
ldw $13,$12,8
bgtu $13,$9,tim1
jr $31
 
hello:
.byte "Hello, world!", 0x0D, 0x0A, 0
/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,0xF0301000
 
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
/rom06.s
0,0 → 1,30
;
; rom06.s -- "crossed" echo with two terminals, polled
;
 
.set tba0,0xF0300000 ; terminal base address 0
.set tba1,0xF0301000 ; terminal base address 1
 
add $8,$0,tba0 ; set $8 to terminal base address 0
add $9,$0,tba1 ; set $9 to terminal base address 1
L1:
ldw $10,$8,0 ; load receiver status into $10
and $10,$10,1 ; check receiver ready
beq $10,$0,L3 ; not ready - check other terminal
ldw $11,$8,4 ; load receiver data into $11
L2:
ldw $10,$9,8 ; load transmitter status into $10
and $10,$10,1 ; check transmitter ready
beq $10,$0,L2 ; loop while not ready
stw $11,$9,12 ; load char into transmitter data
L3:
ldw $10,$9,0 ; load receiver status into $10
and $10,$10,1 ; check receiver ready
beq $10,$0,L1 ; not ready - check other terminal
ldw $11,$9,4 ; load receiver data into $11
L4:
ldw $10,$8,8 ; load transmitter status into $10
and $10,$10,1 ; check transmitter ready
beq $10,$0,L4 ; loop while not ready
stw $11,$8,12 ; load char into transmitter data
j L1 ; all over again
/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
/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
/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'
/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
/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
/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
/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
/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
/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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.