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.22/stdalone/hello
    from Rev 18 to Rev 21
    Reverse comparison

Rev 18 → Rev 21

/hello.s
0,0 → 1,54
;
; hello.s -- Hello, world!
;
 
.set tba,0xF0300000 ; terminal base address
.set tos,0xC0010000 ; top of stack
 
; get some addresses listed in the load map
.export reset
.export start
.export out
.export hello
 
; minimal execution environment
reset:
add $29,$0,tos ; setup stack
jal start ; do useful work
reset1:
j reset1 ; halt by looping
 
; main program
start:
sub $29,$29,8 ; create stack frame
stw $31,$29,0 ; save return register
stw $16,$29,4 ; save register variable
add $16,$0,hello ; pointer to string
loop:
ldbu $4,$16,0 ; get char
beq $4,$0,stop ; null - finished
jal out ; output char
add $16,$16,1 ; bump pointer
j loop ; next char
stop:
ldw $31,$29,0 ; restore return register
ldw $16,$29,4 ; restore register variable
add $29,$29,8 ; release stack frame
jr $31 ; return
 
; output a character to the terminal
out:
add $8,$0,tba ; set I/O base address
out1:
ldw $9,$8,8 ; get xmtr status
and $9,$9,1 ; xmtr ready?
beq $9,$0,out1 ; no - wait
stw $4,$8,12 ; send char
jr $31 ; return
 
; a very famous little string...
hello:
.byte 0x0D, 0x0A
.byte "Hello, world!"
.byte 0x0D, 0x0A
.byte 0x0D, 0x0A, 0
/Makefile
0,0 → 1,32
#
# Makefile for "hello", a program for testing the boot loader
#
 
BUILD = ../../build
 
SRC = hello.s
OBJ = hello.o
BIN = hello.bin
MAP = hello.map
 
.PHONY: all install run clean
 
all: $(BIN)
 
install: $(BIN)
mkdir -p $(BUILD)/stdalone
cp $(BIN) $(BUILD)/stdalone
cp $(MAP) $(BUILD)/stdalone
 
run: $(BIN)
$(BUILD)/bin/sim -i -t 1 -l $(BIN)
 
$(BIN): $(OBJ)
$(BUILD)/bin/ld -h -rc 0xC0000000 \
-m $(MAP) -o $(BIN) $(OBJ)
 
$(OBJ): $(SRC)
$(BUILD)/bin/as -o $(OBJ) $(SRC)
 
clean:
rm -f *~ $(OBJ) $(BIN) $(MAP)

powered by: WebSVN 2.1.0

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