echo "go" >> $name.go
echo "quit" >> $name.go
h316 $name.go > /dev/null
-
+#h316 $name.go > /dev/null
rm -f $name.par
rm -f $name.go
-# Skript, das die neue Bibliothek zusammenbauen soll
+# Skript, das die neue Bibliothek zusammenbauen soll (30.05.05)
-OWN = f$$w4 pchar fpatch uc lpchar vpunch
-OWN_1=$(foreach obj, $(OWN),$(obj).asm)
-OWN_2=$(OWN_1:.asm=.obj)
-#OWN_3=$(shell echo $(subst $$,\$$,$(OWN)) | dd conv=ucase 2>/dev/null)
+SRC_DIR = src
+OBJ_DIR = obj
+LIB_DIR = lib
+
+MODULES = f$$w4 f$$w1 pchar fpatch uc lpchar vpunch
-FORTRAN=$H316/bin/frtn
+FRTN_COMMAND = frtn
+ASM_COMMAND = asm
+LDC_COMMAND = ldc
+SRC_FILES = $(foreach obj, $(MODULES),$(obj).asm)
+OBJ_FILES = $(SRC_FILES:.asm=.obj)
+OBJ_FILES_FULL = $(foreach file, $(OBJ_FILES),$(OBJ_DIR)/$(file))
+#OWN_3=$(shell echo $(subst $$,\$$,$(OWN)) | dd conv=ucase 2>/dev/null)
##########################################
-all : $(OWN_2)
+all : $(OBJ_FILES_FULL)
+
+test:
+ @echo $(OBJ_FILES)
+
-$(OWN_2):%.obj:src/%.asm
+$(OBJ_FILES_FULL):$(OBJ_DIR)/%.obj:$(SRC_DIR)/%.asm
@echo Building: $(subst $$,\$$,$@)
- @asm $(subst $$,\$$,$^) || rm -f $@
+ @if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi
+ @ rm -f $@
+ @ cd $(OBJ_DIR) && $(ASM_COMMAND) ../$(subst $$,\$$,$^)
clean:
@echo Cleaning up.
- @rm -f $(subst $$,\$$,$(OWN_2)) *.lst *.go src/vpunch.asm
+ @rm -rf $(OBJ_DIR) $(LIB_DIR) *.lst *.go
+ @rm -f $(SRC_DIR)/vpunch.asm $(SRC_DIR)/vpunch.2
+ @$(MAKE) -s -C vpunch-help clean
+
+vpunch-help/use: vpunch-help/use.c vpunch-help/font_8x16.c
+ $(MAKE) -C vpunch-help use
+
+src/vpunch.2: vpunch-help/use
+ vpunch-help/use > src/vpunch.2
src/vpunch.asm: src/vpunch.1 src/vpunch.2
cat src/vpunch.1 src/vpunch.2 > src/vpunch.asm
-###########
-.PHONY: clean all
-
+
+.PHONY: clean all
+
-use: font_8x16.o use.o
\ No newline at end of file
+use: font_8x16.o use.o
+clean:
+ @rm -f *.o use
\ No newline at end of file
}
int main (int argc, char ** argv){
-// printf("Hallo, Welt!\n");
int c;
int a;
for (c=0; c<4096; c++) fontdata_8x16[c]=tw(fontdata_8x16[c]);
- printf("\tSUBR\tFONT\n");
+// printf("\tSUBR\tFONT\n");
for (a=0; a<256; a++){
char * fd =fontdata_8x16 + (a<<4);
if (a==0) printf("FONT\t"); else printf("\t");
* ASR TYPING ROUTINES
*
* REVISIONS:
-* 1.0 (5.2.2005) - FIRST STABLE VERSION
-* 1.1 (10.2.2005) - ADDED FORGOTTEN ASR START SEQUENCE
+* 1.0 (05.02.2005) - FIRST STABLE VERSION
+* 1.1 (10.02.2005) - ADDED FORGOTTEN ASR START SEQUENCE
+* 1.2 (25.07.2005) - CORRECTED ASR START SEQUENCE
+* 1.2.1 (27.07.2005) - RECORRECTED START SEQUENCE
*
* AUTHOR
*
*
**** FORM FEED ROUTINE
FF DAC **
+ JST ASUP OUTPUT MODE
LDA SFF
TCA
STA CNT
--- /dev/null
+default: ldc
+
+all: ldc
+
+%.o: %.c *.h
+ @echo -n Baue: $@
+ @echo
+ @gcc -c -Wunknown-pragmas -o$@ $<
+
+
+ldc: ldc.o process.o hw_helpers.o tape.o split.o
+ @echo Baue: ldc
+ @gcc -o$@ $^
+
+clean:
+ rm -f *.o ldc
+
+install: ldc
+ cp ldc $(HOME)/bin
+
+.PHONY: default all clean install
\ No newline at end of file
--- /dev/null
+#include <stdio.h>
+
+main ()
+{
+ unsigned char buf;
+ int stat[256];
+ int c;
+ for (c = 0; c < 256; c++)
+ stat[c] = 0;
+ int ret;
+ do {
+ ret = read (0, &buf, 1);
+ stat[buf]++;
+ }
+ while (ret);
+ for (c = 0; c < 256; c++)
+ printf ("%03i:%04i\n", c, stat[c]);
+
+}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include "hw_types.h"
+#include "hw_helpers.h"
+
+char *bin2str (unsigned long value, int length)
+{
+ int c;
+// printf("length: %i\n", length);
+ if ((length < 1) || (length > (sizeof (long) * 8)))
+ return NULL;
+ char *result = (char *) malloc (length + 1);
+// if (result==NULL) return NULL;
+ result[length] = 0;
+ result[0] = 'f';
+ for (c = 0; c < length; c++)
+ result[length - c - 1] = '0' + ((value >> c) & 1);
+ return result;
+}
+
+void parstrip (char *data, int size)
+{
+ int c;
+ for (c = 0; c < size; c++)
+ data[c] &= 127;
+}
+
+void parset (char *data, int size)
+{
+ int c;
+ for (c = 0; c < size; c++)
+ data[c] |= 128;
+}
+
+void twistbytes (hw16 * start, int count)
+{
+ int c;
+ char tmp;
+ for (c = 0; c < count; c++) {
+ tmp = start[c].bytes.high;
+ start[c].bytes.high = start[c].bytes.low;
+ start[c].bytes.low = tmp;
+ }
+}
--- /dev/null
+#ifndef HW_HELPERS_H
+#define HW_HELPERS_H
+#include "hw_types.h"
+
+char *bin2str (unsigned long value, int length);
+void msg (char *string);
+void msgf (char *format, ...);
+void say (char *string);
+void sayf (char *format, ...);
+void endwarn (int ret);
+void err (char *string);
+void parstrip (char *data, int size);
+void parset (char *data, int size);
+void twistbytes (hw16 * start, int count);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef HW_TYPES_H
+#define HW_TYPES_H
+// #pragma pack(1)
+
+struct hw16_bits {
+ unsigned int b9:1 __attribute__ ((packed));
+ unsigned int b10:1 __attribute__ ((packed));
+ unsigned int b11:1 __attribute__ ((packed));
+ unsigned int b12:1 __attribute__ ((packed));
+ unsigned int b13:1 __attribute__ ((packed));
+ unsigned int b14:1 __attribute__ ((packed));
+ unsigned int b15:1 __attribute__ ((packed));
+ unsigned int b16:1 __attribute__ ((packed));
+ unsigned int b1:1 __attribute__ ((packed));
+ unsigned int b2:1 __attribute__ ((packed));
+ unsigned int b3:1 __attribute__ ((packed));
+ unsigned int b4:1 __attribute__ ((packed));
+ unsigned int b5:1 __attribute__ ((packed));
+ unsigned int b6:1 __attribute__ ((packed));
+ unsigned int b7:1 __attribute__ ((packed));
+ unsigned int b8:1 __attribute__ ((packed));
+} __attribute__ ((packed));
+
+struct hw16_tape {
+ unsigned int low:6 __attribute__ ((packed));
+ unsigned int mid:6 __attribute__ ((packed));
+ unsigned int high:4 __attribute__ ((packed));
+};
+
+struct hw16_bytes {
+ unsigned char low __attribute__ ((packed));
+ unsigned char high __attribute__ ((packed));
+};
+
+struct hw16_otype {
+ unsigned int space1:6 __attribute__ ((packed));
+ unsigned int t0_subtype:6 __attribute__ ((packed));
+ unsigned int type:4 __attribute__ ((packed));
+};
+
+typedef struct {
+ unsigned int space3:6 __attribute__ ((packed)) __attribute__ ((packed)); //Erster Block
+ unsigned int S:6 __attribute__ ((packed));
+ unsigned int T:4 __attribute__ ((packed));
+ unsigned int space1:8 __attribute__ ((packed)); // Zweiter Block
+ unsigned int N:6 __attribute__ ((packed));
+ unsigned int space2:2 __attribute__ ((packed));
+} head0;
+typedef head0 head0_0;
+
+typedef struct {
+ unsigned int space3:6 __attribute__ ((packed)); //Erster Block
+ unsigned int S:6 __attribute__ ((packed));
+ unsigned int T:4 __attribute__ ((packed));
+} head0_23;
+typedef head0_23 head0_2;
+typedef head0_23 head0_3;
+
+
+typedef struct {
+ unsigned int A1:6 __attribute__ ((packed));
+ unsigned int N:6 __attribute__ ((packed));
+ unsigned int T:4 __attribute__ ((packed));
+ unsigned int I:8 __attribute__ ((packed));
+ unsigned int A2:8 __attribute__ ((packed));
+} head12;
+typedef head12 head1;
+typedef head12 head2;
+
+typedef struct {
+ unsigned int A1:6 __attribute__ ((packed));
+ unsigned int space1:6 __attribute__ ((packed));
+ unsigned int T:4 __attribute__ ((packed));
+ unsigned int space2:8 __attribute__ ((packed));
+ unsigned int A2:8 __attribute__ ((packed));
+} head34;
+typedef head34 head3;
+typedef head34 head4;
+
+typedef struct {
+ unsigned int A:6 __attribute__ ((packed));
+ unsigned int OP:4 __attribute__ ((packed));
+ unsigned int T2:1 __attribute__ ((packed));
+ unsigned int F:1 __attribute__ ((packed));
+ unsigned int T:4 __attribute__ ((packed));
+} head57;
+typedef head57 head5;
+typedef head57 head7;
+
+typedef struct {
+ unsigned int A1:6 __attribute__ ((packed));
+ unsigned int space1:6 __attribute__ ((packed));
+ unsigned int T:4 __attribute__ ((packed));
+ unsigned int B:8 __attribute__ ((packed));
+ unsigned int A2:8 __attribute__ ((packed));
+} head6;
+
+
+typedef union{
+ unsigned int value __attribute__ ((packed));
+
+ struct {
+ unsigned int type:3; //Immer 0
+ unsigned int space:5;
+ unsigned int data:16;
+ } generic;
+
+ struct{
+ unsigned int one:1;
+ unsigned int R:2;
+ unsigned int ADDRESS:15;
+ unsigned int OP:4;
+ unsigned int T:1;
+ unsigned int F:1;
+ }op_known_address;
+
+ struct{
+ unsigned int two:3;
+ unsigned int SYMBOL_NUMBER:14;
+ unsigned int zero:1;
+ unsigned int OP:4;
+ unsigned int T:1;
+ unsigned int F:1;
+ }op_symbolic_address;
+
+ struct {
+ unsigned int four:3;
+ unsigned int ADDRESS:16;
+ unsigned int R:2;
+ unsigned int space:1;
+ unsigned int T:1;
+ unsigned int F:1;
+ } known_address;
+
+ struct {
+ unsigned int six:3;
+ unsigned int SYMBOL_NUMBER:14;
+ unsigned int space:5;
+ unsigned int T:1;
+ unsigned int F:1;
+ } symbolic_address;
+
+}type_0_4_data;
+
+
+
+typedef union {
+ struct hw16_bits bits __attribute__ ((packed));
+ struct hw16_bytes bytes __attribute__ ((packed));
+ struct hw16_tape tape __attribute__ ((packed));
+ struct hw16_otype blocktype __attribute__ ((packed));
+ unsigned short value __attribute__ ((packed));
+} hw16;
+
+enum {BT_DATA,BT_STOP};
+
+typedef struct {
+ int size;
+ int type;
+ hw16 *data;
+ unsigned char * raw_data;
+} datablock;
+
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <sys/select.h>
+#include "hw_types.h"
+#include "hw_helpers.h"
+#define XON 0x11
+#define XOFF 0x13
+#define CHAR_START 0x81
+// 0x93
+#define CHAR_END1 0223
+#define CHAR_END2 0223
+#define CHAR_END3 0223
+#define MAX_BLOCK_SIZE 500
+
+//#define DEBUG
+//#define DEBUG_CHECKSUM
+//#define DEBUG_STRUCTURE
+//#define IGNORE_CHECKSUM
+#define HARDCORE_DEBUG
+/********************************************************/
+void output (char *string, int length);
+datablock *get_block ();
+
+/********************************************************/
+char ends[3] = { CHAR_END1, CHAR_END2, CHAR_END3 };
+int errflag = 0; // Global error flag
+int tapemode = 0;
+int inputfd;
+int ignore = 0;
+int dosplit = 0;
+int splitnum = 0;
+/********************************************************/
+
+
+/********************************************************/
+void dump_data (void *data, int count)
+{
+ int fd = open ("dump", O_RDWR | O_CREAT | O_APPEND, 0666);
+ write (fd, "***", 3);
+ write (fd, data, count);
+ close (fd);
+}
+
+/********************************************************/
+void endwarn (int ret)
+{
+ if (ret < 1) {
+ err ("Unexpected problem in input");
+ exit (3);
+ }
+}
+
+/********************************************************/
+/* Small output things */
+void err (char *string)
+{
+ printf ("Error: --> %s\n", string);
+ errflag++;
+}
+
+void msg (char *string)
+{
+#ifdef DEBUG
+ printf ("** %s\n", string);
+#endif
+}
+
+void msgf (char *format, ...)
+{
+ va_list ag;
+ va_start (ag, format);
+ char ms[100];
+ vsprintf (ms, format, ag);
+ msg (ms);
+ va_end (ag);
+}
+
+void errf (char *format, ...)
+{
+ va_list ag;
+ va_start (ag, format);
+ char ms[100];
+ vsprintf (ms, format, ag);
+ err (ms);
+ va_end (ag);
+}
+
+void say (char *string)
+{
+ printf ("%s\n", string);
+}
+
+void sayf (char *format, ...)
+{
+ va_list ag;
+ va_start (ag, format);
+ char ms[100];
+ vsprintf (ms, format, ag);
+ say (ms);
+ va_end (ag);
+}
+
+
+/********************************************************/
+/********************************************************/
+
+/********************************************************/
+/*Block input routines*/
+
+unsigned char decode (unsigned char in)
+{
+ if (in & 64)
+ switch (in) {
+ case 0174:
+ return 05;
+ break;
+ case 0374:
+ return 045;
+ break;
+ case 0175:
+ return 012;
+ break;
+ case 0375:
+ return 052;
+ break;
+ case 0176:
+ return 021;
+ break;
+ case 0376:
+ return 061;
+ break;
+ case 0177:
+ return 023;
+ break;
+ case 0377:
+ return 063;
+ break;
+ default:
+ err ("decode(): Impossible case!!!\n");
+ return 0;
+ break;
+ } else {
+ if (in & 128)
+ in |= 32;
+ return in;
+ }
+
+ return 0;
+}
+
+/********************************************************/
+/********************************************************/
+
+void combine466 (unsigned char *raw, unsigned char *data)
+{
+ hw16 *result = (hw16 *) data;
+
+// result->tape.low = 077;
+ unsigned char r1, r2, r3;
+
+ r1 = decode ((raw)[0]) & 017;
+ r2 = decode ((raw)[1]) & 077;
+ r3 = decode ((raw)[2]) & 077;
+
+ result->tape.high = r1;
+ result->tape.mid = r2;
+ result->tape.low = r3;
+
+#ifdef DEBUG_COMBINE
+ msgf ("combine466 (data) : %s%s%s", bin2str (r1, 4), bin2str (r2, 6),
+ bin2str (r3, 6));
+ msgf ("combine466 (rawmem) : %s%s", bin2str (data[1], 8),
+ bin2str (data[0], 8));
+ msgf ("combine466 (structure): %s", bin2str (result->value, 16));
+#endif
+}
+
+/*********************************************************************/
+/*********************************************************************/
+int checksum_error (hw16 * data, int size)
+{
+ unsigned short int checksumme = 0;
+ int c;
+ for (c = 0; c < (size - 1); c++) {
+ checksumme ^= data[c].value;
+#ifdef DEBUG_CHECKSUM
+ msgf ("checksum_error(): Gelesen:%04x Berechnet:%04x",
+ data[c + 1].value, checksumme);
+ if (data[c + 1].value == checksumme)
+ msg ("checksum_error (): Treffer.");
+#endif
+ }
+#ifdef DEBUG_CHECKSUM
+ msgf ("checksum_error(): Gelesen:%04x Berechnet:%04x",
+ data[size - 1].value, checksumme);
+#endif
+ if (data[size - 1].value != checksumme)
+ return 1;
+ return 0;
+}
+
+/********************************************************/
+datablock *get_block()
+{
+ int blk_size, round, ret, found, complete;
+ unsigned char buffer[3];
+ hw16 *blk_data;
+ unsigned char *raw_data;
+
+ if (tapemode)
+ tapestart ();
+ do {
+ ret = read (inputfd, buffer, 1);
+#ifdef HARDCORE_DEBUG
+ msgf ("READ : (hex)%02x (bin)%s (dec)%3i (oct)%3o",
+ buffer[0], bin2str (buffer[0], 8), buffer[0], buffer[0]);
+#endif
+ if (ret < 1) {
+ msg ("get_block(): Nichts mehr zu lesen");
+ return NULL;
+ }
+
+ if (buffer[0]==0x83){
+ datablock *result = (datablock *) malloc (sizeof (datablock));
+ result->type = BT_STOP;
+ result->data = NULL;
+ result->raw_data = NULL;
+ result->size = 0;
+ return result;
+ }
+
+ } while (*buffer != (unsigned char) CHAR_START);
+
+ msg ("get_block(): Blockstart erkannt");
+
+// blk_data = (hw16 *) malloc (MAX_BLOCK_SIZE * sizeof (hw16));
+ blk_data=NULL;
+ raw_data=NULL;
+ round = 0;
+ blk_size = 0;
+
+ do {
+ complete = 0;
+ ret = read (inputfd, buffer + round, 1);
+#ifdef HARDCORE_DEBUG
+ static int lochzahl = 0;
+ char *bin = bin2str (buffer[round], 8);
+ int a;
+ for (a = 0; a < 8; a++)
+ if (bin[a] == '1')
+ lochzahl++;
+ msgf ("READ (round %i): (hex)%02x (bin)%s (dec)%3i "
+ " (oct)%3o Lochzahl:%4i",
+ round, buffer[round], bin, buffer[round], buffer[round], lochzahl);
+
+// msgf ("READ(round %i) (hex)%02x", round, buffer[round]);
+#endif
+ endwarn (ret);
+ round++;
+ found = 0;
+ if (buffer[round - 1] == CHAR_END1)
+ found++;
+ if (buffer[round - 1] == CHAR_END2)
+ found++;
+
+ if (found) {
+ complete++;
+ } else {
+ if (round == 3) {
+ //if (blk_size == MAX_BLOCK_SIZE) {
+ // err ("Blocküberlauf");
+ // free (blk_data);
+ // exit (4);
+ //}
+ blk_data = (hw16 *) realloc (blk_data,(blk_size+1)* sizeof (hw16));
+ raw_data = (unsigned char *) realloc (raw_data,(blk_size+1)*3);
+ memcpy(raw_data+blk_size*3,buffer,3);
+ combine466 (buffer, (unsigned char *) (blk_data + blk_size));
+ blk_size++;
+ round = 0;
+ }
+ }
+ }
+ while (complete == 0);
+
+ msgf ("get_block(): Size: %i", blk_size);
+
+#ifdef DEBUG_STRUCTURE
+ hw16 *l1 = blk_data;
+ hw16 *l2 = blk_data + 1;
+ head0 *head = (head0 *) blk_data;
+ msgf ("get_block(): HEAD: %s", bin2str (l1->value, 16));
+ msgf ("get_block(): HEAD: %s", bin2str (l2->value, 16));
+ msgf ("get_block(): head->T: %i", head->T);
+ msgf ("get_block(): head->S: %i", head->S);
+ msgf ("get_block(): head->N: %i", head->N);
+#endif
+
+
+ if (checksum_error (blk_data, blk_size)) {
+ err ("get_block(): Checksummenfehler");
+
+
+#ifdef CHECKSUM_DUMP
+ dump_data (buffer, 3);
+ read (inputfd, buffer, 3);
+ dump_data (buffer, 3);
+#endif
+
+ if (tapemode) {
+ tapestop ();
+ sleep (15);
+ tapestart ();
+ } else {
+ if (!ignore)
+ exit (4);
+ }
+
+ } else
+ msg ("get_block(): Checksumme OK");
+
+ datablock *result = (datablock *) malloc (sizeof (datablock));
+ result->type = BT_DATA;
+ result->data = blk_data;
+ result->raw_data = raw_data;
+ result->size = blk_size;
+
+ if (tapemode)
+ tapestop ();
+ return result;
+}
+
+/********************************************************/
+/**********************************************************************/
+int main (int argc, char **args)
+{
+ int c;
+ char *filename = NULL;
+ int blk_no = 0;
+
+ msg ("Verarbeite Kommandozeilenparameter:");
+ for (c = 1; c < argc; c++) {
+ if ((args[c][0] == '-') && (strlen (args[c]) > 1)) {
+ char action = args[c][1];
+ //msgf ("Action %c, Arg dazu:%s", action, parm);
+ switch (action) {
+ case 'I':
+ ignore++;
+ break;
+ case 't':
+ tapemode++;
+ break;
+ case 'S':
+ splitnum++;
+ case 's':
+ dosplit++;
+ break;
+ default:
+ say ("Usage:\n");
+ sayf ("%s [-t] [-S] [-n] [-I] [filename]", args[0]);
+ sayf ("");
+ sayf (" -t Tape mode. Uses tty device and stops on error.");
+ sayf (" -S Split library tape into separate numbered files");
+ sayf (" -s same as -S but no numbering");
+ sayf (" -I Ignore errors");
+ sayf ("");
+ exit (1);
+ break;
+ }
+ } else {
+ filename = args[c];
+ }
+ }
+
+ //Use file?
+ if (filename != NULL) {
+ msgf ("Using file:%s", filename);
+ inputfd = open (filename, O_RDWR);
+ if (inputfd < 0) {
+ perror ("File");
+ err ("Sorry, exiting.");
+ exit (3);
+ }
+ } else {
+ inputfd = 0;
+ if (tapemode) {
+ err ("Use of console as tape device not allowed! Please specify a suitable device!");
+ exit(1);
+ }
+ }
+
+ if (tapemode) {
+ msg ("Tapemode aktiviert.");
+ if (!isatty (inputfd)) {
+ err ("Input file doesn't seem to be a tty.\nNot using tape mode on files!\nQuit.");
+ exit (1);
+ }
+ tapeinit (inputfd);
+ }
+ datablock *akt_block;
+
+ while (1) {
+ msg ("********************************************************");
+ msgf ("Block no. %5i", blk_no++);
+
+ akt_block = get_block ();
+ if (akt_block == NULL) {
+ msg ("Ende der Verarbeitung.");
+
+ msgf ("Errflag:%i", errflag);
+ if (errflag)
+ sayf ("** Es gab Fehler.");
+ exit (0);
+ }
+ // Verarbeitung hier
+
+ process_block (akt_block);
+ if (dosplit) split(akt_block);
+
+ free (akt_block->data);
+ free (akt_block->raw_data);
+ free (akt_block);
+ } // Endlosschleife
+} //main();
+
+// end.
--- /dev/null
+#include <stdio.h>
+#include "hw_types.h"
+#include "hw_helpers.h"
+
+#include "process.h"
+
+//#define DEBUG_DATA
+/**********************************************************************/
+
+int get_blocktype (datablock * block){
+ return block->data[0].blocktype.type;
+}
+
+int get_blocksubtype(datablock * block){
+ if (block->data[0].blocktype.type!=0) return 0;
+ return block->data[0].blocktype.t0_subtype;
+}
+
+void block_copy(datablock* dest, datablock* src){
+ dest->data = (hw16 *) malloc (src->size * sizeof (hw16));
+ dest->raw_data = (unsigned char *) malloc (src->size * 3 );
+ dest->size=src->size;
+ memcpy (dest->data, src->data, src->size * sizeof (hw16));
+ memcpy (dest->raw_data, src->raw_data, src->size * 3);
+
+}
+
+datablock * block_clone(datablock * orgblock){
+ datablock * block = (datablock *) malloc (sizeof (datablock));
+ block_copy(block,orgblock);
+ return block;
+}
+
+void block_dispose(datablock * victim){
+ free(victim->data);
+ free(victim->raw_data);
+ free(victim);
+}
+
+char ** extract_labels0(datablock * blockp){
+ char ** result=(char **) malloc (sizeof(char **));
+ result[0]==NULL;
+ if (get_blocktype(blockp)!=0) return NULL;
+
+ datablock block;
+ block_copy(&block,blockp);
+
+ hw16 * data = block.data;
+ int c;
+ parstrip ((char *)data +4, (block.size - 3) * 2);
+ twistbytes (data + 2, block.size - 3);
+ for (c = 0; c < (((head0*)data)->N - 3) / 3; c++) {
+ char akt[7];
+ memcpy (akt, ((char *) data) + 4 + c * 6, 6);
+ akt[6]=0;
+
+
+ int dd=5;
+ while (akt[dd]==' ') akt[dd--]=0; // hinten kürzen;
+ dd=0;
+ while (akt[dd]==' ') dd++; // vorne kürzen;
+ char * aktres = malloc(strlen(akt+dd)+1);
+ strcpy (aktres," ");
+ strncpy (aktres,akt+dd,strlen(akt+dd));
+ result=(char **)realloc(result, (c+1)* sizeof(char**));
+ result[c]=aktres;
+// printf("akt: %s\n",result[c]);
+ }
+ result=(char **)realloc(result, (c+1)* sizeof(char**));
+ result[c]=NULL;
+ free(block.data);
+ free(block.raw_data);
+ return result;
+}
+
+void dispose_labels(char ** labels){
+ char * akt;
+ if (labels==NULL) return;
+ int c=0;
+ do {
+ free (labels[c++]);
+ } while (labels[c]!=NULL);
+ free (labels);
+}
+//***
+
+char * extract_label6(datablock * block){
+ datablock myblock;
+ block_copy(&myblock,block);
+ char * dat =(char *) myblock.data;
+ twistbytes (myblock.data + 1, 4);
+ parstrip (dat + 3, 6);
+ char *akt = malloc(7);
+ memcpy (akt, dat + 3, 6);
+ akt[6]=0;
+ free (myblock.data);
+ free (myblock.raw_data);
+ return akt;
+}
+
+
+//*****************
+void process_block (datablock * orgblock)
+{
+ if (orgblock->type==BT_STOP){
+ say("**************** ENDBLOCK ****************");
+ return;
+ }
+
+ if (orgblock->type!=BT_DATA) return;
+
+ datablock block;
+ block_copy(&block, orgblock);
+
+ hw16 * data = block.data;
+
+ int type = get_blocktype(&block);
+ int subtype = get_blocksubtype(&block);
+
+ msg ("process_block(): Start");
+ msgf ("process_block(): Blocktyp: %o", type);
+ if (type == 0)
+ msgf ("process_block(): Subtyp (oct): %o",
+ block.data[0].blocktype.t0_subtype);
+ switch (type) {
+ case 0:
+ {
+ head0 *head = (head0 *) data;
+ switch (subtype) {
+ case 0:
+ {
+ int c=0;
+ char ** labels=extract_labels0(&block);
+ do {
+ char * akt = labels[c++];
+ if (c == 1)
+ sayf ("%6s (0-0) subprogram name", akt);
+ else
+ sayf ("%s (0-0) \" \"", akt);
+ } while (labels[c]!=NULL);
+ dispose_labels(labels);
+ }
+ break;
+ case 1:
+ say (" (0-1) non-load flag off");
+ break;
+ case 2:
+ say (" (0-2) chain flag on");
+ break;
+ case 3:
+ say (" (0-3) end of job");
+ break;
+ case 4:
+ {
+ say (" (0-4) data");
+
+#ifdef DEBUG_DATA_PLAIN
+ }
+ int words24 = (block.size - 4) * 2 / 3;
+ int c;
+ for (c = 3; c < (block.size - 1); c++) {
+ msgf ("Datenwort(hex): %04x Und (bin):%s", data[c].value,
+ bin2str (data[c].value, 16));
+ }
+ }
+#endif
+
+#ifdef DEBUG_DATA
+ int words24 = (block.size - 4) * 2 / 3;
+ msgf ("WORDS:%02i", words24);
+ msgf ("BASE (oct):%06o", data[2].value);
+ int c;
+ twistbytes (data + 3, (block.size - 4));
+ for (c = 0; c < (words24); c++) {
+// sayf("Nummer:%5i",c);
+ unsigned int dhigh = ((unsigned char *) data)[6 + 3 * c];
+ unsigned int dmid = ((unsigned char *) data)[7 + 3 * c];
+ unsigned int dlow = ((unsigned char *) data)[8 + 3 * c];
+ type_0_4_data mydata;
+ mydata.value = 0;
+ mydata.value += dhigh << 16;
+ mydata.value += dmid << 8;
+ mydata.value += dlow << 0;
+// msgf("Daten: %08o %06x",(unsigned long)mydata.value,mydata.value);
+ switch (mydata.generic.type) {
+ case 0: //generic/unmodified data
+ sayf ("%06o Generic/unmodified data",
+ mydata.generic.data);
+ break;
+ case 1: //Address is known and to be desectorized
+ case 3:
+ case 7:
+ sayf ("%o %o %02o %05o (%1o) Known address",
+ mydata.op_known_address.F,
+ mydata.op_known_address.T,
+ mydata.op_known_address.OP,
+ mydata.op_known_address.ADDRESS,
+ mydata.op_known_address.R);
+ break;
+ case 2: // Symbolic Address, to be desectorized
+ sayf ("%o %o %02o %05o Symbolic address",
+ mydata.op_symbolic_address.F,
+ mydata.op_symbolic_address.T,
+ mydata.op_symbolic_address.OP,
+ mydata.op_symbolic_address.SYMBOL_NUMBER);
+ break;
+ case 4: // Address ist known, do not desectorize
+
+ sayf ("%o %o %06o Address known, not to be desectorized", mydata.known_address.F, mydata.known_address.T, mydata.known_address.ADDRESS);
+ break;
+ case 6: //Symbolic Address, not to be desctorized when known
+ sayf ("%o %o %05o Symbolic Address, not to be desectorized when the address is known", mydata.symbolic_address.F, mydata.symbolic_address.T, mydata.symbolic_address.SYMBOL_NUMBER);
+
+ break;
+ default:
+ say ("There is an error in the 0-4 type word!");
+ }
+
+ }
+#endif
+ }
+ break;
+ case 010:
+ say (" (0-10) symbol number definition block");
+ break;
+ case 014:
+ say (" (0-14) end");
+
+ break;
+ case 024:
+ say (" (0-24) switch to relocateable mode");
+ break;
+ case 030:
+ say (" (0-30) switch to absolute mode");
+ break;
+ case 054:
+ say (" (0-54) enter extended-memory desectorizing mode");
+ break;
+ case 060:
+ say (" (0-60) leave extended-memory desectorizing mode");
+ break;
+ case 044:{
+
+
+ parstrip ((char *) data + 4, 6);
+ twistbytes (data + 2, 3);
+ char akt[7] = "SYMBOL";
+ memcpy (akt, ((char *) data) + 4, 6);
+
+ sayf ("%s (0-44) subprogram call", akt);
+ }
+ break;
+ case 050:
+ {
+ int c;
+ parstrip ((char *) data + 4, (block.size - 3) * 2);
+ twistbytes (data + 2, block.size - 3);
+ for (c = 0; c < (head->N - 3) / 3; c++) {
+ char akt[7] = "SYMBOL";
+ memcpy (akt, ((char *) data) + 4 + c * 6, 6);
+ if (c == 0)
+ sayf ("%s (0-50) subprogram entry point definition",
+ akt);
+ else
+ sayf ("%s (0-50) \" \"", akt);
+ }
+
+ }
+
+ break;
+ case 064:
+ say (" (0-64) set base sector");
+ break;
+ default:
+ errf ("Unbekannter Blocktyp! (0-%0o)", subtype);
+ break;
+ }
+}
+
+break;
+case 1:
+say (" (1) absolute program words");
+break;
+case 2:
+say (" (2) relative program words");
+break;
+case 3:
+say (" (3) end jump (absolute)");
+break;
+case 4:
+say (" (4) end jump (relative)");
+break;
+case 5:{
+ char * dat =(char *) data;
+ twistbytes (data + 1, 4);
+ parstrip (dat + 3, 6);
+ char akt[7] = "SYMBOL";
+ memcpy (akt, dat + 3, 6);
+ twistbytes (data + 1, 4);
+
+ sayf ("%s (5) subroutine call", akt);
+}
+
+break;
+case 6:{
+ char * dat =(char *) data;
+ twistbytes (data + 1, 4);
+ parstrip (dat + 3, 6);
+ char akt[7] = "SYMBOL";
+ memcpy (akt, dat + 3, 6);
+ twistbytes (data + 1, 4);
+
+
+sayf ("%s (6) subroutine or common block definition",akt);
+
+
+}
+break;
+case 7:{
+ parstrip ((char *) data + 3, 6);
+ twistbytes (data + 1, 4);
+ char akt[7] = "SYMBOL";
+ memcpy (akt, ((char *) data) + 3, 6);
+ twistbytes (data + 1, 4);
+
+ sayf ("%s (7) reference (call) to common item", akt);
+}
+
+break;
+
+default:
+err ("Unbekannter Blocktyp!");
+break;
+break;
+
+
+}
+}
--- /dev/null
+#ifndef PROCESS_H
+#define PROCESS_H
+#include "hw_types.h"
+void process_block (datablock * block);
+
+int get_blocktype (datablock * block);
+int get_subblocktype (datablock * block);
+void block_copy(datablock * dest, datablock* src);
+datablock * block_clone(datablock * original);
+void block_dispose(datablock * victim);
+void process_block (datablock * orgblock);
+char ** extract_labels0(datablock * block);
+char * extract_label6(datablock * block);
+void dispose_labels(char ** labels);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "hw_types.h"
+#include "hw_helpers.h"
+#include "process.h"
+#include "split.h"
+
+#define CHAR_START 0x81
+#define CHAR_END 0223
+
+
+//#define STOP1 0x83
+//#define STOP1 0x93
+//#define STOP1 0xff
+
+
+int fd=-3;
+int number=0;
+
+
+enum{OUTSIDE,INSIDE_ASM,INSIDE_FORT};
+int state = OUTSIDE;
+extern int splitnum;
+
+#define bstart_l 1
+#define bend_l 2
+#define endseq_l 3
+char bstart_str[bstart_l] = {CHAR_START};
+char bend_str[bend_l] = {CHAR_END,0xff};
+char endseq_str[endseq_l] = {0x83,0x93,0xff};
+
+void split_init(){
+}
+
+
+void split(datablock * block){
+ if ((block->type==BT_STOP) && splitnum){
+ char filename[200];
+ number+=10;
+ snprintf(filename,200,"%04i-STOP",number);
+ fd=open (filename,O_WRONLY|O_CREAT|O_TRUNC,00644);
+ write(fd,endseq_str,endseq_l);
+ close (fd);
+ return;
+ }
+
+ if (block->type!=BT_DATA) return;
+
+ switch (state){
+ case OUTSIDE:
+ if (get_blocktype(block)==6){
+ char* fn = extract_label6(block);
+ char filename[200];
+ number+=10;
+ if (splitnum) snprintf(filename,200,"%04i-%s",number,fn);
+ else snprintf(filename,200,"%s",fn);
+ free(fn);
+ while (filename[strlen(filename)-1]==' ')filename [strlen(filename)-1]=0;
+ fd=open (filename,O_WRONLY|O_CREAT|O_TRUNC,00644);
+ state=INSIDE_FORT;
+ write(fd,bstart_str,bstart_l);
+ write(fd,block->raw_data,(block->size)*3);
+ write(fd,bend_str,bend_l);
+ }
+
+ if ((get_blocktype(block)==0)&& (get_blocksubtype(block)==0)){
+ char ** labels=extract_labels0(block);
+ char* fn = labels[0];
+ char filename[200];
+ number+=10;
+ if (splitnum) snprintf(filename,200,"%04i-%s",number,fn);
+ else snprintf(filename,200,"%s",fn);
+
+ while (filename[strlen(filename)-1]==' ')filename [strlen(filename)-1]=0;
+ fd=open (filename,O_WRONLY|O_CREAT|O_TRUNC,00644);
+ dispose_labels(labels);
+
+ state=INSIDE_ASM;
+ write(fd,bstart_str,bstart_l);
+ write(fd,block->raw_data,(block->size)*3);
+ write(fd,bend_str,bend_l);
+ }
+ break;
+
+ case INSIDE_ASM:
+ write(fd,bstart_str,bstart_l);
+ write(fd,block->raw_data,(block->size)*3);
+ write(fd,bend_str,bend_l);
+ if (get_blocksubtype(block)==014){
+ state=OUTSIDE;
+ close(fd);
+ }
+ break;
+
+ case INSIDE_FORT:
+ write(fd,bstart_str,bstart_l);
+ write(fd,block->raw_data,(block->size)*3);
+ write(fd,bend_str,bend_l);
+ if ((get_blocktype(block)==3)||get_blocktype(block)==4){
+ state=OUTSIDE;
+ close(fd);
+ }
+ break;
+ }
+}
--- /dev/null
+#include "hw_types.h"
+
+void split_init();
+void split(datablock * akt);
+void split_finish();
--- /dev/null
+#include <stdio.h>
+#include <termios.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include "tape.h"
+
+static struct termios orgstate;
+static struct termios workstate;
+
+static int fd;
+
+void tapeclose ()
+{
+ tcsetattr (fd, TCSANOW, &orgstate);
+ close (fd);
+}
+
+void tapestart ()
+{
+ char a = 0x11; //xon;
+ write (fd, &a, 1);
+}
+
+void tapestop ()
+{
+ char a = 0x13; //xoff;
+ write (fd, &a, 1);
+}
+
+void tapeinit (int tapefd)
+{
+ fd = tapefd;
+ tcgetattr (tapefd, &orgstate);
+ tcgetattr (tapefd, &workstate);
+ workstate.c_iflag = 0;
+ workstate.c_oflag = 0;
+ workstate.c_cflag = CS8 | CREAD | CLOCAL | CRTSCTS | CSTOPB;
+ workstate.c_lflag = 0;
+ cfsetspeed (&workstate, B4800);
+ tcsetattr (tapefd, TCSANOW, &workstate);
+}
+
+// Ende.
--- /dev/null
+void tapeinit(int fg);
+void tapeclose();
+void tapestart();
+void tapestop();
--- /dev/null
+PROGS=paron paroff load turn zstrip tab
+
+install: $(PROGS)
+ cp $(PROGS) ../../bin/
+
+clean:
+ rm -f $(PROGS) $(foreach p, $(PROGS),../../bin/$(p))
+
+
--- /dev/null
+#include <stdio.h>
+#include <termios.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+
+struct termios orgstate;
+struct termios workstate;
+
+#define PORT_FILE "/dev/ttyS0"
+#define BUFFER_SIZE 1000000
+
+char * buffer;
+int sp, ep, count, portfd;
+
+void sighandler(int sig){
+ sp=0;
+ ep=count-1;
+ close (portfd);
+// fprintf(stderr,"%i %i\n", sp, ep);
+ if (count>0) {
+ while(buffer[sp]==0) sp++;
+ while(buffer[ep]==0) ep--;
+ }
+
+ write(1,buffer+sp,ep-sp+1);
+ tcdrain(2);
+ fprintf(stderr,"Eingelesen: %i\n",ep-sp+1);
+ tcsetattr(portfd, TCSANOW, &orgstate);
+ close(portfd);
+ exit(0);
+}
+
+int main (int argc, char ** argv){
+
+ portfd=open(PORT_FILE, O_RDWR);
+ tcgetattr(portfd, &orgstate);
+ tcgetattr(portfd, &workstate);
+ cfmakeraw(&workstate);
+// workstate.c_oflag=0;
+ workstate.c_cflag|=CS8+CREAD+CLOCAL+CRTSCTS+CSTOPB ;
+// workstate.c_lflag=0;
+ cfsetspeed(&workstate, B4800);
+ tcsetattr(portfd, TCSANOW, &workstate);
+ count=0;
+
+ signal(SIGINT, sighandler);
+ buffer=(char *) malloc(BUFFER_SIZE);
+ fprintf(stderr, "Warte auf Daten. Einspielen und dann CTRL-C drücken.\n");
+
+ while(1) {
+ int erg=read(portfd, buffer+count, 1);
+ if (erg>0) count+=erg;
+ }
+
+
+} //main();
+// Ende.
--- /dev/null
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#define BUF_SIZ 100000
+#define LINE_LENGTH 72
+// ssize_t getline(char **lineptr, size_t *n, FILE *stream);
+
+int main(int argc, char ** argv){
+ char buffer;
+ while (read(0,&buffer,1)) {
+ buffer&=127;
+ write(1,&buffer,1);
+ }
+
+} // main()
+// Ende
+
--- /dev/null
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#define BUF_SIZ 100000
+#define LINE_LENGTH 72
+// ssize_t getline(char **lineptr, size_t *n, FILE *stream);
+
+int main(int argc, char ** argv){
+ char buffer;
+ while (read(0,&buffer,1)) {
+ buffer|=128;
+ write(1,&buffer,1);
+ }
+
+} // main()
+// Ende
+
--- /dev/null
+#include <stdio.h>
+
+#define INPUT_TAB 0x09
+
+int main(int argc, char ** agrv){
+ char c;
+ while(read(0,&c,1)){
+
+ switch(c){
+ case INPUT_TAB: printf("\\");
+ break;
+ case '\n': printf("\r\n");
+ break;
+ default : printf("%c",c);
+ break;
+ }
+ }
+
+}//main()
+// Ende.
--- /dev/null
+#include <stdio.h>
+#include <termios.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+
+#define BUFFER_SIZE 1000000
+
+char * buffer;
+int sp;
+
+int main(int argc, char ** argv){
+ sp=0;
+ buffer=(char *) malloc(BUFFER_SIZE);
+ while (read(0, buffer+sp++,1)&& sp-BUFFER_SIZE);
+ fprintf(stderr,"Eingelesen: %i\n",--sp);
+ while(sp) write(1, buffer+--sp,1);
+
+} //main();
+// Ende.
--- /dev/null
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+
+ #define MAX_SIZE 1000000
+
+int main(int argc, char ** argv){
+ int fd= open(argv[1], O_RDONLY );
+ if (fd<1) printf("Scheiße!\n");
+ char * buff=(char *) malloc(MAX_SIZE);
+
+ int sp=0;
+ int ep=read (fd, buff, MAX_SIZE)-1;
+ close (fd);
+
+ while(buff[sp]==0) sp++;
+ while(buff[ep]==0) ep--;
+
+ write(1,buff+sp,ep-sp+1);
+
+}
+
WRITE (1,40) NAME
WRITE (1,50)
DO 200 K=1,5
- WRITE (1,60) K
+ WRITE (1,60) K, NAME
200 CONTINUE
C
10 FORMAT (35HHACHTI'S "HELLO-WORLD", 28.NOV.2004 )
GOTO 300
9999 WRITE(1,80)
80 FORMAT (8HGOODBYE.)
-10000 GOTO 10000
STOP
END
$0
STA 0
*
*SPIEL BEGINNT:
-RND LDA 0
+RND LDA 0
SUB EP
SNZ
* SKIP WENN SP=EP >> FERTIG
JMP* PRT
-*
-*
+*
LDA* 0
-*
+*
ICA
OTA '0004
JMP *-1