more commands I found

This commit is contained in:
Oliver Lehmann 2009-08-13 09:49:54 +00:00
parent cf41d7eef6
commit 04f56172bf
5 changed files with 1224 additions and 0 deletions

185
WEGA/contrib/makea.out.c Normal file
View File

@ -0,0 +1,185 @@
/***********************************************************************
************************************************************************
makea.out (c) zft/keaw abt. basissoftware wae
wega p8000/16-bit-teil
c-program
version : 1.0
datum : 30.06.1988
bearbeiter : r. kuehle
***********************************************************************
das programm makea.out dient der formatierung von ausfuehrbaren ausgabe-
dateien in a.out-format mit der nachfolgenden moeglichkeit der program-
mierung von prom's unter dem programmsystem pburn.
das programm makea.out wird ueber folgendes wega-kommando aufgerufen:
makea.out filename
filename entspricht dem namen der zu formatierenden ausfuehrbaren
ausgabedatei. makea.out erzeugt eine a.out-datei mit dem namen
filename.a
**********************************************************************
*********************************************************************/
/* the valid magic numbers for the a.out are defined below: */
#define X_MAGIC1 0xE507 /* 8-bit executable */
/* valid flags in the s_flags field are defined as follow: */
#define SF_STRIP 0x0001 /* relocation info has been stripped */
#define SF_Z80 0x0008 /* u880 program */
/* these definitions apply to the sg_atr field in the segment table */
#define SG_CODE 0x0001 /* segment contains code */
#define SG_DATA 0x0002 /* contains initialized data */
#define SG_BSS 0x0004 /* contains uninitialized data */
#define SG_STACK 0x0008 /* the segment grows downward */
#define SG_OCODE 0x0010 /* code section is offset */
#define SG_ODATA 0x0020 /* data section is offset */
#define SG_OBSS 0x0040 /* bss section is offset */
#define SG_BOUND 0x0080 /* segment number bound to this section */
#define rmode 0 /* read mode */
#define wmode 1 /* write mode */
main (argc,argv)
int argc;
char *argv[];
{
/* the object module header structure is as defined below for a.out object file format */
struct st1
{
int s_magic; /* magic number */
long s_imsize; /* size of memory image section */
long s_bss; /* size of bss section */
unsigned s_segt; /* size of segment table section */
unsigned s_syms; /* size of symbol table section */
long s_entry; /* entry point address */
unsigned s_flag; /* flags word */
unsigned s_codesz; /* 8-bit padded code size */
unsigned s_lines; /* number of line table entries */
};
struct st1 s_exec;
/* the segment table is an array of the following structure. Each*/
/* entry relates to one segment in the program. For file types */
/* with magic number S_MAGIC1 there is a maximum of 128 such */
/* entries. For file types S_MAGIC3 there is a maximum of */
/* 256 entries. For the remaining file types there is always 1 */
/* entry in the segment table */
struct st2
{
char sg_segno; /* segment number */
char sg_coff; /* offset/256 for code section */
char sg_doff; /* offset/256 for data section */
char sg_boff; /* offset/256 for bss section */
unsigned sg_code; /* size of the code portion */
unsigned sg_data; /* size of the data portion */
unsigned sg_bss; /* size of the bss portion */
int sg_atr; /* attributes */
long sg_unused; /* unused */
};
struct st2 segt;
char *pfile; /* zeiger kommando */
char *pname; /* zeiger filename.p */
int fdi,fda; /* file deskriptor */
long nbytes; /* read n bytes */
long n_read; /* tatsaechlich gelesene bytes */
long n_write; /* tatsaechlich geschriebene bytes */
char aname[30]; /* name a.out-datei */
char buffer[512]; /* puffer */
long size; /* laenge datei */
size=0;
printf ("makea.out (c) zft/keaw 1.0\n");
if (argc != 2) {printf ("error - command line mismatch\n");
exit (0);}
pfile=argv[1];
/* open file command line */
fdi=open (pfile,rmode);
if (fdi==-1) {printf ("error - can't open %s\n",pfile);
exit (0);}
for (pname=aname; *pfile!='\0'; pfile++,pname++)
*pname= *pfile;
*pname= '.';
pname++;
*pname= 'a';
pname++;
*pname= '\0';
pname=aname;
/* open filename.p */
fda=creat (pname,0755);
if (fda==-1) {printf ("error - can't open %s\n",pname);
exit (0);}
lseek (fda, 40L, 0);
nbytes=512;
do
{
n_read=read (fdi,buffer,nbytes);
if (n_read==-1) {printf ("error - %s read error\n",pfile);
close (fdi);
exit(0);}
if (n_read==0) break;
n_write=write (fda,buffer,n_read);
if (n_read!=n_write) {printf ("error - %s write error\n",pname);
close (fdi);
close (fda);
exit(0);}
size=size+n_read;
} while (n_read!=0);
if (size>0xffff) {printf ("error - segment overlay %s\n",pfile);
close (fdi);
close (fda);
exit (0);}
s_exec.s_magic=X_MAGIC1;
s_exec.s_imsize=size;
s_exec.s_bss=0;
s_exec.s_segt=0x10;
s_exec.s_syms=0;
s_exec.s_entry=0;
s_exec.s_flag=0x0001;
s_exec.s_codesz=0;
s_exec.s_lines=0;
segt.sg_segno=0;
segt.sg_coff=0;
segt.sg_doff=0;
segt.sg_boff=0;
segt.sg_code=size;
segt.sg_data=0;
segt.sg_bss=0;
segt.sg_atr=1;
segt.sg_unused=0;
/* header filename.p */
lseek (fda, 0L, 0);
nbytes=24;
n_write=write (fda,&s_exec,nbytes);
if (n_write!=nbytes) {printf ("error - %s write error\n",pname);
close (fdi);
close (fda);
exit (0);}
nbytes=16;
n_write=write (fda,&segt,nbytes);
if (n_write!=nbytes) {printf ("error - %s write error\n",pname);
close (fdi);
close (fda);
exit (0);}
printf ("%s - %d bytes loaded\n",pname,size);
close (fdi);
close (fda);
}

