working on tester code
This commit is contained in:
parent
a1073b2f83
commit
445d652921
3 changed files with 135 additions and 0 deletions
11
btester.sh
Executable file
11
btester.sh
Executable file
|
@ -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*
|
72
raw_to_simh_bin.cpp
Normal file
72
raw_to_simh_bin.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
// this program is in the public domain
|
||||||
|
// written by Folkert van Heusden <mail@vanheusden.com>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
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<file_size; i++) {
|
||||||
|
uint8_t c = fgetc(fh_in);
|
||||||
|
|
||||||
|
put_byte(c, &csum, fh_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
fputc(csum & 0xff, fh_out);
|
||||||
|
|
||||||
|
put_byte(0x01, &csum, fh_out);
|
||||||
|
put_byte(0x00, &csum, fh_out);
|
||||||
|
|
||||||
|
put_byte(6, &csum, fh_out);
|
||||||
|
put_byte(0, &csum, fh_out);
|
||||||
|
|
||||||
|
put_byte(start & 255, &csum, fh_out);
|
||||||
|
put_byte(start >> 8, &csum, fh_out);
|
||||||
|
|
||||||
|
fclose(fh_out);
|
||||||
|
|
||||||
|
fclose(fh_in);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
52
tester.mac
Normal file
52
tester.mac
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue