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/stdalone/wrtmbr/mbr
    from Rev 103 to Rev 248
    Reverse comparison

Rev 103 → Rev 248

/mbr.s
0,0 → 1,54
;
; mbr.s -- the master boot record
;
 
.set tba,0xF0300000 ; terminal base address
.set tos,0xC0011000 ; top of stack
 
start:
add $29,$0,tos ; set stackpointer
jal msgout ; output message
stop:
j stop ; halt by looping
 
msgout:
sub $29,$29,8 ; allocate stack frame
stw $31,$29,0 ; save return register
stw $16,$29,4 ; save local variable
add $16,$0,msg ; pointer to string
loop:
ldbu $4,$16,0 ; get char
beq $4,$0,exit ; null - finished
jal out ; output char
add $16,$16,1 ; bump pointer
j loop ; next char
exit:
ldw $31,$29,0 ; restore return register
ldw $16,$29,4 ; restore local variable
add $29,$29,8 ; release stack frame
jr $31 ; return
 
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
 
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 "Execution halted."
.byte 0x0D, 0x0A
.byte 0x0D, 0x0A, 0
 
.locate 512-2
sign:
.byte 0x55, 0xAA
/Makefile
0,0 → 1,24
#
# Makefile for assembling the default master boot record
#
 
BUILD = ../../../build
 
.PHONY: all clean
 
all: mbr.dump
 
mbr.dump: dump mbr.bin
./dump mbr.bin mbr.dump
 
dump: dump.c
gcc -m32 -g -Wall -o dump dump.c
 
mbr.bin: mbr.o
$(BUILD)/bin/ld -h -rc 0xC0010000 -o mbr.bin mbr.o
 
mbr.o: mbr.s
$(BUILD)/bin/as -o mbr.o mbr.s
 
clean:
rm -f *~ dump mbr.o mbr.bin mbr.dump
/dump.c
0,0 → 1,48
/*
* dump.c -- dump a binary file as contents of a C array
*/
 
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
 
int main(int argc, char *argv[]) {
FILE *infile, *outfile;
int c, n;
 
if (argc != 3) {
printf("Usage: %s <infile> <outfile>\n", argv[0]);
return 1;
}
infile = fopen(argv[1], "rb");
if (infile == NULL) {
printf("Error: cannot open file '%s' for input\n", argv[1]);
return 1;
}
outfile = fopen(argv[2], "wt");
if (outfile == NULL) {
printf("Error: cannot open file '%s' for output\n", argv[2]);
return 1;
}
n = 0;
while (1) {
c = getc(infile);
if (c == EOF) {
break;
}
fprintf(outfile, "0x%02X, ", c);
n++;
if (n == 8) {
n = 0;
fprintf(outfile, "\n");
}
}
if (n != 0) {
fprintf(outfile, "\n");
}
fclose(infile);
fclose(outfile);
return 0;
}

powered by: WebSVN 2.1.0

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