150
WEGA/contrib/makesend.c Normal file
View File

@ -0,0 +1,150 @@
/***********************************************************************
************************************************************************
makesend (c) zft/keaw abt. basissoftware wae
wega p8000/16-bit-teil
c-program
version : 1.0
datum : 20.04.1989
bearbeiter : r. kuehle
***********************************************************************
Auf dem U8-Entwicklungsmodul koennen uber das Kommnado 'SEND' Programme
erzeugt werden (DOWNLOAD). Diese so erzeugten Programme lassen sich
nicht mit dem Kommando 'LOAD' nicht wieder laden (UPLOAD).
Das Programm 'makesend' ist ein Filterprogramm und dient der Formatierung
von ueber das Kommando 'SEND' erzeugten Dateien mit der nachfolgenden
Moeglichkeit, diese formatierten Dateien ueber das Kommando 'LOAD' wieder
in den U8-Entwicklungsmodul laden zu koennen.
Das Programm 'makesend' wird ueber folgendes wega-kommando aufgerufen:
makesend filename
Filename entspricht dem Namen der zu formatierenden Datei.
**********************************************************************
*********************************************************************/
/* the valid magic numbers for the a.out are defined below: */
#define X_MAGIC1 0xE507 /* 8-bit executable */
/* valid flags in the s_flags field are defined as follow: */
#define SF_STRIP 0x0001 /* relocation info has been stripped */
#define SF_SEND 0x0010 /* module created by SEND */
/* these definitions apply to the sg_atr field in the segment table */
#define SG_CODE 0x0001 /* segment contains code */
#define SG_DATA 0x0002 /* contains initialized data */
#define SG_BSS 0x0004 /* contains uninitialized data */
#define SG_STACK 0x0008 /* the segment grows downward */
#define SG_OCODE 0x0010 /* code section is offset */
#define SG_ODATA 0x0020 /* data section is offset */
#define SG_OBSS 0x0040 /* bss section is offset */
#define SG_BOUND 0x0080 /* segment number bound to this section */
main (argc,argv)
int argc;
char *argv[];
{
/* the object module header structure is as defined below for a.out object file format */
struct st1
{
int s_magic; /* magic number */
long s_imsize; /* size of memory image section */
long s_bss; /* size of bss section */
unsigned s_segt; /* size of segment table section */
unsigned s_syms; /* size of symbol table section */
long s_entry; /* entry point address */
unsigned s_flag; /* flags word */
unsigned s_codesz; /* 8-bit padded code size */
unsigned s_lines; /* number of line table entries */
};
struct st1 s_exec;
/* the segment table is an array of the following structure. Each*/
/* entry relates to one segment in the program. For file types */
/* with magic number S_MAGIC1 there is a maximum of 128 such */
/* entries. For file types S_MAGIC3 there is a maximum of */
/* 256 entries. For the remaining file types there is always 1 */
/* entry in the segment table */
struct st2
{
char sg_segno; /* segment number */
char sg_coff; /* offset/256 for code section */
char sg_doff; /* offset/256 for data section */
char sg_boff; /* offset/256 for bss section */
unsigned sg_code; /* size of the code portion */
unsigned sg_data; /* size of the data portion */
unsigned sg_bss; /* size of the bss portion */
int sg_atr; /* attributes */
long sg_unused; /* unused */
};
struct st2 segt;
char *pfile; /* zeiger kommando */
int fd; /* file deskriptor */
long nbytes; /* read n bytes */
long n_read; /* tatsaechlich gelesene bytes */
long n_write; /* tatsaechlich geschriebene bytes */
printf ("makesend (c) zft/keaw 1.0\n");
if (argc != 2) {printf ("error - command line mismatch\n");
exit (0);}
pfile=argv[1];
/* open file command line */
fd=open (pfile,2);
if (fd==-1) {printf ("error - can't open %s\n",pfile);
exit (0);}
nbytes=24L;
n_read=read (fd, &s_exec, nbytes);
if (n_read!=nbytes||n_read==0L)
{printf ("error - %s read error\n",pfile);
close (fd);
exit (0);}
if (s_exec.s_magic!=X_MAGIC1)
{printf ("error - %s invalid file type\n",pfile);
close (fd);
exit (0);}
if ((s_exec.s_flag & SF_SEND)==0)
{printf ("error - %s not created by SEND\n",pfile);
close (fd);
exit (0);}
s_exec.s_flag=SF_STRIP;
s_exec.s_imsize--;
nbytes=16L;
n_read=read (fd, &segt, nbytes);
if (n_read!=nbytes||n_read==0L)
{printf ("error - %s read error\n",pfile);
close (fd);
exit (0);}
segt.sg_code--;
/* header formatierte file */
lseek (fd, 0L, 0);
nbytes=24L;
n_write=write (fd, &s_exec, nbytes);
if (n_write!=nbytes)
{printf ("error - %s write error\n",pfile);
close (fd);
exit (0);}
nbytes=16L;
n_write=write (fd, &segt, nbytes);
if (n_write!=nbytes)
{printf ("error - %s write error\n",pfile);
close (fd);
exit (0);}
printf ("%s - load formatted\n",pfile);
close (fd);
}

