diff --git a/btester.sh b/btester.sh new file mode 100755 index 0000000..a956a7e --- /dev/null +++ b/btester.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +pdpy11 --lst tester.mac + +if [ ! -e raw_to_simh_bin ] ; then + g++ -Ofast raw_to_simh_bin.cpp -o raw_to_simh_bin +fi + +./raw_to_simh_bin tester 512 512 tester.bin + +ls -la tester* diff --git a/raw_to_simh_bin.cpp b/raw_to_simh_bin.cpp new file mode 100644 index 0000000..3d7b3d3 --- /dev/null +++ b/raw_to_simh_bin.cpp @@ -0,0 +1,72 @@ +// this program is in the public domain +// written by Folkert van Heusden +#include +#include +#include + +void put_byte(const uint8_t byte, int32_t *const csum, FILE *const fh) +{ + *csum -= byte; + + fputc(byte, fh); +} + +int main(int argc, char *argv[]) +{ + if (argc != 5) { + fprintf(stderr, "Usage: %s file_in load_offset start_offset file_out\n", argv[0]); + fprintf(stderr, "Note: offsets must be decimal\n"); + + return 1; + } + + const char *file_in = argv[1]; + const uint32_t offset = atol(argv[2]); + const uint32_t start = atol(argv[3]); + const char *file_out = argv[4]; + + FILE *fh_in = fopen(file_in, "r"); + FILE *fh_out = fopen(file_out, "wb"); + + fseek(fh_in, 0, SEEK_END); + uint32_t file_size = ftell(fh_in); + fseek(fh_in, 0, SEEK_SET); + + int32_t csum = 0; + + // header for the data itself + // after the data, a header will follow setting + // the start address + put_byte(0x01, &csum, fh_out); + put_byte(0x00, &csum, fh_out); + + uint32_t temp = file_size + 6; + put_byte(temp & 255, &csum, fh_out); + put_byte(temp >> 8, &csum, fh_out); + + put_byte(offset & 255, &csum, fh_out); + put_byte(offset >> 8, &csum, fh_out); + + for(int i=0; i> 8, &csum, fh_out); + + fclose(fh_out); + + fclose(fh_in); + + return 0; +} diff --git a/tester.mac b/tester.mac new file mode 100644 index 0000000..9d6ee61 --- /dev/null +++ b/tester.mac @@ -0,0 +1,52 @@ +; in simh: +; simh> set console telnet=3333 +; then invoke telnet to port 3333 on the simh systm +; simh> load test.bin +; simh> run + + +; initialize stack pointer +start: MOV #1000, R6 + + MOV #textstart, R0 + CALL printstart + + + MOV #textfin, R0 + CALL printstart + TRAP 7 + +; store copy of R0 on the stack +printstart: MOV R0,-(SP) +; store PSW (status register) on stack + MFPS -(SP) + +; string ends with 0x00 +print: TSTB (R0) + BEQ pdone + +; put character in tty buffer + MOVB (R0), @#TTYTX + +; wait for it to be transmitted +waittx: TSTB @#TTYST + BPL waittx + + INC R0 + JMP print + +; retrieve stored r0, r1 and psw from stack +pdone: MTPS (SP)+ + + MOV (SP)+,R0 + RET + + make_raw + +textstart: .ASCII "tester running...\r\n\x00" +textfin: .ASCII "tester finished\r\n\x00" + +textbuffer: .BLKB 256. + +TTYST = 177564 +TTYTX = 177566