finish s1.s; tried to clean up s5-s8; let as7 continue after error

This commit is contained in:
Phil Budne
2016-02-25 20:58:17 -05:00
parent 0b0ea2e637
commit 2cca3d4473
9 changed files with 206 additions and 89 deletions
+4
View File
@@ -0,0 +1,4 @@
AS7=../tools/as7 -d
system:
$(AS7) s?.s > output
+8 -1
View File
@@ -6,5 +6,12 @@ For modified versions of these files, look in src/cmds and src/sys.
Details of the files: Details of the files:
s1.s: pages 2-3 of 01-s1.pdf, incomplete and with some cruft at the end s1.s: pages 2-5 of 01-s1.pdf, incomplete
s2.s: pages 7-
s3.s: pages 14-
s4.s: pages 21-
s5.s: pages 28-
s6.s: pages 34-
sx.s: temp symbol defns (from end of s1.s)
cat.c: pages 21-23 of 06-5-12.pdf cat.c: pages 21-23 of 06-5-12.pdf
+87 -24
View File
@@ -102,31 +102,94 @@ swap: 0
dac u.ulistp i dac u.ulistp i
ion ion
jmp dskswap; 07000 jmp dskswap; 07000
lac u.dspbuf
sna
jmp 2f
law dspbuf
jms movdsp
2:
iof
lac o600000
tad 9f+t i
dac 9f+t i
ion
jms dskswap; 06000
lac u.swapret
dac swap
lac o20
dac maxquant
lac u.dspbuf
sza
"** 01-s1.pdf page 4
jms movdsp
3:
dzm uquant
iof
jmp swap i
t = t+1
" For now, this stuff is defined so that swp:
" the assembler doesn't complain about it jmp .
.save; .getuid; .open; .read; .write; .creat; .seek; .tell
.close; .link; .unlink; .setuid; .rename; .exit; .time; .intrp
.chdir; .chmod; .chown; badcal; .sysloc; badcal; .capt; .rele
.status; badcal; .sems; .rmes; .fork
swn:
.-swp-1 i
.intrp:
lac u.ac
dac u.intflg
jmp okexit
.sysloc:
lac u.ac
and o1777
jms betwen; d1; locn
jms error
tad locsw
dac .+1
lac ..
dac u.ac
jmp sysexit
locsw:
lac .
iget; inode; userdata; sysdata; copy; copyz; betwen; dskrd
dskwr; dskbuf; dpdata; namei; pbsflgs; alloc; free; dspdata
crdata
locn:
.-locsw-1
pibreak: 23
u.ac: 100
u.mq: 3
u.rq: 3
copy: 7
.savblk: 0
.insys: 0
uquant: 0
betwen: 0
maxquant: 0
laci: 0
swp: 0
badcal: 0
coldentry: 0
halt: 0
dskio: 0
sysdata: 0
dskbuf: 0
o7000: 07000
o20001: 020001
chkint: 0 chkint: 0
.save: 0 lac .insys
lookfor: 0 sza
jmp chkint i
lac .int1
sna
jmp 1f
sad u.ofiles+2
jmp 2f
1:
lac .int2
sna
jmp chkint i
sad chkint i
sad u.ofiles+2
skp
jmp chkint i
dzm .int2
jmp 1f
2:
dzm .int1
1:
"** 01-s1.pdf page 5
lac u.intflg
sza
jmp chkint i
-1
dac .insys
ion
isz chkint
jmp chkint i
+23 -23
View File
@@ -2,15 +2,15 @@
" s5 " s5
dskswap: 0 dskswap: 0
cli; ais 3 cll; als 3
dac 9f+t dac 9f+t
jms dsktrans; -64; userdata; 9f+t; dskswap jms dsktrans; -64; userdata; 9f+t; dskswap
lac 0f+t lac 9f+t
tad o20 tad o20
dac 9f+t dac 9f+t
jms dsktrans; -4096; 4096; 9f+t; dekswap jms dsktrans; -4096; 4096; 9f+t; dskswap
isc dskswap isz dskswap
jmp dskswap jmp dskswap i
t = t+1 t = t+1
@@ -21,7 +21,7 @@ access: 0
spa spa
jmp access i jmp access i
sad i.uid sad i.uid
ird 2 lrs 2
lacq lacq
and mode and mode
sza sza
@@ -60,8 +60,8 @@ t = t+1
fget: 0 fget: 0
jms betwen; d0; d9 jms betwen; d0; d9
jmp fget i jmp fget i
cli; mul; 3 cll; mul; 3
iacq "** ?? lacq
"** 01-s1.pdf page 29 "** 01-s1.pdf page 29
tad ofilesp tad ofilesp
@@ -83,14 +83,14 @@ forall: 0
sad u.limit sad u.limit
jmp 1f jmp 1f
lac u.base lac u.base
rai ral
lac u.base i lac u.base i
sni snl
lrs 9 lrs 9
and o777 and o777
jmp forall i jmp forall i
1: 1:
lac u.ount lac u.count
dac u.ac dac u.ac
jmp sysexit jmp sysexit
@@ -157,7 +157,7 @@ icreat: 0
lac u.uid lac u.uid
dac u.uid dac u.uid
-1 -1
dac i.niks dac i.nlks
dzm i.size dzm i.size
jms copyz; i.dskps; 7 jms copyz; i.dskps; 7
jms iput jms iput
@@ -171,9 +171,9 @@ dspput: 0
jmp i dspput jmp i dspput
sad o14 sad o14
jmp 1f jmp 1f
img "** ??? lmq
sad o12 sad o12
jmp dspni jmp dspnl
lac dsploc i lac dsploc i
sad o400000 sad o400000
jmp dspleft jmp dspleft
@@ -195,19 +195,19 @@ dspleft:
dac 8 dac 8
lac o400000 lac o400000
dac 8 i dac 8 i
cla; liss 18+7 cla; llss 18+7
dac dsploc i dac dsploc i
jmp dspput i jmp dspput i
dspni: 0 dspnl: 0
lac dspino lac dsplno
sad d33 sad d33
jmp 1f jmp 1f
isz dspino isz dsplno
jmp dspni i jmp dspnl i
1: 1:
lac o2000 lac o2000
wbi wbi "** ??
isz dspput isz dspput
jmp dspput i jmp dspput i
@@ -216,12 +216,12 @@ dspinit: 0
dac dsploc dac dsploc
lac o300000 lac o300000
dac dspbuf+3 dac dspbuf+3
dzm dspino dzm dsplno
jmp dspinit i jmp dspinit i
movdsp: 0 movdsp: 0
iof iof
cdf caf
dac dspbufp dac dspbufp
-1 -1
dac .dspb dac .dspb
@@ -237,7 +237,7 @@ argname: 0
jms arg jms arg
dac .+2 dac .+2
jms copy; ..; name; 4 jms copy; ..; name; 4
lac u.edir lac u.cdir
jms namei; name jms namei; name
jms error jms error
jmp argname i jmp argname i
+16 -16
View File
@@ -37,7 +37,7 @@ itrunc: 0
jmp 1b jmp 1b
lac i.flags lac i.flags
and o577777 and o577777
dac i.flacs dac i.flags
jmp itrunc i jmp itrunc i
t = t+4 t = t+4
@@ -54,7 +54,7 @@ namei: 0
-8 -8
tad i.size tad i.size
cma cma
irss 3 lrss 3
dac 9f+t dac 9f+t
sna sna
jmp namei i jmp namei i
@@ -94,13 +94,13 @@ t = t+2
iget: 0 iget: 0
dac ii dac ii
cli; idiv; 5 cll; idiv; 5
dac 9f+t dac 9f+t
tad d2 tad d2
dac 9f+i+1 dac 9f+i+1
jms dskrd jms dskrd
lac 9f+t lac 9f+t
cli; mul; 12 cll; mul; 12
lacq lacq
tad dskbufp tad dskbufp
dac 9f+t dac 9f+t
@@ -151,14 +151,14 @@ dget: 0
alss 3 alss 3
dac 9f+t dac 9f+t
jms pget jms pget
fac 9f+t+1 dac 9f+t+1
jms dskrd jms dskrd
lac 9f+t lac 9f+t
and o77 and o77
tad dskbufp tad dskbufp
dac 9f+t+2 dac 9f+t+2
dac .+2 dac .+2
jms copy; ..; dnode; 8 jms copy; ..; inode; 8
lac 9f+t lac 9f+t
tad d8 tad d8
jms betwen; d0; i.size jms betwen; d0; i.size
@@ -173,7 +173,7 @@ dput: 0
jms dskrd jms dskrd
lac 9f+t+2 lac 9f+t+2
dac .+3 dac .+3
jms copy; dnode; ..; 8 jms copy; inode; ..; 8
lac 9f+t+1 lac 9f+t+1
jms dskwr jms dskwr
jmp dput i jmp dput i
@@ -181,11 +181,11 @@ dput: 0
t = t+3 "** first t not there (hole from hole punch?) t = t+3 "** first t not there (hole from hole punch?)
pget: 0 pget: 0
irss 6 lrss 6
dac 9f+t dac 9f+t
lac i.flags lac i.flags
"** 01-s1.pdf page 36 "** 01-s1.pdf page 37
and o200000 and o200000
sza sza
@@ -193,7 +193,7 @@ pget: 0
lac 9f+t lac 9f+t
jms betwen; d0; d6 jms betwen; d0; d6
jmp 1f jmp 1f
rad idskpp tad idskpp
dac 9f+t dac 9f+t
lac 9f+t i lac 9f+t i
sna sna
@@ -203,8 +203,8 @@ pget: 0
1: 1:
jms alloc jms alloc
dac 9f+t+1 dac 9f+t+1
jms copy; idskps; dskbuf; 7 jms copy; i.dskps; dskbuf; 7
jms copyz; dskbuf+7; 6467 "** NUMBER UNCLEAR 64-7??? jms copyz; dskbuf+7; 64-7 "** NUMBER UNCLEAR
lac 9f+t+1 lac 9f+t+1
jms dskwr jms dskwr
lac 9f+t+1 lac 9f+t+1
@@ -247,8 +247,8 @@ iwrite: 0
"** 01-s1.pdf page 38 "** 01-s1.pdf page 38
dac oread dac iread
lac cslp lac cskp
dac iwrite dac iwrite
jmp 1f jmp 1f
@@ -282,7 +282,7 @@ iread: 0
1: 1:
lac 9f+t lac 9f+t
jms pget jms pget
das 9f+t+3 dac 9f+t+3
jms dskrd jms dskrd
lac 9f+t lac 9f+t
and o77 and o77
@@ -331,7 +331,7 @@ finac: 0
sma sma
jms error jms error
lac f.i lac f.i
jms ihet jms iget
jms finac i jms finac i
dacisize: 0 dacisize: 0
+8 -8
View File
@@ -3,20 +3,20 @@
pibreak: pibreak:
dac .ac "** CROSSED OUT.... dac .ac "** CROSSED OUT....
dpsf lpsf
jmp 1f jmp 1f
dpcf lpcf
dprs dprs "** ??
dac dpstat dac dpstat
sma rad sma ral
jmp 2f jmp 2f
dprc dprc "** ??
dac dpchar dac dpchar
-1 -1
dac dpread dac dpread
lac dpstat lac dpstat
rai ral
2: 2:
sma sma
jmp piret jmp piret
@@ -28,7 +28,7 @@ pibreak:
jmp 1f jmp 1f
lpb lpb
dac pbsfigs dac pbsflgs
isz s.tim+1 isz s.tim+1
skp skp
isz s.tim isz s.tim
@@ -251,7 +251,7 @@ ttyrestart: 0
lpb lpb
dac pbsflgs+1 dac pbsflgs+1
"** 01-s1.pdf page 44 "** 01-s1.pdf page 45
and o2000 and o2000
sna sna
+5 -5
View File
@@ -102,7 +102,7 @@ q2:
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0 .+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
dsploc: .=.+1 dsploc: .=.+1
dspinc: .=.+1 dsplno: .=.+1
dspbuf: dspbuf:
0065057;0147740;0160000 0065057;0147740;0160000
.=.+30 .=.+30
@@ -113,11 +113,11 @@ coldentry:
clon clon
law 3072 law 3072
vcga vcga
jsp dspinit jms dspinit
law dspbuf law dspbuf
jsp movdsp jms movdsp
cla cla
jsp dskio; 06000 jms dskio; 06000
jms copy; dskbuf; sysdata; ulist-sysdata jms copy; dskbuf; sysdata; ulist-sysdata
lac d3 lac d3
jms namei; initf jms namei; initf
@@ -194,7 +194,7 @@ inode:
i.flags: .=.+1 i.flags: .=.+1
i.dskps: .=.+7 i.dskps: .=.+7
i.uid: .=.+1 i.uid: .=.+1
i.lks: .=.+1 i.nlks: .=.+1
i.size: .=.+1 i.size: .=.+1
i.uniq: .=.+1 i.uniq: .=.+1
.= inode+12 .= inode+12
+22
View File
@@ -0,0 +1,22 @@
" For now, this stuff is defined so that
" the assembler doesn't complain about it
.save: 0
alloc: 0
betwen: 0
chkint: 0
copy: 7
copyz: 0
dskio: 0
dskrd: 0
dsktrans: 0
dskwr: 0
error: 0
free: 0
halt: 0
laci: 0
lookfor: 0
o7000: 07000
o70000: 070000
swp: 0
+33 -12
View File
@@ -21,6 +21,8 @@ my $origline; # The current input line of code
my $stage = 1; # Pass one or pass two my $stage = 1; # Pass one or pass two
my $debug = 0; # Run in debug mode my $debug = 0; # Run in debug mode
my $errors = 0; # set to non-zero on error
my %Undef; # undefined symbols: only complain once
### Main program ### ### Main program ###
@@ -87,13 +89,25 @@ for my $i ( 0 .. $#Mem ) {
} }
} }
exit(0); exit($errors);
my $file; # global for error messages
my $lineno;
sub err {
my $msg = shift;
$errors = 1; # exit status
print STDERR "$file:$lineno: $msg\n";
return 0;
}
# Open and parse the given file # Open and parse the given file
sub parse_file { sub parse_file {
my $file = shift; $file = shift;
open( my $IN, "<", $file ) || die("Cannot read $file: $!\n"); open( my $IN, "<", $file ) || die("Cannot read $file: $!\n");
$lineno = 0;
while ( my $line = <$IN> ) { while ( my $line = <$IN> ) {
$lineno++;
# Lose the end of line and any leading/trailing whitespace # Lose the end of line and any leading/trailing whitespace
# Discard any comments and preceding comment whitespace # Discard any comments and preceding comment whitespace
@@ -111,12 +125,12 @@ sub parse_file {
# Split into a section with possible labels and a # Split into a section with possible labels and a
# statement section with definitely no labels. The ? # statement section with definitely no labels. The ?
# makes the first pattern less greedy. # makes the first pattern less greedy.
#print("cmd is >$cmd<\n"); print("cmd is >$cmd<\n");
$cmd =~ m{(.*?)([^:]*$)}; $cmd =~ m{(.*?)([^:]*$)};
my $labelsect = $1; my $labelsect = $1;
my $statement = $2; my $statement = $2;
#print(">$labelsect< >$statement<\n"); #print(">$labelsect< >$statement<\n");
# Split $labelsect into labels using the : character # Split $labelsect into labels using the : character
my @labellist = split( /:\s*/, $labelsect ); my @labellist = split( /:\s*/, $labelsect );
@@ -147,9 +161,9 @@ sub parse_label {
} }
# It's a textual label, check if it's been defined before # It's a textual label, check if it's been defined before
die("Label $label defined multiple times\n") if ( defined( $Label{$label} ) ) {
if ( defined( $Label{$label} ) ); err("Label $label defined multiple times\n") if ( $stage == 1 );
}
# Otherwise, save its value # Otherwise, save its value
$Label{$label} = $Var{'.'}; $Label{$label} = $Var{'.'};
#printf( "Set absolute label %s to 0%o\n", $label, $Label{$label} ); #printf( "Set absolute label %s to 0%o\n", $label, $Label{$label} );
@@ -202,6 +216,7 @@ sub parse_statement {
sub parse_expression { sub parse_expression {
my $expression = shift; my $expression = shift;
print "exp: $expression\n";
# If it's a defined variable ( . , .. , etc.) # If it's a defined variable ( . , .. , etc.)
# return the value # return the value
return ( $Var{$expression} ) return ( $Var{$expression} )
@@ -426,7 +441,11 @@ sub parse_expression {
#print("Did a subtraction and got $diff\n"); #print("Did a subtraction and got $diff\n");
return ($diff); return ($diff);
} }
die("I have no idea what $expression is in pass two\n") if ( $stage == 2 ); if ( $stage == 2 ) {
err("undefined: $expression") unless (defined $Undef{$expression});
$Undef{$expression} = 1;
}
return 0;
} }
# Add two expression together # Add two expression together
@@ -463,18 +482,20 @@ sub find_relative_label {
my $curlocation = $Var{'.'}; my $curlocation = $Var{'.'};
# Error check: no labels at all # Error check: no labels at all
die("No relative labels\n") if ( !defined( $Rlabel{$label} ) ); if ( !defined( $Rlabel{$label} ) ) {
return err("relative label $label not defined\n");
}
# Get the list of possible locations for this label # Get the list of possible locations for this label
my $locarray = $Rlabel{$label}; my $locarray = $Rlabel{$label};
# Error check: no locations # Error check: no locations
die("No relative labels\n") if ( @{$locarray} == 0 ); return err("No relative labels") if ( @{$locarray} == 0 );
# Error check: forward but no next location, or backward but no previous # Error check: forward but no next location, or backward but no previous
die("No forward label\n") return err("No forward label $label")
if ( ( $direction eq 'f' ) && ( $curlocation > $locarray->[-1] ) ); if ( ( $direction eq 'f' ) && ( $curlocation > $locarray->[-1] ) );
die("No backward label\n") return err("No backward label $label")
if ( ( $direction eq 'b' ) && ( $curlocation < $locarray->[0] ) ); if ( ( $direction eq 'b' ) && ( $curlocation < $locarray->[0] ) );
# Search forward for a location larger then the current one # Search forward for a location larger then the current one