80
WEGA/contrib/saw.1 Normal file
View File

@ -0,0 +1,80 @@
.TH SAW 1
.\" @[$]saw.1 1.0
.ad
.fi
.SH NAME
saw
.SH SYNTAX
.B saw
file
.SH BESCHREIBUNG
Das Programm
.B saw
ist ein Filterprogramm.
.br
Mit diesem Programm werden segmentierte Programme entsprechend den
Segmentnummern in nichtsegmentierte Programme aufgesplittet.
.br
Die so erzeugten 'files' koennen mit dem LOAD-Kommando einzeln
in ein entsprechenden Entwicklungsmodul (Emulator) geladen werden.
.br
.B Saw
erzeugt Dateien mit nachfolgend aufgefuehrter Charakteristik.
.br
.sp
.nf
filename.segment_attribut:
--------------------------
filename ... entspricht dem Namen der zu splittenden Datei
segment ... Segmentnummmer
attribut ... c - Segment enthaelt Code
d - Segment enthaelt initialisierte Daten
b - Segment enthaelt uninitialisierte Daten
object module header:
---------------------
s_magic : N_MAGIC1 (0xE707 nonsegmented executable)
s_imsize: _c Laenge Code
_d Laenge Daten
_b = 0
s_bss : _c = 0
_d = 0
_b Laenge uninitialisierte Daten
s_segt : 0x10
s_syms : 0
s_entry : 0
s_flag : 0x0001
s_codesz: 0
s_lines : 0
segment table:
--------------
entsprechend dem Original-Segment
.fi
.bp
.SH BEISPIEL
.PD 0
.TP
\&% saw test
.TP
(c) zft/keaw v. 1.0 splitted:
.TP
test.0_c
.TP
test.32_d
.TP
test.64_b
.TP
test.65_b
.TP
\&%
.sp 1
.SH SIEHE AUCH
.PD 0
.TP
\&a.out(5)
.TP
LOAD(1)
.sp 1
.SH DIAGNOSTIK
Auftretende Fehler sind in den Ausschriften selbstklaerend.

275
WEGA/contrib/saw.c Normal file
View File

