;
|
;
|
; mbr.s -- the master boot record
|
; mbr.s -- the master boot record
|
;
|
;
|
|
|
.set tba,0xF0300000 ; terminal base address
|
.set tba,0xF0300000 ; terminal base address
|
.set tos,0xC0001000 ; top of stack
|
.set tos,0xC0011000 ; top of stack
|
|
|
start:
|
start:
|
add $29,$0,tos ; set stackpointer
|
add $29,$0,tos ; set stackpointer
|
jal msgout ; output message
|
jal msgout ; output message
|
stop:
|
stop:
|
j stop ; halt by looping
|
j stop ; halt by looping
|
|
|
msgout:
|
msgout:
|
sub $29,$29,8 ; allocate stack frame
|
sub $29,$29,8 ; allocate stack frame
|
stw $31,$29,0 ; save return register
|
stw $31,$29,0 ; save return register
|
stw $16,$29,4 ; save local variable
|
stw $16,$29,4 ; save local variable
|
add $16,$0,msg ; pointer to string
|
add $16,$0,msg ; pointer to string
|
loop:
|
loop:
|
ldbu $4,$16,0 ; get char
|
ldbu $4,$16,0 ; get char
|
beq $4,$0,exit ; null - finished
|
beq $4,$0,exit ; null - finished
|
jal out ; output char
|
jal out ; output char
|
add $16,$16,1 ; bump pointer
|
add $16,$16,1 ; bump pointer
|
j loop ; next char
|
j loop ; next char
|
exit:
|
exit:
|
ldw $31,$29,0 ; restore return register
|
ldw $31,$29,0 ; restore return register
|
ldw $16,$29,4 ; restore local variable
|
ldw $16,$29,4 ; restore local variable
|
add $29,$29,8 ; release stack frame
|
add $29,$29,8 ; release stack frame
|
jr $31 ; return
|
jr $31 ; return
|
|
|
out:
|
out:
|
add $8,$0,tba ; set I/O base address
|
add $8,$0,tba ; set I/O base address
|
out1:
|
out1:
|
ldw $9,$8,8 ; get xmtr status
|
ldw $9,$8,8 ; get xmtr status
|
and $9,$9,1 ; xmtr ready?
|
and $9,$9,1 ; xmtr ready?
|
beq $9,$0,out1 ; no - wait
|
beq $9,$0,out1 ; no - wait
|
stw $4,$8,12 ; send char
|
stw $4,$8,12 ; send char
|
jr $31 ; return
|
jr $31 ; return
|
|
|
msg:
|
msg:
|
.byte 0x0D, 0x0A
|
.byte 0x0D, 0x0A
|
.byte "Error: This is the default MBR, "
|
.byte "Error: This is the default MBR, "
|
.byte "which cannot load anything."
|
.byte "which cannot load anything."
|
.byte 0x0D, 0x0A
|
.byte 0x0D, 0x0A
|
.byte "Please replace the disk, or "
|
.byte "Please replace the disk, or "
|
.byte "write an operating system onto it."
|
.byte "write an operating system onto it."
|
.byte 0x0D, 0x0A
|
.byte 0x0D, 0x0A
|
.byte "Execution halted."
|
.byte "Execution halted."
|
.byte 0x0D, 0x0A
|
.byte 0x0D, 0x0A
|
.byte 0x0D, 0x0A, 0
|
.byte 0x0D, 0x0A, 0
|
|
|
.locate 512-2
|
.locate 512-2
|
sign:
|
sign:
|
.byte 0x55, 0xAA
|
.byte 0x55, 0xAA
|
|
|