##################################################################
|
##################################################################
|
# TITLE: Boot Up Code
|
# TITLE: Boot Up Code
|
# AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
# AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
# DATE CREATED: 1/12/02
|
# DATE CREATED: 1/12/02
|
# FILENAME: boot.asm
|
# FILENAME: boot.asm
|
# PROJECT: Plasma CPU core
|
# PROJECT: Plasma CPU core
|
# COPYRIGHT: Software placed into the public domain by the author.
|
# COPYRIGHT: Software placed into the public domain by the author.
|
# Software 'as is' without warranty. Author liable for nothing.
|
# Software 'as is' without warranty. Author liable for nothing.
|
# DESCRIPTION:
|
# DESCRIPTION:
|
# Initializes the stack pointer and jumps to main2().
|
# Initializes the stack pointer and jumps to main2().
|
##################################################################
|
##################################################################
|
.text
|
.text
|
.align 2
|
.align 2
|
.globl entry
|
.globl entry
|
.ent entry
|
.ent entry
|
entry:
|
entry:
|
.set noreorder
|
.set noreorder
|
|
|
#These eight instructions must be the first instructions.
|
#These eight instructions must be the first instructions.
|
#convert.exe will correctly initialize $gp
|
#convert.exe will correctly initialize $gp
|
lui $gp,0
|
lui $gp,0
|
ori $gp,$gp,0
|
ori $gp,$gp,0
|
#convert.exe will set $4=.sbss_start $5=.bss_end
|
#convert.exe will set $4=.sbss_start $5=.bss_end
|
lui $4,0
|
lui $4,0
|
ori $4,$4,0
|
ori $4,$4,0
|
lui $5,0
|
lui $5,0
|
ori $5,$5,0
|
ori $5,$5,0
|
lui $sp,0
|
lui $sp,0
|
ori $sp,$sp,0xfff0 #initialize stack pointer
|
ori $sp,$sp,0xfff0 #initialize stack pointer
|
$BSS_CLEAR:
|
$BSS_CLEAR:
|
sw $0,0($4)
|
sw $0,0($4)
|
slt $3,$4,$5
|
slt $3,$4,$5
|
bnez $3,$BSS_CLEAR
|
bnez $3,$BSS_CLEAR
|
addiu $4,$4,4
|
addiu $4,$4,4
|
|
|
jal main2
|
jal main2
|
nop
|
nop
|
$L1:
|
$L1:
|
j $L1
|
j $L1
|
|
|
#address 0x3c
|
#address 0x3c
|
interrupt_service_routine:
|
interrupt_service_routine:
|
#registers $26 and $27 are reserved for the OS
|
#registers $26 and $27 are reserved for the OS
|
ori $26,$0,0xffff
|
ori $26,$0,0xffff
|
ori $27,$0,46
|
ori $27,$0,46
|
sb $27,0($26) #echo out '.'
|
sb $27,0($26) #echo out '.'
|
|
|
#normally clear the interrupt source here
|
#normally clear the interrupt source here
|
|
|
#return and re-enable interrupts
|
#return and re-enable interrupts
|
ori $26,$0,0x1
|
ori $26,$0,0x1
|
mfc0 $27,$14 #C0_EPC=14
|
mfc0 $27,$14 #C0_EPC=14
|
jr $27
|
jr $27
|
mtc0 $26,$12 #STATUS=1; enable interrupts
|
mtc0 $26,$12 #STATUS=1; enable interrupts
|
.set reorder
|
.set reorder
|
.end entry
|
.end entry
|
|
|
|
|
###################################################
|
###################################################
|
.globl isr_enable
|
.globl isr_enable
|
.ent isr_enable
|
.ent isr_enable
|
isr_enable:
|
isr_enable:
|
.set noreorder
|
.set noreorder
|
jr $31
|
jr $31
|
mtc0 $4,$12 #STATUS=1; enable interrupts
|
mtc0 $4,$12 #STATUS=1; enable interrupts
|
.set reorder
|
.set reorder
|
.end isr_enable
|
.end isr_enable
|
|
|
|
|
###################################################
|
###################################################
|
.globl putchar
|
.globl putchar
|
.ent putchar
|
.ent putchar
|
putchar:
|
putchar:
|
.set noreorder
|
.set noreorder
|
li $5,0xffff
|
li $5,0xffff
|
|
|
#Uncomment to make each character on a seperate line
|
#Uncomment to make each character on a seperate line
|
#The VHDL simulator buffers the lines
|
#The VHDL simulator buffers the lines
|
# sb $4,0($5)
|
# sb $4,0($5)
|
# ori $4,$0,'\n'
|
# ori $4,$0,'\n'
|
|
|
jr $31
|
jr $31
|
sb $4,0($5)
|
sb $4,0($5)
|
.set reorder
|
.set reorder
|
.end putchar
|
.end putchar
|
|
|
|
|
###################################################
|
###################################################
|
.globl puts
|
.globl puts
|
.ent puts
|
.ent puts
|
puts:
|
puts:
|
.set noreorder
|
.set noreorder
|
ori $5,$0,0xffff
|
ori $5,$0,0xffff
|
PUTS1:
|
PUTS1:
|
lb $6,0($4)
|
lb $6,0($4)
|
beqz $6,PUTS2
|
beqz $6,PUTS2
|
addiu $4,$4,1
|
addiu $4,$4,1
|
b PUTS1
|
b PUTS1
|
sb $6,0($5)
|
sb $6,0($5)
|
PUTS2:
|
PUTS2:
|
jr $31
|
jr $31
|
ori $2,$0,0
|
ori $2,$0,0
|
.set reorder
|
.set reorder
|
.end puts
|
.end puts
|
|
|
|
|
|
|