@ -0,0 +1,275 @@
/***********************************************************************
************************************************************************
saw.c (c) zft/keaw abt. basissoftware wae
wega p8000/16-bit-teil
c-program
version : 1.0
datum : 05.01.1990
bearbeiter : r. kuehle
***********************************************************************
cmdsaw: scc -c saw.c
gld /lib/scrt0.o saw.o -o saw -lc
***********************************************************************
Das Programm 'saw' ist ein Filterprogramm.
Mit diesem Programm werden segmentierte Programme entsprechend
den Segmentnummern in nichtsegmentierte Programme aufgesplittet.
Die so erzeugten Programme koennen damit mit dem LOAD-Kommando einzeln
in ein entsprechenden Entwicklungsmodul (Emulator) geladen werden.
Das Programm 'saw' wird ueber folgendes wega-kommando aufgerufen:
saw filename
und erzeugt nachfolgend aufgefuehrte files
filename.segment_attribut
filename ... entspricht dem Namen der zu splittenden Datei
segment ... segment nummer
attribut ... c - segment enthaelt code
d - segment enthaelt initialisierte daten
b - segment enthaelt uninitialisierte Daten
mit nachfolgender characteristik:
object module header:
---------------------
s_magic : N_MAGIC1 (0xE707 nonsegmented executable)
s_imsize: size code oder data portion
bss = 0
s_bss : size bss portion
code/data = 0
s_segt : 0x10
s_syms : 0
s_entry : 0
s_flag : 0x0001
s_codesz: 0
s_lines : 0
segment table:
--------------
entsprechend dem selektierten segment
**********************************************************************
*********************************************************************/
/* the valid magic numbers for the a.out are defined below: */
#define S_MAGIC1 0xE607 /* segmented executable */
#define S_MAGIC3 0xE611 /* segmented separate I & D */
#define S_MAGIC4 0xE605 /* segmented overlay */
#define N_MAGIC1 0xE707 /* nonsegmented executable */
#define N_MAGIC3 0xE711 /* nonsegmented separate I& D */
#define N_MAGIC4 0xE705 /* nonsegmented overlay */
/* valid flags in the s_flags field are defined as follow: */
#define SF_STRIP 0x0001 /* relocation info has been stripped */
/* these definitions apply to the sg_atr field in the segment table */
#define SG_CODE 0x0001 /* segment contains code */
#define SG_DATA 0x0002 /* contains initialized data */
#define SG_BSS 0x0004 /* contains uninitialized data */
#define SG_STACK 0x0008 /* the segment grows downward */
#define SG_OCODE 0x0010 /* code section is offset */
#define SG_ODATA 0x0020 /* data section is offset */
#define SG_OBSS 0x0040 /* bss section is offset */
#define SG_BOUND 0x0080 /* segment number bound to this section */
/* the object module header structure is as defined below for a.out object file format */
struct st1
{
int s_magic; /* magic number */
long s_imsize; /* size of memory image section */
long s_bss; /* size of bss section */
unsigned s_segt; /* size of segment table section */
unsigned s_syms; /* size of symbol table section */
long s_entry; /* entry point address */
unsigned s_flag; /* flags word */
unsigned s_codesz; /* 8-bit padded code size */
unsigned s_lines; /* number of line table entries */
};
struct st1 s_exec;
/* the segment table is an array of the following structure. Each*/
/* entry relates to one segment in the program. For file types */
/* with magic number S_MAGIC1 there is a maximum of 128 such */
/* entries. For file types S_MAGIC3 there is a maximum of */
/* 256 entries. For the remaining file types there is always 1 */
/* entry in the segment table */
struct st2
{
char sg_segno; /* segment number */
char sg_coff; /* offset/256 for code section */
char sg_doff; /* offset/256 for data section */
char sg_boff; /* offset/256 for bss section */
unsigned sg_code; /* size of the code portion */
unsigned sg_data; /* size of the data portion */
unsigned sg_bss; /* size of the bss portion */
int sg_atr; /* attributes */
long sg_unused; /* unused */
};
struct st2 segt;
char *pfile; /* zeiger kommando */
char *pname, *pname1, *pname2; /* zeiger filename.segment.attribut */
char name[50]; /* filename.segment.attibut */
char zi_ascii[10]; /* ziffern 0 ... 9 */
char buffer[0xfffe]; /* buffer */
int fd, fd1; /* file deskriptor */
int segno; /* segment nummer */
int i; /* indizes */
long zseg; /* zaehler segment table */
long nbytes; /* read n bytes */
long n_read; /* tatsaechlich gelesene bytes */
long n_write; /* tatsaechlich geschriebene bytes */
long seg_offset; /* segment offset */
long dat_offset; /* code und data offset */
main (argc,argv)
int argc;
char *argv[];
{
printf ("(c) zft/keaw v. 1.0 splitted:\n");
if (argc != 2) {printf ("error - command line mismatch\n");
exit (0);}
pfile=argv[1];
/* open file command line */
fd=open (pfile,0);
if (fd==-1) {printf ("error - can't open %s\n",pfile);
exit (0);}
for (pname1=name; *pfile!='\0'; pfile++, pname1++)
*pname1= *pfile;
*pname1='.';
*pname1++;
pfile=argv[1];
pname=name;
nbytes=24L;
n_read=read (fd, &s_exec, nbytes);
if (n_read!=nbytes||n_read==0L)
{printf ("error - %s read error\n",pfile);
close (fd);
exit (0);}
/* pruefung gueltige MAGIC-Number */
if (s_exec.s_magic!=S_MAGIC1&&s_exec.s_magic!=S_MAGIC3&&s_exec.s_magic!=S_MAGIC4&&s_exec.s_magic!=N_MAGIC1&&s_exec.s_magic!=N_MAGIC3&&s_exec.s_magic!=N_MAGIC4)
{printf ("error - %s invalid file type\n",pfile);
close (fd);
exit (0);}
/* pruefung mehr als ein Segment */
if (s_exec.s_segt == 0x10)
{printf ("error - %s can't splitt, 1 segment\n",pfile);
close (fd);
exit (0);}
zseg=s_exec.s_segt & 0xffff;
seg_offset=24L;
dat_offset=24L+s_exec.s_segt & 0xffff;
s_exec.s_magic=N_MAGIC1;
s_exec.s_segt=0x10;
s_exec.s_syms=0;
s_exec.s_entry=0L;
s_exec.s_flag=0x0001;
s_exec.s_codesz=0;
s_exec.s_lines=0;
zi_ascii[0]='0';
zi_ascii[1]='1';
zi_ascii[2]='2';
zi_ascii[3]='3';
zi_ascii[4]='4';
zi_ascii[5]='5';
zi_ascii[6]='6';
zi_ascii[7]='7';
zi_ascii[8]='8';
zi_ascii[9]='9';
do
{
lseek (fd,seg_offset,0);
s_exec.s_imsize=0L;
s_exec.s_bss=0L;
nbytes=16L;
n_read=read (fd, &segt, nbytes);
if (n_read!=nbytes||n_read==0)
{printf ("error3 - %s read error\n",pfile);
close (fd);
exit (0);}
nbytes=segt.sg_code + segt.sg_data;
nbytes=nbytes & 0xffff;
lseek (fd,dat_offset,0);
if (nbytes!=0L)
{n_read=read (fd, buffer, nbytes);
if ((n_read & 0xffff)!=nbytes)
{printf ("error - %s read error\n",pfile);
close (fd);
exit (0);}
s_exec.s_imsize=nbytes;}
/*segment in filename.segment. ...*/
segno=segt.sg_segno & 0x00ff;
pname2=pname1;
do
{
for (i= -1; segno>=0; i++)
segno=segno-10;
segno=segno+10;
if (i==0) *pname2=zi_ascii[segno];
else *pname2=zi_ascii[i];
pname2++;
} while (i!=0);
/*attribut in filename. ... .attribut*/
*pname2='_';
pname2++;
if ((segt.sg_atr & 0x0001)>0) {*pname2='c';
pname2++;}
if ((segt.sg_atr & 0x0002)>0) {*pname2='d';
pname2++;}
if ((segt.sg_atr & 0x0004)>0) {*pname2='b';
s_exec.s_bss=segt.sg_bss;
pname2++;}
*pname2='\0';
fd1=creat (pname,0755);
if (fd1==-1) {printf ("error - can't open %s\n",pname);
exit (0);}
n_write=write (fd1,&s_exec,24L);
if (n_write!=24L) {printf ("error - %s write error\n",pname);
close (fd1);
break;}
n_write=write (fd1,&segt,16L);
if (n_write!=16L) {printf ("error - %s write error\n",pname);
close (fd1);
break;}
n_write=write (fd1,buffer,nbytes);
if ((n_write & 0xffff)!=nbytes)
{printf ("error - %s write error\n",pname);
close (fd1);
break;}
printf ("%s\n",pname);
close (fd1);
seg_offset=seg_offset+16L;
dat_offset=dat_offset+nbytes;
zseg=zseg-16L;
} while (zseg!=0L);
close (fd);
}

534
WEGA/contrib/udformat.c Normal file
View File

@ -0,0 +1,534 @@
/**************************************************************************
***************************************************************************
W E G A - Quelle (C) ZFT/KEAW Abt. Basissoftware - 1989
Programm: udformat.c
Bearbeiter : P. Hoge
Datum : 10.3.89
Version : 1.1
***************************************************************************
Formatieren von UDOS-Disketten
Syntax: udformat [udosdev]
***************************************************************************
**************************************************************************/
#include <signal.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
/*
* USER-DISK:
* SPUR 16H SEKTOREN 0,5,A,1,6,B DIRECTORY
* SPUR 16H SEKTOR 2 POINTERSEKTOR DER DIRECTORY
* SPUR 17H SEKTOREN 0,1 DISK-ALLOCATION-MAP
* ZAHL DER FREIEN SEKTOREN: 277H
* ZAHL DER BELEGTEN SEKTOREN: 9 + 720H (NICHT VORHANDENE SEKTOREN) = 729H
*/
char *arg0;
int fd;
char buf[512];
char f48ss9[31] = {
0xeb, 0x34, 0x90, /* JMP BOOT */
'W','E','G','A','-','D','O','S',/* System id */
00, 2, /* bytes per sector */
2, /* sectors per cluster */
01, 0, /* reserved sectors at beginning */
2, /* fat-copies */
64, 0, /* directory entries */
360%256, 360/256, /* number of all sectors */
0xfc, /* format id */
2,0, /* sectors per fat */
9,0, /* sectors per track */
1,0, /* number of sides */
0,0, /* special reserved sectors */
0xf0, /* 1. byte fat */
};
char f96ds9[31] = {
0xeb, 0x34, 0x90, /* JMP BOOT */
'W','E','G','A','-','D','O','S',/* System id */
00, 2, /* bytes per sector */
2, /* sectors per cluster */
01, 0, /* reserved sectors at beginning */
2, /* fat-copies */
112, 0, /* directory entries */
1440%256, 1440/256, /* number of all sectors */
0xf9, /* format id */
3,0, /* sectors per fat */
9,0, /* sectors per track */
2,0, /* number of sides */
0,0, /* special reserved sectors */
0xf9 /* 1. byte fat */
};
main(argc,argv)
char **argv;
{
char *fdname;
int dev = 0;
struct stat mstat;
char *pboot;
arg0 = argv[0];
switch (argc) {
case 1:
fdname = "/dev/rfd196ds16";
break;
case 2:
fdname = argv[1];
break;
default:
error:
fprintf(stderr,"usage: udformat [udosdev]\n");
exit(1);
}
if (stat(fdname, &mstat) == 0) {
if (mstat.st_mode & (S_IFBLK | S_IFCHR)) {
dev++; /* echte Floppy */
}
}
pboot = f96ds16;
if (cmp(fdname, "/dev/") {
if (dev == 0)
goto error;
if (cmp(fdname, "48ss16")
pboot = f48ss16;
else if (cmp(fdname, "96ds16") == 0) {
fprintf(stderr, "%s: invalid UDOS format\n", arg0);
exit(1);
}
}
if (dev) {
strcpy(buf, "format "); /* physisch Formatieren */
strcat(buf, fdname);
if (system(buf))
exit(1);
}
if ((fd = open(fdname, O_RDWR|O_CREAT|O_TRUNC, 0664)) < 0) {
fprintf(stderr, "%s: kann %s nicht oeffnen\n", arg0, fdname);
exit(1);
}
signal(SIGALRM, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
putdata(pboot);
exit(0);
}
putsect()
{
if (write(fd, buf, 512) != 512) {
fprintf(stderr, "%s: Schreibfehler in %s\n", arg0, fdname);
exit(1);
}
}
putdata(p)
register char *p;
{
register i, j;
clear_buf(); /* write boot sector */
for (i = 0; i < 30; i++)
buf[i] = p[i];
buf[0x2f] = p[24]; /* sectors/track */
buf[0x1fe] = 0x55;
buf[0x1ff] = 0xaa;
putsect();
/* write fat's */
i = p[16]; /* number of fats */
while (i--) {
clear_buf();
buf[0] = p[30]; /* 1. byte fat */
buf[1] = 0xff;
buf[2] = 0xff;
j = p[22]; /* number of fat sectors */
while (j--) {
putsect();
clear_buf();
}
}
/* write directory */
i = ((p[17]&0x00ff) * 32)/512; /* number of directory sectors */
while (i--)
putsect();
}
clear_buf()
{
register i = sizeof(buf);
register char *s = buf;
while (i--)
*s++ = 0;
}
cmp(s1, s2)
register char *s1, *s2;
{
register char *s3;
s3 = s2;
while (1) {
if (*s1 == 0)
return(0);
if (*s1 != *s2) {
s1++;
continue;
}
loop:
if (*s2 == 0)
return(1);
if (*s1 != *s2) {
s2 = s3;
continue;
}
s1++;
s2++;
goto loop;
}
}
123:
;******************************************************************************
; KOMMANDOABARBEITUNG
;******************************************************************************
; ERZEUGEN DER BITMAP, DES DIRECTORY-DESCRIPTORS UND DES 1. DIRECTORYSEKTORS
;
CALL ERBIMA ;ERZEUGEN DER BITMAP
CALL ERDIDE ;ERZEUGEN DES DIRECTORYDESCRIPTORS U. 1. SEKTOR
;
; BITMAP SCHREIBEN (1700 / 1701)
;
CALL WRBIMA ;BITMAP SCHREIBEN
;
; DESCRIPTOR DER DIRECTORY SCHREIBEN (1600)
;
LD IY,DIDESV ;VEKTOR FUER DESCRIPTOR
LD HL,DIRDES ;PUFFERANFANGSADRESSE
LD (DIDESV+2),HL
LD HL,100H ;DATENLAENGE
LD (DIDESV+4),HL
LD HL,1600H
LD (DIDESV+11),HL
LD A,(DRIVAD) ;DRIVEADRESSE
LD (IY+11),A ;IN VEKTOR LADEN
CALL FLOPPY ;DIR.-DESCRIPTOR SCHREIBEN
LD A,(IY+10) ;COMPLETION CODE
BIT 6,A ;FEHLER ?
JP NZ,FTEST ;FEHLERTEST
;
; 1. DATENSEKTOR DER DIRECTORY SCHREIBEN (1605)
;
LD A,(DIDESV+11)
ADD A,5 ;SEKTORADRESSE+5
LD (DIDESV+11),A
LD HL,DIRSEC ;DATENADRESSE 1. DIR.-SEKTOR
LD (DIDESV+2),HL ;ADRESSE LADEN
LD HL,100H
LD (DIDESV+4),HL ;DATENLAENGE LADEN
CALL FLOPPY ;1.SEKTOR SCHREIBEN
LD A,(IY+10) ;COMPLETION CODE
BIT 6,A ;FEHLER ?
JP NZ,FTEST ;FEHLERTEST
;
; RESTLICHE DATENSEKTOREN DER DIRECTORY SCHREIBEN
;
CALL CLEAR ;SPEICHER LOESCHEN
LD A,-1 ;-1 AM SEKTORANFANG,DA SEKTOR
LD (DIRSEC),A ;OHNE INFORMATION
;
LD HL,SEKTAB ;SEKTORADRESSTABELLE
LD B,4 ;WEITERE 4 SEKTOREN DER DIRECTORY
WRLOOP
LD A,(DRIVAD) ;DRIVEADRESSE
ADD A,(HL) ;AKTUELLE SEKTORADRESSE
LD (DIDESV+11),A ;IN VEKTOR LADEN
INC HL
LD A,(HL) ;SPUR
LD (DIDESV+12),A ;IN VEKTOR LADEN
INC HL
PUSH HL ;POSITION RETTEN
PUSH BC ;B-REGISTER RETTEN
LD HL,100H
LD (DIDESV+4),HL ;DATENLAENGE LADEN
CALL FLOPPY ;SEKTOR SCHREIBEN
POP BC
POP HL
LD A,(DIDESV+10) ;COMPLETION CODE
BIT 6,A ;FEHLER ?
JP NZ,FTEST ;FEHLERTEST
DJNZ WRLOOP ;NAECHSTER SEKTOR
;
; POINTERSEKTOR DER DIRECTORY SCHREIBEN (1602)
;
CALL CLEAR ;SPEICHER LOESCHEN
LD HL,POITAB ;POINTERTABELLE
LD DE,DIRSEC
LD BC,14
LDIR ;ZEIGER DER DIRECTORY IN POINTERSEKTOR EINTR.
;
LD HL,10 ;RELAT. ADRESSE DES LETZTEN ZEIGERS IM
;POINTERSEKTOR BZGL. DES SEKTORANFANGES
LD (DIRSEC+0FAH),HL
;
LD HL,-1 ;BACKPOINTER DES POINTERSEKTORS
LD (DIRSEC+0FEH),HL
;
LD HL,1600H ;FOREPOINTER DES POINTERSEKTORS (DESCR.-ADR.)
LD (DIRSEC+0FCH),HL
;
LD HL,100H ;DATENLAENGE
LD (DIDESV+4),HL
LD HL,1602H
LD A,(DRIVAD)
ADD A,L
LD L,A
LD (DIDESV+11),HL ;SPUR/SEKTORADR. LADEN
CALL FLOPPY
LD A,(DIDESV+10)
BIT 6,A
JP NZ,FTEST ;FEHLER
;***ERZEUGEN DER BITMAP***
erbimap procedure()
{
register i, j;
i = 4*80+4;
clr_buf();
LD BC,4*80+4 ;4 * 80 SPUREN + PRUEFSUMMEN
LDIR ;LOESCHEN
LD (HL),77H
LD BC,1BH
LDIR
;
; Adresse fuer die Anzahl belegter und freier Sektoren erzeugen
;
LD A,(CMDF) ;aktuelle Diskettenkonfiguration laden
LD B,A
PUSH HL ;<HL> speichern
LD HL,BELTAB ;laden mit dem Anfangswert der Belegungstabelle
LD DE,7 ;Wert fuer die Verschiebung
JR DECB
ABT ADD HL,DE
DECB DJNZ ABT
POP DE ;Adresse aus <HL> in <DE> zurueck
;
; Eintragen der Werte aus der Tabelle
;
LD BC,7 ;alle restlichen Werte eintragen
LDIR ;belegte Sektoren eintragen
;
XOR A
LD (DE),A
INC DE
LD (DE),A
;
LD HL,UNBEN
LD DE,UNBEN+1
LD BC,80H
LD (HL),0
LDIR ;REST ZU 200H LAENGE UNBENUTZT
;
LD HL,30E6H
LD (SPUR16),HL ;SPUR 16H, SEKTOREN 0,1,2,5,6,A,B BELEGT SETZEN
LD A,0C0H
LD (SPUR17),A ;SPUR 17H, SEKTOREN 0,1 BELEGT SETZEN
;
; Belegte Sektoren entsprechend Diskettentyp eintragen
;
LD A,(CMDF)
CP 5
RET Z
CP 4
JR Z,BSB32
;
; Rest kannn nur noch 40-Spuren-Diskette sein.
;
LD HL,SPUR28 ;SPUREN 28H-4CH NICHT VORHANDEN
LD (HL),0FFH ;--> BELEGT SETZEN
LD DE,SPUR28+1
LD BC,4*28H-1 ;28H SPUREN
LDIR
;
BSB32 LD HL,SPUR0 ;SPUR 0-4CH, SEKTOREN 10H-1FH NICHT VORHANDEN
LD B,80 ;--> BELEGT SETZEN
ERB1: INC HL
INC HL
LD (HL),0FFH ;SEKTOREN 10H-17H
INC HL
LD (HL),0FFH ;SEKTOREN 18H-1FH
INC HL
DJNZ ERB1
RET
;***ERZEUGEN DES DIRECTORYDESCRIPTORS UND DES 1. DIRECTORYSEKTORS***
ERDIDE LD HL,KDIDES ;DESCRIPTORKONSTANTEN
LD DE,DIRDES ;DATENFELD
LD BC,24
LDIR ;KONSTANTEN UMLADEN
LD HL,DATE ;AKTUELLES DATUM
LD BC,8
PUSH HL
PUSH BC
LDIR ;DATE OF CREATION
POP BC
POP HL
LDIR ;DATE OF LAST MODIFICATION
LD H,D
LD L,E
INC DE
LD (HL),0 ;REST MIT 0 FUELLEN
LD BC,215
LDIR
LD HL,1602H
LD (DIRDES+80H),HL ;ADRESSE DES POINTERSEKTORS DER DIRECTORY
;
LD HL,KDIREC1 ;KONSTANTEN FUER 1.DIR.-SEKTOR
LD DE,DIRSEC
LD C,13
LDIR ;UMLADEN
RET
;***DIRECTORYDESCRIPTORKONSTANTEN***
KDIDES DEFW 0 ;NICHT BENUTZT
DEFW 0 ;NICHT BENUTZT
DEFW 0 ;NICHT BENUTZT
DEFW 1605H
DEFW 1605H ;ERSTER SEKTOR
DEFW 160BH ;LETZTER SEKTOR
DEFB 40H ;FILETYP=DIRECTORY
DEFW 5 ;RECORDANZAHL=5
DEFW 100H ;RECORDLAENGE=100H
DEFW 100H ;BLOCKLAENGE=100H
DEFB 0F0H ;PROPERTIES='WELS'
DEFW 0
DEFW 0
;***KONSTANTEN FUER 1.DIR.-SEKTOR***
KDIREC1 DEFB 89H ;BIT 7=1 DA SECRET, 9 BUCHSTABEN
DEFM 'DIRECTORY' ;NAME
DEFW 1600H ;ADRESSE DES DESCRIPTORS
DEFB -1 ;LETZTE ANGEGEBENE DATEI
;***SEKTORADRESSTABELLE DER DIRECTORY***
POITAB DEFW 1600H
DEFW 1605H
SEKTAB DEFW 160AH
DEFW 1601H
DEFW 1606H
DEFW 160BH
DEFW -1 ;NACHFOLGER FEHLT
; Tabelle fuer Anzahl belegter und freier Sektoren und Diskettenwerte
BELTAB
DEFW 1929 ;Typ 2, 40-Spuren-Diskette
DEFB 0
DEFB 16
DEFB 40
DEFW 631
DEFW 9 ;Typ 5, 80-Spuren-Diskette, doppelseitig
DEFB 1
DEFB 32
DEFB 80
DEFW 2551
; Tabelle der Datenlaengen fuer die Sektorinformationen
DLTAB
DEFB 0DH
DEFB 10H
DEFB 10H
DEFB 10H
DEFB 20H
DEFB 24H
DEFB 28H
DEFB 3CH
DEFB 40H
;***SCHREIBEN DER BITMAP AUF DISKETTE***
WRBIMA LD IY,BITMAV ;VEKTOR FUER BITMAP SCHREIBEN
LD A,(DRIVAD) ;DRIVEADRESSE
LD (IY+11),A ;IN VEKTOR LADEN
CALL FLOPPY ;SCHREIBEN AUF DISKETTE
RET
;
; ***SCHREIBEN VON SEKTOREN AUF FORMATIERTE DISKETTE***
; INPUT: HL - PUFFERANFANGSADRESSE
; BC - DATENLAENGE
; DE - SPURNUMMER / SEKTORNUMMER
;
FLPWRT: LD IY,RDVEKT
LD (IY+0),0 ;UNIT 0
LD (IY+1),0EH ;WRITE BINARY
LD (RDVEKT+2),HL
LD (RDVEKT+4),BC
LD A,(DRIVAD)
OR E
LD E,A
LD (RDVEKT+11),DE
CALL FLOPPY
LD A,(RDVEKT+10)
BIT 6,A
RET Z
POP DE
JP FTEST
; DISK ALLOCATION MAP
;
BITMAP DEFS 18H ;DISK ID (MAX. 24 ZEICHEN)
MAPTAB
SPUR0 DEFS 54H ;SPUREN 0-14H
SPUR15 DEFS 4 ;SPUR 15H
SPUR16 DEFS 4 ;SPUR 16H
SPUR17 DEFS 44H ;SPUREN 17H-27H
SPUR28 DEFS 94H ;SPUREN 28H-4CH
DEFS 4 ;=0
DEFS 0AH ;=33H
KZ1 DEFS 2 ;=33F7H USER-DISK BZW. =38F8H SYSTEM-DISK
DEFS 1BH ;=77H
BELEGT DEFS 2 ;ANZAHL DER BELEGTEN SEKTOREN
DEFS 2 ;=0
KZ2 DEFS 1 ;=4BH USER-DISK BZW. =4AH SYSTEM-DISK
FREI DEFS 2 ;ANZAHL DER FREIEN SEKTOREN
DEFS 2 ;=0
UNBEN DEFS 80H ;UNBENUTZT (NUR REST ZU RL=200)
;
DIRDES DEFS 100H ;DIRECTORYDESCRIPTORSPEICHER
DIRSEC DEFS 100H ;DIRECTORYSEKTORSPEICHER
;
URLAD DEFS 100H
OSLOAD DEFS 300H
GET DEFS 400H
SAVE DEFS 0E00H
PFRL DEFS 4000H
RAMEND defs 0