Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
$ !
$ ! Compile, link, locate and generate hex files containing
$ ! ASM86 for
$ ! Concurrent CP/M-86: vers IBM PC 1.0
$ ! uses old PL/M-86 compiler
$ !
$ set verify
$ assign 'f$directory()' f1 ! force TMP files to local dir
$ oldplm86 mainp.plm debug optimize(2) 'p1' xref
$ oldplm86 cmac1.plm debug optimize(2) 'p1'
$ oldplm86 cmac2.plm debug optimize(2) 'p1'
$ oldplm86 cmac3.plm debug optimize(2) 'p1'
$ oldplm86 cmac4.plm debug optimize(2) 'p1'
$ oldplm86 cmac5.plm debug optimize(2) 'p1'
$ oldplm86 mnem1.plm debug optimize(2) 'p1'
$ oldplm86 mnem2.plm debug optimize(2) 'p1'
$ oldplm86 mnem3.plm debug optimize(2) 'p1'
$ oldplm86 mnem4.plm debug optimize(2) 'p1'
$ oldplm86 symb.plm debug optimize(2) 'p1' xref
$ oldplm86 io.plm debug optimize(2) 'p1' xref
$ oldplm86 subr1.plm debug optimize(2) 'p1' xref
$ oldplm86 subr2.plm debug optimize(2) 'p1' xref
$ oldplm86 files.plm debug optimize(2) 'p1' xref
$ oldplm86 scan.plm debug optimize(2) 'p1' xref
$ oldplm86 print.plm debug optimize(2) 'p1' xref
$ oldplm86 predef.plm debug optimize(2) 'p1' xref
$ oldplm86 ermod.plm debug optimize(2) 'p1' xref
$ oldplm86 text.plm debug optimize(2) 'p1' xref
$ oldplm86 outp.plm debug optimize(2) 'p1' xref
$ oldplm86 expr.plm debug optimize(2) 'p1' xref
$ oldplm86 brexpr.plm debug optimize(2) 'p1' xref
$ oldplm86 pseud1.plm debug optimize(2) 'p1' xref
$ oldplm86 pseud2.plm debug optimize(2) 'p1' xref
$ oldplm86 cmsubr.plm debug optimize(2) 'p1' xref
$ oldplm86 instr.plm debug optimize(2) 'p1' xref
$ oldplm86 dline.plm debug optimize(2) 'p1' xref
$ oldplm86 global.plm debug optimize(2) 'p1' xref
$ oldplm86 cm.plm debug optimize(2) 'p1' xref
$ oldplm86 cm2.plm debug optimize(2) 'p1' xref
$ oldasm86 c86lnk.asm debug
$ oldlink86 cmac1.obj,cmac2.obj,cmac3.obj,cmac4.obj,cmac5.obj to f11.mod
$ oldlink86 mnem1.obj,mnem2.obj,mnem3.obj,mnem4.obj,symb.obj to f12.mod
$ oldlink86 io.obj,subr1.obj,subr2.obj,files.obj,scan.obj to f13.mod
$ oldlink86 print.obj,predef.obj,ermod.obj,text.obj,outp.obj to f14.mod
$ oldlink86 expr.obj,brexpr.obj,pseud1.obj,pseud2.obj,cmsubr.obj to f15.mod
$ oldlink86 instr.obj,dline.obj,global.obj,cm.obj,cm2.obj to f16.mod
$ oldlink86 f11.mod,f12.mod,f13.mod to f21.mod
$ oldlink86 f14.mod,f15.mod,f16.mod to f22.mod
$ oldlink86 c86lnk.obj,mainp.obj,f21.mod,f22.mod to asm86.mod
$ oldloc86 asm86.mod nopublics ad(sm(code(0))) od(sm(code,const,stack))
$ oldh86 asm86
$ assign [ccpmpc.vax.common] f1
$ ren asm86.mp1 asm86.111
$ del *.mp1;*
$ ren asm86.111 asm86.mp1
$ pclean
! on micro under cp/m or mp/m
!
! determine BBB and MMM from asm86.mp2 file
! BBB = start of const segment / 16
! MMM = (start of memory segment - start of const segment)/ 16 + 100h
! (4K for sysmbol table)
!
! gencmd asm86 data[bBBB,mMMM,xfff]
! which turns out to be:
! gencmd asm86 data[4ad, m44e, xfff]


View File

@@ -0,0 +1,56 @@
$ set def [frank.mpm86.asm86]
$ plm86 mainp.plm debug optimize(2) 'p1' xref
$ plm86 cmac1.plm debug optimize(2) 'p1'
$ plm86 cmac2.plm debug optimize(2) 'p1'
$ plm86 cmac3.plm debug optimize(2) 'p1'
$ plm86 cmac4.plm debug optimize(2) 'p1'
$ plm86 cmac5.plm debug optimize(2) 'p1'
$ plm86 mnem1.plm debug optimize(2) 'p1'
$ plm86 mnem2.plm debug optimize(2) 'p1'
$ plm86 mnem3.plm debug optimize(2) 'p1'
$ plm86 mnem4.plm debug optimize(2) 'p1'
$ plm86 symb.plm debug optimize(2) 'p1' xref
$ plm86 io.plm debug optimize(2) 'p1' xref
$ plm86 subr1.plm debug optimize(2) 'p1' xref
$ plm86 subr2.plm debug optimize(2) 'p1' xref
$ plm86 files.plm debug optimize(2) 'p1' xref
$ plm86 scan.plm debug optimize(2) 'p1' xref
$ plm86 print.plm debug optimize(2) 'p1' xref
$ plm86 predef.plm debug optimize(2) 'p1' xref
$ plm86 ermod.plm debug optimize(2) 'p1' xref
$ plm86 text.plm debug optimize(2) 'p1' xref
$ plm86 outp.plm debug optimize(2) 'p1' xref
$ plm86 expr.plm debug optimize(2) 'p1' xref
$ plm86 brexpr.plm debug optimize(2) 'p1' xref
$ plm86 pseud1.plm debug optimize(2) 'p1' xref
$ plm86 pseud2.plm debug optimize(2) 'p1' xref
$ plm86 cmsubr.plm debug optimize(2) 'p1' xref
$ plm86 instr.plm debug optimize(2) 'p1' xref
$ plm86 dline.plm debug optimize(2) 'p1' xref
$ plm86 global.plm debug optimize(2) 'p1' xref
$ plm86 cm.plm debug optimize(2) 'p1' xref
$ plm86 cm2.plm debug optimize(2) 'p1' xref
$ asm86 c86lnk.asm debug
$ link86 cmac1.obj,cmac2.obj,cmac3.obj,cmac4.obj,cmac5.obj to f11.mod
$ link86 mnem1.obj,mnem2.obj,mnem3.obj,mnem4.obj,symb.obj to f12.mod
$ link86 io.obj,subr1.obj,subr2.obj,files.obj,scan.obj to f13.mod
$ link86 print.obj,predef.obj,ermod.obj,text.obj,outp.obj to f14.mod
$ link86 expr.obj,brexpr.obj,pseud1.obj,pseud2.obj,cmsubr.obj to f15.mod
$ link86 instr.obj,dline.obj,global.obj,cm.obj,cm2.obj to f16.mod
$ link86 f11.mod,f12.mod,f13.mod to f21.mod
$ link86 f14.mod,f15.mod,f16.mod to f22.mod
$ link86 c86lnk.obj,mainp.obj,f21.mod,f22.mod,plm86.lib to asm86.mod
$ loc86 asm86.mod nopublics ad(sm(code(0))) od(sm(code,const,stack))
$ h86 asm86
! on micro under cp/m or mp/m
!
! determine BBB and MMM from asm86.mp2 file
! BBB = start of const segment / 16
! MMM = (start of memory segment - start of const segment)/ 16 + 100h
! (4K for sysmbol table)
!
! gencmd asm86 data[bBBB,mMMM,xfff]
! which turns out to be:
! gencmd asm86 data[4ad, m44e, xfff]


View File

@@ -0,0 +1,20 @@
/*********** "BNF"-expression syntax ************/
/*
E::= E xor A !! E or A !! A
A::= A and N !! N
N::= not N !! R
R::= P eq P !! P lt P !! P le P !! P gt P !! P ge P !! P ne P !! P
P::= P + T !! P - T !! T
T::= T * M !! T / M !! T mod M !! T shl M !! T shr M !! M
M::= - M !! + M !! S
S::= <over>: F !! F
F::= F ptr B !! seg B !! offset B !! type B !!
length B !! last B !! B
B::= ( E ) !! [ bracket-expression ] !! I
I::= varaible !! . number !! number !! label !! string
<over>::= segment register
(stringlength < 3)
*/


View File

@@ -0,0 +1,6 @@
--3 X[zP
&6Si COPYRIGHT (C) DIGITAL RESEARCH, 1981 10/01/81 XZYPM`C-z.<6l{<6lhA8BPh h[vPPXs
8bPhuhbh h&F2 21~@"21<4 CQc'khkh$kh'k\afhhE v3vPPXs,hqPXs FvF21kdFy3h_?0PhhPhkK
217Qc'Hhdkhkkhwky9>CEhI{tUlh*hkhthY]CUlhhr
h]CUlhevPPXr-h'8V


View File

@@ -0,0 +1,69 @@
$title ('BRACKET EXPRESSION')
brexpr:
/*
modified 4/13/81 R. Silberstein
*/
do;
$include (:f1:macro.lit)
$include (:f1:brexpr.x86)
$include (:f1:ermod.ext)
$include (:f1:exglob.ext)
$eject
/* compute index expression within brackets */
bracketexpr: proc(pt) byte public;
dcl pt address,oper based pt operandstruc,
(firsttype,firstreg,lasttype,lastreg) byte,
baseregi lit '0',indexregi lit'1';
regtyp: proc(pt1,pt2) byte;
dcl (pt1,pt2) address,(typ based pt1,regi based pt2) byte;
if (token.type=reg) and (token.descr=wrd) then$do
typ=baseregi;
regi=token.value;
if (regi=rbp) or (regi=rbx) then return true;
typ=indexregi;
if (regi=rsi) or (regi=rdi) then return true;
end$if;
return false;
end regtyp;
setoperflags: proc (pt1,pt2);
dcl (pt1,pt2) address,(typ based pt1,regi based pt2) byte;
if typ=indexregi then$do
oper.sflag=oper.sflag or iregbit;
IF REGI = RDI THEN OPER.BASEINDEX = OPER.BASEINDEX OR INDEXREGBIT;
else$do
oper.sflag=oper.sflag or bregbit;
IF REGI = RBP THEN OPER.BASEINDEX = OPER.BASEINDEX OR BASEREGBIT;
end$if;
end setoperflags;
if not regtyp(.firsttype,.firstreg) then return false;
call setoperflags(.firsttype,.firstreg);
call scan;
if specialtoken('+') then$do
call scan;
if not regtyp(.lasttype,.lastreg) then return false;
if firsttype=lasttype then return false;
call setoperflags(.lasttype,.lastreg);
call scan;
end$if;
if not specialtoken(rightbracket) then return false;
call scan;
if (oper.sflag and segmbit) = 0 then$do
if oper.stype=number then$do
oper.baseindex=oper.baseindex or nooverridebit;
end$if;
end$if;
oper.stype=variable;
return true;
end bracketexpr;
end$module brexpr;


View File

@@ -0,0 +1,125 @@
$nolist
/*
modified 4/13/81 R. Silberstein
*/
/* Symbol types : */
dcl
reg lit '0', /* register */
pseudo lit '1', /* pseudo instruction */
code lit '2', /* instruction */
string lit '3', /* character string */
spec lit '4', /* special character */
number lit '5', /* 8 or 16 bit number */
variable lit '6',
lab lit '7', /* label */
operator lit '8', /* operator in expressions */
doubledefined lit '0f9h', /* doubled defined symbol */
neglected lit '0fah', /* neglected symb.,never to be def. */
ident lit '0fbh', /* identificator, scanner output */
udefsymb lit '0fdh', /* undefined symbol */
symbol lit '0feh', /* variable,label or undef. symb. */
deletedsymb lit '0ffh'; /* deleted symbol (not used */
/* Symbol description values */
dcl
nil lit '0', /* no specification */
byt lit '1', /* symbol is 8-bit type */
wrd lit '2', /* symbol is 16 bit type */
dwrd lit '4'; /* symbol is 2*16 bit type
or a segment register */
/* Register values : */
dcl
rbx lit '3',
rbp lit '5',
rsi lit '6',
rdi lit '7',
res lit '0', /* segment registers */
rcs lit '1',
rss lit '2',
rds lit '3';
/* Symbolic operators */
dcl
oshort lit '0', /* 8-bit value of expression */
oor lit '1', /* logical OR */
oxor lit '2', /* logical XOR */
oand lit '3', /* logical AND */
onot lit '4', /* logical NOT */
oeq lit '5', /* equal */
ogt lit '6', /* greater */
oge lit '7', /* greater or equal */
olt lit '8', /* less */
ole lit '9', /* less or equal */
one lit '10', /* not equal */
omod lit '11', /* arithmetic MOD */
oshl lit '12', /* shift left */
oshr lit '13', /* shift rigth */
optr lit '14', /* take type of 1. op, value of 2. */
ooffset lit '15', /* offset value of operand */
oseg lit '16', /* segment value of operand */
otype lit '17', /* type value of operand */
olength lit '18', /* length attribute of variables */
olast lit '19', /* length - 1 */
leftbracket lit '''[''',
rightbracket lit ''']''';
dcl
operandstruc lit 'struc(
length addr,
stype byte,
sflag byte,
segment addr,
offset addr,
baseindex byte)',
/* define bits of SFLAG of structures above */
type$bit lit '7h', /* bit 0-2 */
segtypebit lit '18h', /* bit 3-4 */
segmbit lit '20h', /* bit 5 */
iregbit lit '40h', /* bit 6 */
bregbit lit '80h', /* bit 7 */
/* left-shift counters */
typecount lit '0',
segtypecount lit '3',
segmcount lit '5',
iregcount lit '6',
bregcount lit '7',
/* define bits of BASEINDEX byte of structures above */
indexregbit lit '01h', /* bit 0 */
baseregbit lit '02h', /* bit 1 */
nooverridebit lit '40h', /* bit 6 */
/* left shift counters */
indexregcount lit '0',
baseregcount lit '1',
noovercount lit '6';
scan: proc external;
end scan;
specialtoken: proc (tok) byte external;
dcl tok byte;
end specialtoken;
$list


View File

@@ -0,0 +1,78 @@
;
extrn asm86:near
cgroup group code
dgroup group const,data,stack,memory
assume cs:cgroup,ds:dgroup
data segment public 'DATA'
data ends
;
stack segment word stack 'STACK'
stack_base label byte
stack ends
;
memory segment memory 'MEMORY'
memory ends
const segment public 'CONST'
public fcb,fcb16,tbuff,endbuf
org 6
endbuf equ $
org 5ch
fcb equ $
org 6ch
fcb16 equ $
org 80h
tbuff equ $
org 100h
const ends
code segment public 'CODE'
public mon1,mon2
start: mov ax,ds
pushf
pop bx
cli
mov ss,ax
lea sp,stack_base
push bx
popf
jmp asm86
copyright db ' COPYRIGHT (C) DIGITAL RESEARCH, 1981 '
public patch
patch:
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
db 90h,90h,90h,90h,90h,90h,90h,90h
date db ' 10/01/81 '
bdos:
pop ax ; return address
pop dx
pop cx
push ax
int 224
ret
mon1 equ bdos
mon2 equ bdos
code ends
end


View File

@@ -0,0 +1,37 @@
$nolist
codemacro$rout: PROC external;
end$proc codemacro$rout;
db$cm$rout: PROC external;
end$proc db$cm$rout;
dw$cm$rout: PROC external;
end$proc dw$cm$rout;
dd$cm$rout: PROC external;
end$proc dd$cm$rout;
segfix$cm$rout: PROC external;
end$proc segfix$cm$rout;
nosegfix$cm$rout: PROC external;
end$proc nosegfix$cm$rout;
modrm$cm$rout: PROC external;
end$proc modrm$cm$rout;
relb$cm$rout: PROC external;
end$proc relb$cm$rout;
relw$cm$rout: PROC external;
end$proc relw$cm$rout;
dbit$cm$rout: PROC external;
end$proc dbit$cm$rout;
end$cm$rout: PROC external;
end$proc end$cm$rout;
$list


View File

@@ -0,0 +1,16 @@
$nolist
/* D E C L A R A T I O N F O R "C O D E M A C R O" P A R T
Extended version of ASM86 */
dcl comma lit ''',''',
colon lit ''':''',
first lit '0',
second lit '1',
leftpar lit '''(''',
rightpar lit ''')''';
$list


View File

@@ -0,0 +1,351 @@
$title ('codemacro module 1')
cm1:
do;
/*
modified 7/24/81 R. Silberstein
*/
/* This is the module to build new instructions
which is not present in the already existing
system. */
$include (:f1:macro.lit)
$include (:f1:equals.lit)
$include (:f1:struc.lit)
$include (:f1:cmacd.lit)
$include (:f1:ermod.lit)
$include (:f1:scan.ext)
$include (:f1:ermod.ext)
$include (:f1:cm2.ext)
$include (:f1:cm.lit)
$include (:f1:global.ext)
$eject
/* Subroutines: */
more$left$on$line: PROC byte;
if accum(0) <> cr then return true;
else return false;
end$proc more$left$on$line;
modrm$rout: PROC;
dcl nopar byte;
if token.type = number then$do
call put$b(mmodrm1);
if token.value > 7 then$do
cm$error=true; /* legal values are 0,1,.. .,7 */
return;
else$do
call put$b(token.value);
end$if;
else$do
if token.type = ident then$do
if legal$parameter(acclen,.accum(0),.nopar) then$do
call put$b(mmodrm2);
call put$b(nopar);
else$do /* error, parameter mismatch */
cm$error=true;
return;
end$if;
else$do /* error, expected parameter */
cm$error=true;
return;
end$if;
end$if;
call scan;
if accum(0) <> comma then$do
/* error, expected comma */
cm$error=true;
return;
end$if;
call scan;
if token.type = ident then$do
if legal$parameter(acclen,.accum(0),.nopar) then$do
call put$b(nopar);
call scan;
return;
else$do /* error, parameter mismatch */
cm$error=true;
return;
end$if;
else$do /* error, expected parameter */
cm$error=true;
return;
end$if;
end$proc modrm$rout;
db$dw$common$rout: PROC(directive);
dcl (directive,nopar) byte;
if token.type = number then$do
call put$b(directive);
if directive = mdwn then$do
call put$w(token.value);
else$do
if token.value > 0ffh then cm$error=true;
else call put$b(token.value);
end$if;
call scan;
return;
else$do
if token.type = ident then$do
if legal$parameter(acclen,.accum(0),.nopar) then$do
call put$b(directive+1);
call put$b(nopar);
call scan;
return;
else$do /* error, parameter mismatch */
cm$error=true;
return;
end$if;
else$do /* error, expected parameter */
cm$error=true;
return;
end$if;
end$if;
end$proc db$dw$common$rout;
d$s$rb$rw$rout: PROC(directive);
dcl (directive,nopar) byte;
if token.type = ident then$do
if legal$parameter(acclen,.accum(0),.nopar) then$do
call put$b(directive);
call put$b(nopar);
call scan;
return;
else$do /* error, parameter mismatch */
cm$error=true;
return;
end$if;
else$do /* error, expected parameter */
cm$error=true;
return;
end$if;
end$proc d$s$rb$rw$rout;
nosegfix$rout: PROC;
dcl nopar byte;
call put$b(mnosegfix);
do case legal$seg$reg;
do; /* error, no segment register specified */
cm$error=true;
return;
end;
call put$b(res);
call put$b(rcs);
call put$b(rss);
call put$b(rds);
end$case;
call scan;
if accum(0) <> comma then$do
/* error, expected comma */
cm$error=true;
return;
end$if;
call scan; /* skip comma */
if legal$parameter(acclen,.accum(0),.nopar) then$do
call put$b(nopar);
call scan;
else$do
cm$error=true;
return;
end$if;
end$proc nosegfix$rout;
dbit$rout: PROC;
call put$b(mdbit);
end$proc dbit$rout;
field$descr$rout: PROC;
dcl nopar byte,cm$b$var based cmpt byte;
do forever;
if token.type <> number or token.value > 0fh then$do
/* error, expected numberdef. */
cm$error=true;
return;
end$if;
call put$b(mnumberbits);
call put$b(token.value);
call scan;
if accum(0) <> leftpar then$do
/* error, expected left paranthesis */
cm$error=true;
return;
end$if;
call scan; /* skip left paranthesis */
if token.type = ident then$do
if not legal$parameter(acclen,.accum(0),.nopar) then$do
/* error, parameter mismatch */
cm$error=true;
return;
end$if;
cmpt=cmpt-2;
cm$b$var=cm$b$var-1; /* it was a parameter, not a number */
cmpt=cmpt+2;
call put$b(nopar);
call scan;
if accum(0) <> leftpar then$do
/* error, expected left paranthesis */
cm$error=true;
return;
end$if;
call scan; /* skip left paranthesis */
end$if;
if token.type <> number or token.value > 0ffh then$do
/* error, expected numberdef.(byte) or parameter */
cm$error=true;
return;
end$if;
call put$b(token.value);
call scan;
if accum(0) <> rightpar then$do
/* error,expected right paranthesis */
cm$error=true;
return;
end$if;
call scan; /* skip right paranthesis */
cmpt=cmpt-4;
if cm$b$var = mformalbits and
accum(0) = rightpar then call scan;
cmpt=cmpt+4;
if accum(0) <> comma then return;
call scan;
end$forever;
end$proc field$descr$rout;
enddbit$rout: PROC;
call put$b(mendbit);
end$proc enddbit$rout;
endm$rout: PROC;
call put$b(mendm);
end$proc endm$rout;
$eject
/* level 1 in the syntax-tree of codemacrobuilding */
COMMON$CM$ROUT: PROC (TYPE);
DECLARE TYPE BYTE;
if pass = 1 then$do
call skip$rest$of$line;
return;
end$if;
cm$error=false;
if not codemacro$flag then$do
/* error, codemacro directive outside codemacrobodydef. */
cm$error=true;
end$if;
DO CASE TYPE;
call db$dw$common$rout(mdbn);
call db$dw$common$rout(mdwn);
call d$s$rb$rw$rout(mddf);
call d$s$rb$rw$rout(msegfix);
call nosegfix$rout;
call modrm$rout;
call d$s$rb$rw$rout(mrelb);
call d$s$rb$rw$rout(mrelw);
DO;
call dbit$rout;
call field$descr$rout;
call enddbit$rout;
END;
END$CASE;
if cm$error or more$left$on$line then$do
/* error */
global$cm$error=true;
call errmsg(codemacroerr);
end$if;
call skip$rest$of$line;
END COMMON$CM$ROUT;
codemacro$rout: PROC public;
if pass = 1 then$do
codemacro$flag=true;
call skip$rest$of$line;
return;
end$if;
cm$error=false;
global$cm$error=false;
if codemacro$flag then$do
/* error, nested codemacrodefinition */
cm$error=true;
end$if;
call init$cm$rout; /* clearing all temp. working storages */
codemacro$flag=true;
if not name$rout then$do
/* error, expected codemacroname */
cm$error=true;
end$if;
call formal$list$rout;
if cm$error or more$left$on$line$ then$do
/* error */
global$cm$error=true;
call errmsg(codemacroerr);
end$if;
call skip$rest$of$line;
end$proc codemacro$rout;
db$cm$rout: PROC public;
CALL COMMON$CM$ROUT (0);
end$proc db$cm$rout;
dw$cm$rout: PROC public;
CALL COMMON$CM$ROUT (1);
end$proc dw$cm$rout;
dd$cm$rout: PROC public;
CALL COMMON$CM$ROUT (2);
end$proc dd$cm$rout;
segfix$cm$rout: PROC public;
CALL COMMON$CM$ROUT (3);
end$proc segfix$cm$rout;
nosegfix$cm$rout: PROC public;
CALL COMMON$CM$ROUT (4);
end$proc nosegfix$cm$rout;
modrm$cm$rout: PROC public;
CALL COMMON$CM$ROUT (5);
end$proc modrm$cm$rout;
relb$cm$rout: PROC public;
CALL COMMON$CM$ROUT (6);
end$proc relb$cm$rout;
relw$cm$rout: PROC public;
CALL COMMON$CM$ROUT (7);
end$proc relw$cm$rout;
dbit$cm$rout: PROC public;
CALL COMMON$CM$ROUT (8);
end$proc dbit$cm$rout;
end$cm$rout: PROC public;
if pass = 1 then$do
call skip$rest$of$line;
codemacro$flag=false;
return;
end$if;
cm$error=false;
if not codemacro$flag then$do
/* error, terminating a not yet started codemacro */
cm$error=true;
end$if;
call endm$rout;
if pass = 0 then call terminate$cm$rout;
if cm$error or more$left$on$line or cm$list$overflow then$do
/* error */
call errmsg(codemacroerr);
end$if;
call skip$rest$of$line;
global$cm$error=false;
codemacro$flag=false;
end$proc end$cm$rout;
end$module cm1;


View File

@@ -0,0 +1,47 @@
$nolist
/* D E C L A R A T I O N F O R "C O D E M A C R O" P A R T
Extended version of ASM86 */
dcl cm$error byte external,
global$cm$error byte external,
cm$list$overflow byte external,
cmpt address external;
/* level 2 in the syntax-tree of codemacro building */
/* Procedure to initialize temporary storage and pointers
conserning the building of codemacro */
init$cm$rout: PROC external;
end$proc init$cm$rout;
name$rout: PROC byte external;
end$proc name$rout;
formal$list$rout: PROC external;
end$proc formal$list$rout;
terminate$cm$rout: PROC external;
end$proc terminate$cm$rout;
legal$parameter: PROC(lg,ptr,ptr2) byte external;
dcl lg byte,
(ptr,ptr2) address;
end$proc legal$parameter;
legal$seg$reg: PROC byte external;
end$proc legal$seg$reg;
put$b: PROC(b) external;
dcl b byte;
end$proc put$b;
put$w: PROC(w) external;
dcl w address;
end$proc put$w;
$list


View File

@@ -0,0 +1,344 @@
$title ('codemacro module 2')
cm2:
do;
/*
modified 3/26/81 R. Silberstein
*/
/* This is the module to build new instructions
which is not present in the already existing
system. */
$include (:f1:macro.lit)
$include (:f1:equals.lit)
$include (:f1:struc.lit)
$include (:f1:cmacd.lit)
$include (:f1:cm.lit)
$include (:f1:symb.ext)
$include (:f1:subr1.ext)
$include (:f1:subr2.ext)
$include (:f1:scan.ext)
$include (:f1:files.ext)
$include (:f1:exglob.ext)
$eject
/* D E C L A R A T I O N F O R "C O D E M A C R O" P A R T
Extended version of ASM86 */
dcl cm$name(80) byte ,
codemacro$found byte ,
cm$n$pt address ,
cm$n$var based cm$n$pt byte,
cm$n$lg byte ,
par$name(80) byte ,
pmpt address ,
cm$pm$var based pmpt byte,
cm$error byte public ,
cm$body(100) byte ,
cmpt address public ,
cm$b$var based cmpt byte,
cm$w$var based cmpt addr,
cm$counter addr ,
global$cm$error byte public ,
cm$body$full byte ,
ant$par byte ,
cm$list$overflow byte public;
$eject
/* VARIOUS SUBROUTINES */
legal$parameter: PROC(lg,ptr,ptr2) byte public;
dcl (lg,i) byte,
(ptr,ptr2) address,
no based ptr2 byte;
i=0;
do no=0 to cm$body(2)-1;
if parname(i+lg) = 0 and
equal(lg,ptr,.par$name(i)) then return true;
do while par$name(i:=i+1) <> 0;
end$while;
i=i+1;
end;
return false;
end$proc legal$parameter;
legal$spec$letter: PROC(l) byte;
dcl (l,i) byte;
dcl table(8) byte data ('ACDEMRSX');
do i=0 to last(table);
if table(i) = l then return i;
end;
return i;
end$proc legal$spec$letter;
legal$mod$letter: PROC(l) byte;
dcl (l,i) byte;
dcl table(4) byte data ('BWDS');
do i=0 to last(table);
if table(i) = l and i < 3 then return i;
if table(i) = l and i = 3 then$do
if accum(2) = 'B' then return 3;
end$if;
end;
return i;
end$proc legal$mod$letter;
legal$register: PROC byte;
declare disp byte;
if token.type <> reg then return 0;
disp=0;
if token.descr=byt then disp=8;
if token.descr=dwrd then disp=16;
return token.value + disp + 1;
end$proc legal$register;
legal$seg$reg: PROC byte public;
if token.type <> reg then return 0;
if token.descr <> dwrd then return 0;
return token.value + 1;
end$proc legal$seg$reg;
put$b: PROC(b) public;
dcl b byte;
cm$counter=cm$counter+1;
if cm$counter > 99 then$do
cm$error=true;
cm$body$full=true;
return;
end$if;
cm$b$var=b;
cmpt=cmpt+1;
end$proc put$b;
put$w: PROC(w) public;
dcl w addr;
cm$counter=cm$counter+2;
if cm$counter > 99 then$do
cm$error=true;
cm$body$full=true;
return;
end$if;
cm$w$var=w;
cmpt=cmpt+2;
end$proc put$w;
update$cm$lists: PROC byte;
dcl listptr address,next based listptr address;
dcl ptr address;
ptr=.listptr;
if findcodemacro(cm$n$lg,.cm$name(0),ptr)
then$do
do while next <> 0;
listptr=next;
end$while;
else$do
if not new$cm$name(cm$n$lg,.cm$name(0),ptr)
then return false;
end$if;
next=freept;
if not new$cm$body(cm$counter,.cm$body(0))
then return false;
return true;
end$proc update$cm$lists;
$eject
/* level 4 in the syntax-tree of coeemacro building */
register$rout: PROC (l);
dcl l byte;
call put$b(l);
end$proc register$rout;
range$rout: PROC;
put$range: PROC(time);
dcl time byte;
if token.type = number then$do
if time = first then$do
cm$b$var=cm$b$var+numberrange;
cmpt=cmpt+1;
end$if;
if token.value > 0ffh then$do
cm$error=true; /* too large number */
return;
else$do
call put$b(token.value);
end$if;
else$do
if time = first then$do
cm$b$var=cm$b$var+registerrange;
cmpt=cmpt+1;
end$if;
do case legal$register;
do; /* error, expecting a register spec. */
cm$error=true;
return;
end;
call register$rout(rax);
call register$rout(rcx);
call register$rout(rdx);
call register$rout(rbx);
call register$rout(rsp);
call register$rout(rbp);
call register$rout(rsi);
call register$rout(rdi);
call register$rout(ral);
call register$rout(rcl);
call register$rout(rdl);
call register$rout(rbl);
call register$rout(rah);
call register$rout(rch);
call register$rout(rdh);
call register$rout(rbh);
call register$rout(res);
call register$rout(rcs);
call register$rout(rss);
call register$rout(rds);
end$case;
end$if;
call scan;
end$proc put$range;
s$range: PROC;
cmpt=cmpt-1;
cm$b$var=cm$b$var+singlerange;
call put$range(first);
end$proc s$range;
d$range: PROC;
cmpt=cmpt-1;
cm$b$var=cm$b$var+doublerange;
call put$range(first);
if accum(0) <> comma then$do
cm$error=true;
return;
end$if;
call scan;
call put$range(second);
if accum(0) <> rightpar then$do
cm$error=true;
return;
end$if;
end$proc d$range;
/* mainpart of range routine */
call scan; /* skip left paranthesis */
if nextch = comma then call d$range;
else call s$range;
call scan;
end$proc range$rout;
spec$letter$rout: PROC(l);
dcl l byte;
call put$b(l);
end$proc spec$letter$rout;
mod$letter$rout: PROC(l);
dcl l byte;
call put$b(l);
end$proc mod$letter$rout;
$eject
/* level 3 in the syntax-tree of codemacro building */
par$descr$rout: PROC;
call copy(acclen,.accum(0),.cm$pm$var);
pmpt=pmpt+acclen;
cm$pm$var=0; /* end of par.name */
pmpt=pmpt+1;
call scan;
if accum(0) <> colon then$do
/* error, expected colon in parameterdecl */
cm$error=true;
end$if;
call scan;
do case legal$spec$letter(accum(0));
call spec$letter$rout(speca);
call spec$letter$rout(specc);
call spec$letter$rout(specd);
call spec$letter$rout(spece);
call spec$letter$rout(specm);
call spec$letter$rout(specr);
call spec$letter$rout(specs);
call spec$letter$rout(specx);
do; /* error, expected specifier letter */
cm$error=true;
return;
end;
end$case;
do case legal$mod$letter(accum(1));
call mod$letter$rout(modb);
call mod$letter$rout(modw);
call mod$letter$rout(modd);
call mod$letter$rout(modsb);
call mod$letter$rout(nomod); /* no modletter */
end$case;
call scan;
if accum(0) = leftpar then call range$rout;
cm$body(2)=cm$body(2)+1;
end$proc par$descr$rout;
$eject
/* level 2 in the syntax-tree of codemacro building */
/* Procedure to initialize temporary storage and pointers
conserning the building of codemacro */
init$cm$rout: PROC public;
cm$n$pt=.cm$name(0);
cmpt=.cm$body(0)+3; /* correcting for the head */
pmpt=.par$name(0);
CALL FILL (0, LENGTH (CM$NAME), .CM$NAME);
CALL FILL (0, LENGTH (CM$BODY), .CM$BODY);
CALL FILL (0, LENGTH (PAR$NAME), .PAR$NAME);
ant$par=0;
cm$counter=3;
cm$body$full=false;
cm$list$overflow=false;
end$proc init$cm$rout;
name$rout: PROC byte public;
if token.type <> ident then return false;
call copy(acclen,.accum(0),.cm$name(0));
cm$n$lg=acclen;
call scan;
return true;
end$proc name$rout;
formal$list$rout: PROC public;
do while token.type = ident;
call par$descr$rout;
if accum(0) <> ',' then return; /* end of parameters */
call scan;
end$while;
end$proc formal$list$rout;
terminate$cm$rout: PROC public;
if global$cm$error then$do
/* error present in codemacrodef, */
/* no updating of codemacrolist */
return;
end$if;
if not update$cm$lists
then$do
cm$error=true; /* overflow, no more vacant memory */
cm$list$overflow=true;
return;
end$if;
end$proc terminate$cm$rout;
end$module cm2;


View File

@@ -0,0 +1,44 @@
$nolist
/* Literals used in codemacro specification : */
dcl
divisor lit '0',
mplier lit '0',
place lit '0',
itype lit '0',
si$ptr lit '0',
di$ptr lit '1',
port lit '1',
adr lit '0',
dst lit '0',
src lit '1',
opcode lit '0';
/* Literals to simplify table punching: */
dcl
cmachead lit 'struc (next address,nopar byte',
cmac2struc lit 'cmachead,body(2) byte)',
cmac3struc lit 'cmachead,body(3) byte)',
cmac4struc lit 'cmachead,body(4) byte)',
cmac5struc lit 'cmachead,body(5) byte)',
cmac6struc lit 'cmachead,body(6) byte)',
cmac7struc lit 'cmachead,body(7) byte)',
cmac8struc lit 'cmachead,body(8) byte)',
cmac9struc lit 'cmachead,body(9) byte)',
cmac10struc lit 'cmachead,body(10) byte)',
cmac11struc lit 'cmachead,body(11) byte)',
cmac12struc lit 'cmachead,body(12) byte)',
cmac13struc lit 'cmachead,body(13) byte)',
cmac14struc lit 'cmachead,body(14) byte)',
cmac15struc lit 'cmachead,body(15) byte)',
cmac16struc lit 'cmachead,body(16) byte)',
cmac17struc lit 'cmachead,body(17) byte)',
cmac18struc lit 'cmachead,body(18) byte)',
cmac19struc lit 'cmachead,body(19) byte)',
cmac20struc lit 'cmachead,body(20) byte)',
cmac21struc lit 'cmachead,body(21) byte)';
$list


View File

@@ -0,0 +1,524 @@
$title ('CODEMACRO DEFINITIONS - PART 1')
cmac1:
do;
$include (:f1:macro.lit)
$include (:f1:cmacd.lit)
$include (:f1:equals.lit)
$include (:f1:cmac.lit)
/* Code-macro table: */
dcl
/* AAA */
aaa1 cmac3struc public data(
nil,0,
mdbn,37h, /* DB 37H */
mendm), /* ENDM */
/* AAD */
aad1 cmac4struc public data(
nil,0,
mdwn,0d5h,0ah, /* DW 0AD5H */
mendm), /* ENDM */
/* AAM */
aam1 cmac4struc public data(
nil,0,
mdwn,0d4h,0ah, /* DW 0AD4H */
mendm), /* ENDM */
/* AAS */
aas1 cmac3struc public data(
nil,0,
mdbn,3fh, /* DB 3FH */
mendm), /* ENDM */
/* ADC dst:Eb,src:Db */
adc1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,2,dst, /* MODRM 2,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* ADC dst:Ew,src:Db */
adc2 cmac14struc data(
.adc1,2,
specE,modw,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,2,dst, /* MODRM 2,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADC dst:Ew,src:Dsb */
adc3 cmac14struc data(
.adc2,2,
specE,modw,
specD,modsb,
msegfix,dst, /* SEGFIX dst */
mdbn,83h, /* DB 83H */
mmodrm1,2,dst, /* MODRM 2,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* ADC dst:Ew,src:Dw */
adc4 cmac14struc data(
.adc3,2,
specE,modw,
specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,2,dst, /* MODRM 2,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADC dst:Ab,src:Db */
adc5 cmac9struc data(
.adc4,2,
specA,modb,
specD,modb,
mdbn,14h, /* DB 14H */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* ADC dst:Aw,src:Db */
adc6 cmac9struc data(
.adc5,2,
specA,modw,
specD,modb,
mdbn,15h, /* DB 15H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADC dst:Aw,src:Dw */
adc7 cmac9struc data(
.adc6,2,
specA,modw,
specD,modw,
mdbn,15h, /* DB 15H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADC dst:Eb,src:Rb */
adc8 cmac12struc data(
.adc7,2,
specE,modb,
specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,10h, /* DB 10H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* ADC dst:Ew,src:Rw */
adc9 cmac12struc data(
.adc8,2,
specE,modw,
specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,11h, /* DB 11H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* ADC dst:Rb,src:Eb */
adc10 cmac12struc data(
.adc9,2,
specR,modb,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,12h, /* DB 12H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* ADC dst:Rw,src:Ew */
adc11 cmac12struc public data(
.adc10,2,
specR,modw,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,13h, /* DB 13H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* ADD dst:Eb,src:Db */
add1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* ADD dst:Ew,src:Db */
add2 cmac14struc data(
.add1,2,
specE,modw,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADD dst:Ew,src:Dsb */
add3 cmac14struc data(
.add2,2,
specE,modw,
specD,modsb,
msegfix,dst, /* SEGFIX dst */
mdbn,83h, /* DB 83H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* ADD dst:Ew,src:Dw */
add4 cmac14struc data(
.add3,2,
specE,modw,
specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADD dst:Ab,src:Db */
add5 cmac9struc data(
.add4,2,
specA,modb,
specD,modb,
mdbn,04h, /* DB 04H */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* ADD dst:Aw,src:Db */
add6 cmac9struc data(
.add5,2,
specA,modw,
specD,modb,
mdbn,05h, /* DB 05H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADD dst:Aw,src:Dw */
add7 cmac9struc data(
.add6,2,
specA,modw,
specD,modw,
mdbn,05h, /* DB 05H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* ADD dst:Eb,src:Rb */
add8 cmac12struc data(
.add7,2,
specE,modb,
specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0, /* DB 00H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* ADD dst:Ew,src:Rw */
add9 cmac12struc data(
.add8,2,
specE,modw,
specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,1, /* DB 01H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* ADD dst:Rb,src:Eb */
add10 cmac12struc data(
.add9,2,
specR,modb,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,2, /* DB 02H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* ADD dst:Rw,src:Ew */
add11 cmac12struc public data(
.add10,2,
specR,modw,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,3, /* DB 03H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* AND dst:Eb,src:Db */
and1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,4,dst, /* MODRM 4,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* AND dst:Ew,src:Db */
and2 cmac14struc data(
.and1,2,
specE,modw,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,4,dst, /* MODRM 4,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* AND dst:Ew,src:Dw */
and3 cmac14struc data(
.and2,2,
specE,modw,specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,4,dst, /* MODRM 4,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* AND dst:Ab,src:Db */
and4 cmac9struc data(
.and3,2,
specA,modb,specD,modb,
mdbn,24h, /* DB 24H */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* AND dst:Aw,src:Db */
and5 cmac9struc data(
.and4,2,
specA,modw,specD,modb,
mdbn,25h, /* DB 25H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* AND dst:Aw,src:Dw */
and6 cmac9struc data(
.and5,2,
specA,modw,specD,modw,
mdbn,25h, /* DB 25H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* AND dst:Eb,src:Rb */
and7 cmac12struc data(
.and6,2,
specE,modb,specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,20h, /* DB 20H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* AND dst:Ew,src:Rw */
and8 cmac12struc data(
.and7,2,
specE,modw,specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,21h, /* DB 21H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm),
/* AND dst:Rb,src:Eb */
and9 cmac12struc data(
.and8,2,
specR,modb,specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,22h, /* DB 22H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* AND dst:Rw,src:Ew */
and10 cmac12struc public data(
.and9,2,
specR,modw,specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,23h, /* DB 23H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* CALL adr:Ew */
call1 cmac10struc data(
nil,1,
specE,modw,
msegfix,adr, /* SEGFIX adr */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,2,adr, /* MODRM 2,adr */
mendm), /* ENDM */
/* CALL adr:Cb */
call2 cmac7struc data(
.call1,1,
specC,modb,
mdbn,0e8h, /* DB 0E8H */
mrelw,adr, /* RELW adr */
mendm), /* ENDM */
/* CALL adr:Cw */
call3 cmac7struc public data(
.call2,1,
specC,modw,
mdbn,0e8h, /* DB 0E8H */
mrelw,adr, /* RELW adr */
mendm), /* ENDM */
/* CALLF adr:Ed */
callf1 cmac10struc data(
nil,1,
specE,modd,
msegfix,adr, /* SEGFIX adr */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,3,adr, /* MODRM 3,adr */
mendm), /* ENDM */
/* CALLF adr:Cd */
callf2 cmac7struc public data(
.callf1,1,
specC,modd,
mdbn,9ah, /* DB 9AH */
mddf,adr, /* DD adr */
mendm), /* ENDM */
/* CBW */
cbw1 cmac3struc public data(
nil,0,
mdbn,98h, /* DB 98H */
mendm), /* ENDM */
/* CLC */
clc1 cmac3struc public data(
nil,0,
mdbn,0f8h, /* DB 0F8H */
mendm), /* ENDM */
/* CLD */
cld1 cmac3struc public data(
nil,0,
mdbn,0fch, /* DB 0FCH */
mendm), /* ENDM */
/* CLI */
cli1 cmac3struc public data(
nil,0,
mdbn,0fah, /* DB 0FAH */
mendm), /* ENDM */
/* CMC */
cmc1 cmac3struc public data(
nil,0,
mdbn,0f5h, /* DB 0F5H */
mendm), /* ENDM */
/* CMP dst:Eb,src:Db */
cmp1 cmac14struc data(
nil,2,
specE,modb,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,7,dst, /* MODRM 7,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* CMP dst:Ew,src:Db */
cmp2 cmac14struc data(
.cmp1,2,
specE,modw,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,7,dst, /* MODRM 7,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* CMP dst:Ew,src:Dsb */
cmp3 cmac14struc data(
.cmp2,2,
specE,modw,specD,modsb,
msegfix,dst, /* SEGFIX dst */
mdbn,83h, /* DB 83H */
mmodrm1,7,dst, /* MODRM 7,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* CMP dst:Ew,src:Dw */
cmp4 cmac14struc data(
.cmp3,2,
specE,modw,specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,7,dst, /* MODRM 7,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* CMP dst:Ab,src:Db */
cmp5 cmac9struc data(
.cmp4,2,
specA,modb,specD,modb,
mdbn,3ch, /* DB 3CH */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* CMP dst:Aw,src:Db */
cmp6 cmac9struc data(
.cmp5,2,
specA,modw,specD,modb,
mdbn,3dh, /* DB 3DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* CMP dst:Aw,src:Dw */
cmp7 cmac9struc data(
.cmp6,2,
specA,modw,specD,modw,
mdbn,3dh, /* DB 3DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* CMP dst:Eb,src:Rb */
cmp8 cmac12struc data(
.cmp7,2,
specE,modb,specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,38h, /* DB 38H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* CMP dst:Ew,src:Rw */
cmp9 cmac12struc data(
.cmp8,2,
specE,modw,specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,39h, /* DB 39H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* CMP dst:Rb,src:Eb */
cmp10 cmac12struc data(
.cmp9,2,
specR,modb,specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,3ah, /* DB 3AH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* CMP dst:Rw,src:Ew */
cmp11 cmac12struc public data(
.cmp10,2,
specR,modw,specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,3bh, /* DB 3BH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm); /* ENDM */
end$module cmac1;


View File

@@ -0,0 +1,550 @@
$title ('CODEMACRO DEFINITIONS - PART 2')
cmac2:
do;
/*
modified 6/16/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:cmacd.lit)
$include (:f1:equals.lit)
$include (:f1:cmac.lit)
dcl
/* CMPS dst:Eb,src:Eb */
cmps1 cmac12struc data(
nil,2,
specE,modb,specE,modb,
mnosegfix,res,dst, /* NOSEGFIX ES,dst */
msegfix,src, /* SEGFIX src */
mdbn,0a6h, /* DB 0A6H */
mendm), /* ENDM */
/* CMPS dst:Ew,src:Ew */
cmps2 cmac12struc public data(
.cmps1,2,
specE,modw,specE,modw,
mnosegfix,res,dst, /* NOSEGFIX ES,dst */
msegfix,src, /* SEGFIX src */
mdbn,0a7h, /* DB 0A7H */
mendm), /* ENDM */
/* CMPSB */
CMPSB1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0A6H,
MENDM),
/* CMPSW */
CMPSW1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0A7H,
MENDM),
/* CWD */
cwd1 cmac3struc public data(
nil,0,
mdbn,99h, /* DB 99H */
mendm), /* ENDM */
/* DAA */
daa1 cmac3struc public data(
nil,0,
mdbn,27h, /* DB 27H */
mendm), /* ENDM */
/* DAS */
das1 cmac3struc public data(
nil,0,
mdbn,2fh, /* DB 2FH */
mendm), /* ENDM */
/* DEC dst:Eb */
dec1 cmac10struc data(
nil,1,
specE,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0feh, /* DB 0FEH */
mmodrm1,1,dst, /* MODRM 1,dst */
mendm), /* ENDM */
/* DEC dst:Ew */
dec2 cmac10struc data(
.dec1,1,
specE,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,1,dst, /* MODRM 1,dst */
mendm), /* ENDM */
/* DEC dst:Rw */
dec3 cmac12struc public data(
.dec2,1,
specR,modw,
mdbit, /* DBIT 5(9H),3(dst) */
mnumberbits,5,9h,
mformalbits,3,dst,0,
mendbit,
mendm),
/* DIV divisor:Eb */
div1 cmac10struc data(
nil,1,
specE,modb,
msegfix,divisor, /* SEGFIX divisor */
mdbn,0f6h, /* DB 6FH */
mmodrm1,6,divisor, /* MODRM divisor */
mendm), /* ENDM */
/* DIV divisor:Ew */
div2 cmac10struc public data(
.div1,1,
specE,modw,
msegfix,divisor, /* SEGFIX divisor */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,6,divisor, /* MODRM 6,divisor */
mendm), /* ENDM */
/* ESC opcode:Db(0,63),src:Eb */
esc1 cmac21struc data(
nil,2,
specD,modb+doublerange+numberrange,0,63,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbit, /* DBIT 5(1BH),3(opcode(3)) */
mnumberbits,5,1bh,
mformalbits,3,opcode,3,
mendbit,
mmodrm2,opcode,src, /* MODRM opcode,src */
mendm), /* ENDM */
/* ESC opcode:Db(0,63),src:Ew */
esc2 cmac21struc data(
.esc1,2,
specD,modb+doublerange+numberrange,0,63,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbit, /* DBIT 5(1BH),3(opcode(3)) */
mnumberbits,5,1bh,
mformalbits,3,opcode,3,
mendbit,
mmodrm2,opcode,src, /* MODRM opcode,src */
mendm), /* ENDM */
/* ESC opcode:Db(0,63),src:Ed */
esc3 cmac21struc public data(
.esc2,2,
specD,modb+doublerange+numberrange,0,63,
specE,modd,
msegfix,src, /* SEGFIX src */
mdbit, /* DBIT 5(1BH),3(opcode(3)) */
mnumberbits,5,1bh,
mformalbits,3,opcode,3,
mendbit,
mmodrm2,opcode,src, /* MODRM opcode,src */
mendm), /* ENDM */
/* HLT */
hlt1 cmac3struc public data(
nil,0,
mdbn,0f4h, /* DB 0F4H */
mendm), /* ENDM */
/* IDIV divisor:Eb */
idiv1 cmac10struc data(
nil,1,
specE,modb,
msegfix,divisor, /* SEGFIX divisor */
mdbn,0f6h, /* DB 0F6H */
mmodrm1,7,divisor, /* MODRM 7,divisor */
mendm), /* ENDM */
/* IDIV divisor:Ew */
idiv2 cmac10struc public data(
.idiv1,1,
specE,modw,
msegfix,divisor, /* SEGFIX divisor */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,7,divisor, /* MODRM 7,divisor */
mendm),
/* IMUL mplier:Eb */
imul1 cmac10struc data(
nil,1,
specE,modb,
msegfix,mplier, /* SEGFIX mplier */
mdbn,0f6h, /* DB 0F6H */
mmodrm1,5,mplier, /* MODRM 5,mplier */
mendm), /* ENDM */
/* IMUL mplier:Ew */
imul2 cmac10struc public data(
.imul1,1,
specE,modw,
msegfix,mplier, /* SEGFIX mplier */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,5,mplier, /* MODRM 5,mplier */
mendm), /* ENDM */
/* IN dst:Ab,port:Db */
in1 cmac9struc data(
nil,2,
specA,modb,specD,modb,
mdbn,0e4h, /* DB 0E4H */
mdbf,port, /* DB port */
mendm), /* ENDM */
/* IN dst:Aw,port:Db */
in2 cmac9struc data(
.in1,2,
specA,modw,specD,modb,
mdbn,0e5h, /* DB 0E5H */
mdbf,port, /* DB port */
mendm), /* ENDM */
/* IN dst:Ab,port:Rw(DX) */
in3 cmac8struc data(
.in2,2,
specA,modb,
specR,modw+singlerange+register$range,rdx,
mdbn,0ech, /* DB 0ECH */
mendm),
/* IN dst:Aw,port:Rw(DX) */
in4 cmac8struc public data(
.in3,2,
specA,modw,
specR,modw+singlerange+register$range,rdx,
mdbn,0edh, /* DB 0EDH */
mendm), /* ENDM */
/* INC dst:Eb */
inc1 cmac10struc data(
nil,1,
specE,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0feh, /* DB 0FEH */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* INC dst:Ew */
inc2 cmac10struc data(
.inc1,1,
specE,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* INC dst:Rw */
inc3 cmac12struc public data(
.inc2,1,
specR,modw,
mdbit, /* DBIT 5(08H),3(dst(0)) */
mnumberbits,5,08h,
mformalbits,3,dst,0,
mendbit,
mendm), /* ENDM */
/* INT itype:Db */
int1 cmac7struc data(
nil,1,
specD,modb,
mdbn,0cdh, /* DB 0CDH */
mdbf,itype, /* DB itype */
mendm), /* ENDM */
/* INT itype:Db(3) */
int2 cmac6struc public data(
.int1,1,
specD,modb+singlerange,3,
mdbn,0cch, /* DB 0CCH */
mendm), /* ENDM */
/* INTO */
into1 cmac3struc public data(
nil,0,
mdbn,0ceh, /* DB 0CEH */
mendm), /* ENDM */
/* IRET */
iret1 cmac3struc public data(
nil,0,
mdbn,0cfh, /* DB 0CFH */
mendm), /* ENDM */
/* JA place:Cb */
ja1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,77h, /* DB 77H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JAE place:Cb */
jae1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,73h, /* DB 73H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JB place:Cb */
jb1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,72h, /* DB 72H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JBE place:Cb */
jbe1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,76h, /* DB 76H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JCXZ place:Cb */
jcxz1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,0e3h, /* DB 0E3H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JE place:Cb */
je1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,74h, /* DB 74H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JG place:Cb */
jg1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,7fh, /* DB 7FH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JGE place:Cb */
jge1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,7dh, /* DB 7DH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JL place:Cb */
jl1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,7ch, /* DB 7CH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JLE place:Cb */
jle1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,7eh, /* DB 7EH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JMP place:Ew */
jmp1 cmac10struc data(
nil,1,
specE,modw,
msegfix,place, /* SEGFIX place */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,4,place, /* MODRM 4,place */
mendm), /* ENDM */
/* JMP place:Cw */
jmp2 cmac7struc public data(
.jmp1,1,
specC,modw,
mdbn,0e9h, /* DB 0E9H */
mrelw,place, /* RELW place */
mendm), /* ENDM */
/* JMPF place:Md */
jmpf1 cmac10struc data(
nil,1,
specM,modd,
msegfix,place, /* SEGFIX place */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,5,place, /* MODRM 5,place */
mendm), /* ENDM */
/* JMPF place:Cd */
jmpf2 cmac7struc public data(
.jmpf1,1,
specC,modd,
mdbn,0eah, /* DB 0EAH */
mddf,place, /* DD place */
mendm), /* ENDM */
/* JMPS place:Cb */
jmps1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,0ebh, /* DB 0EBH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JNE place:Cb */
jne1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,75h, /* DB 75H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JNO place:Cb */
jno1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,71h, /* DB 71H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JNP place:Cb */
jnp1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,7bh, /* DB 7BH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JNS place:Cb */
jns1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,79h, /* DB 79H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JO place:Cb */
jo1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,70h, /* DB 70H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JP place:Cb */
jp1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,7ah, /* DB 7AH */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* JS place:Cb */
js1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,78h, /* DB 78H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* LAHF */
lahf1 cmac3struc public data(
nil,0,
mdbn,9fh, /* DB 9FH */
mendm), /* ENDM */
/* LDS dst:Rw,src:Ed */
lds1 cmac12struc public data(
nil,2,
specR,modw,specE,modd,
msegfix,src, /* SEGFIX src */
mdbn,0c5h, /* DB 0C5H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* LES dst:Rw,src:Ed */
les1 cmac12struc public data(
nil,2,
specR,modw,specE,modd,
msegfix,src, /* SEGFIX src */
mdbn,0c4h, /* DB 0C4H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* LEA dst:Rw,src:M */
lea1 cmac10struc public data(
nil,2,
specR,modw,specM,nomod,
mdbn,8dh, /* DB 8DH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* LOCK prefx */
lock1 cmac3struc public data(
nil,0+prefix$on,
mdbn,0f0h, /* DB 0F0H */
mendm), /* ENDM */
/* LODS SI$ptr:Eb */
lods1 cmac7struc data(
nil,1,
specE,modb,
msegfix,si$ptr, /* SEGFIX SI$ptr */
mdbn,0ach, /* DB 0ACH */
mendm), /* ENDM */
/* LODS SI$ptr:Ew */
lods2 cmac7struc public data(
.lods1,1,
specE,modw,
msegfix,si$ptr, /* SEGFIX SI$ptr */
mdbn,0adh, /* DB 0AdH */
mendm), /* ENDM */
/* LODSB */
LODSB1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0ACH,
MENDM),
/* LODSW */
LODSW1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0ADH,
MENDM),
/* LOOP place:Cb */
loop1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,0e2h, /* DB 0E2H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* LOOPE place:Cb */
loope1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,0e1h, /* DB 0E1H */
mrelb,place, /* RELB place */
mendm), /* ENDM */
/* LOOPNE place:Cb */
loopne1 cmac7struc public data(
nil,1,
specC,modb,
mdbn,0e0h, /* DB 0E0H */
mrelb,place, /* RELB place */
mendm); /* ENDM */
end$module cmac2;


View File

@@ -0,0 +1,478 @@
$title ('CODEMACRO DEFINITIONS - PART 3')
cmac3:
do;
/*
modified 6/16/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:cmacd.lit)
$include (:f1:equals.lit)
$include (:f1:cmac.lit)
dcl
/* MOV dst:Eb,src:Db */
mov1 cmac14struc data(
nil,2,
specE,modb,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0c6h, /* DB 0C6h */
mmodrm1,0,dst, /* MODRM 0,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* MOV dst:Ew,src:Db */
mov2 cmac14struc data(
.mov1,2,
specE,modw,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0c7h, /* DB 0C7h */
mmodrm1,0,dst, /* MODRM 0,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* MOV dst:Ew,src:Dw */
mov3 cmac14struc data(
.mov2,2,
specE,modw,specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0c7h, /* DB 0C7h */
mmodrm1,0,dst, /* MODRM 0,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* MOV dst:Rb,src:Db */
mov4 cmac16struc data(
.mov3,2,
specR,modb,specD,modb,
mdbit, /* DBIT 5(10110B),3(dst(0)) */
mnumberbits,5,16h,
mformalbits,3,dst,0,
mendbit,
mdbf,src, /* DB src */
mendm), /* ENDM */
/* MOV dst:Rw,src:Db */
mov5 cmac16struc data(
.mov4,2,
specR,modw,specD,modb,
mdbit, /* DBIT 5(10111B),3(dst(0)) */
mnumberbits,5,17h,
mformalbits,3,dst,0,
mendbit,
mdwf,src, /* DW src */
mendm), /* ENDM */
/* MOV dst:Rw,src:Dw */
mov6 cmac16struc data(
.mov5,2,
specR,modw,specD,modw,
mdbit, /* DBIT 5(10111B),3(dst(0)) */
mnumberbits,5,17h,
mformalbits,3,dst,0,
mendbit,
mdwf,src, /* DW src */
mendm), /* ENDM */
/* MOV dst:Eb,src:Rb */
mov7 cmac12struc data(
.mov6,2,
specE,modb,specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,88h, /* DB 88H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* MOV dst:Ew,src:Rw */
mov8 cmac12struc data(
.mov7,2,
specE,modw,specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,89h, /* DB 89H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* MOV dst:Rb,src:Eb */
mov9 cmac12struc data(
.mov8,2,
specR,modb,specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,8ah, /* DB 8AH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* MOV dst:Rw,src:Ew */
mov10 cmac12struc data(
.mov9,2,
specR,modw,specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,8bh, /* DB 8BH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* MOV dst:Ew,src:S */
mov11 cmac12struc data(
.mov10,2,
specE,modw,specS,nomod,
msegfix,dst, /* SEGFIX dst */
mdbn,8ch, /* DB 8CH */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* MOV dst:Sd(ES),src:Ew */
mov12 cmac13struc data(
.mov11,2,
specS,modd+singlerange+registerrange,res,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,8eh, /* DB 8EH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* MOV dst:Sd(SS,DS),src:Ew */
mov13 cmac14struc data(
.mov12,2,
specS,modd+doublerange+registerrange,rss,rds,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,8eh, /* DB 8EH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* MOV dst:Ab,src:Xb */
mov14 cmac11struc data(
.mov13,2,
specA,modb,specX,modb,
msegfix,src, /* SEGFIX src */
mdbn,0a0h, /* DB 0A0H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* MOV dst:Aw,src:Xw */
mov15 cmac11struc data(
.mov14,2,
specA,modw,specX,modw,
msegfix,src, /* SEGFIX src */
mdbn,0a1h, /* DB 0A1H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* MOV dst:Xb,src:Ab */
mov16 cmac11struc data(
.mov15,2,
specX,modb,specA,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0a2h, /* DB 0A2H */
mdwf,dst, /* DW dst */
mendm), /* ENDM */
/* MOV dst:Xw,src:Aw */
mov17 cmac11struc public data(
.mov16,2,
specX,modw,specA,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0a3h, /* DB 0A3H */
mdwf,dst, /* DW dst */
mendm), /* ENDM */
/* MOVS SI$ptr:Eb,DI$ptr:Eb */
movs1 cmac12struc data(
nil,2,
specE,modb,specE,modb,
mnosegfix,res,si$ptr, /* NOSEGFIX ES,SI$ptr */
msegfix,di$ptr, /* SEGFIX DI$ptr */
mdbn,0a4h, /* DB 0A4H */
mendm), /* ENDM */
/* MOVS SI$ptr:Ew,DI$ptr:Ew */
movs2 cmac12struc public data(
.movs1,2,
specE,modw,specE,modw,
mnosegfix,res,si$ptr, /* NOSEGFIX ES,SI$ptr */
msegfix,di$ptr, /* SEGFIX DI$ptr */
mdbn,0a5h, /* DB 0A5H */
mendm), /* ENDM */
/* MOVSB */
MOVSB1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0A4H,
MENDM),
/* MOVSW */
MOVSW1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0A5H,
MENDM),
/* MUL mplier:Eb */
mul1 cmac10struc data(
nil,1,
specE,modb,
msegfix,mplier, /* SEGFIX mplier */
mdbn,0f6h, /* DB 0F6H */
mmodrm1,4,mplier, /* MODRM 4,mplier */
mendm), /* ENDM */
/* MUL mplier:Ew */
mul2 cmac10struc public data(
.mul1,1,
specE,modw,
msegfix,mplier, /* SEGFIX mplier */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,4,mplier, /* MODRM 4,mplier */
mendm), /* ENDM */
/* NEG dst:Eb */
neg1 cmac10struc data(
nil,1,
specE,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0f6h, /* DB 0F6H */
mmodrm1,3,dst, /* MODRM 3,dst */
mendm), /* ENDM */
/* NEG dst:Ew */
neg2 cmac10struc public data(
.neg1,1,
specE,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,3,dst, /* MODRM 3,dst */
mendm), /* ENDM */
/* NOP */
nop1 cmac3struc public data(
nil,0,
mdbn,90h, /* DB 90H */
mendm), /* ENDM */
/* NOT dst:Eb */
not1 cmac10struc data(
nil,1,
specE,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0f6h, /* DB 0F6H */
mmodrm1,2,dst, /* MODRM 2,dst */
mendm), /* ENDM */
/* NOT dst:Ew */
not2 cmac10struc public data(
.not1,1,
specE,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,2,dst, /* MODRM 2,dst */
mendm), /* ENDM */
/* OR dst:Eb,src:Db */
or1 cmac14struc data(
nil,2,
specE,modb,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80h */
mmodrm1,1,dst, /* MODRM 1,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* OR dst:Ew,src:Dw */
or2 cmac14struc data(
.or1,2,
specE,modw,specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,1,dst, /* MODRM 1,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* OR dst:Ew,src:Db */
or3 cmac14struc data(
.or2,2,
specE,modw,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,1,dst, /* MODRM 1,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* OR dst:Ab,src:Db */
or4 cmac9struc data(
.or3,2,
specA,modb,specD,modb,
mdbn,0ch, /* DB 0CH */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* OR dst:Aw,src:Db */
or5 cmac9struc data(
.or4,2,
specA,modw,specD,modb,
mdbn,0dh, /* DB 0DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* OR dst:Aw,src:Dw */
or6 cmac9struc data(
.or5,2,
specA,modw,specD,modw,
mdbn,0dh, /* DB 0DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* OR dst:Eb,src:Rb */
or7 cmac12struc data(
.or6,2,
specE,modb,specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,08h, /* DB 08h */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* OR dst:Ew,src:Rw */
or8 cmac12struc data(
.or7,2,
specE,modw,specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,09h, /* DB 09h */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* OR dst:Rb,src:Eb */
or9 cmac12struc data(
.or8,2,
specR,modb,specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,0ah, /* DB 0Ah */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* OR dst:Rw,src:Ew */
or10 cmac12struc public data(
.or9,2,
specR,modw,specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,0bh, /* DB 0Bh */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* OUT dst:Db,src:Ab */
out1 cmac9struc data(
nil,2,
specD,modb,specA,modb,
mdbn,0e6h, /* DB 0E6H */
mdbf,dst, /* DB dst */
mendm), /* ENDM */
/* OUT dst:Db,src:Aw */
out2 cmac9struc data(
.out1,2,
specD,modb,specA,modw,
mdbn,0e7h, /* DB 0E7H */
mdbf,dst, /* DB dst */
mendm), /* ENDM */
/* OUT dst:Rw(DX),src:Ab */
out3 cmac8struc data(
.out2,2,
specR,modw+singlerange+registerrange,rdx,
specA,modb,
mdbn,0eeh, /* DB 0EEH */
mendm), /* ENDM */
/* OUT dst:Rw(DX),src:Aw */
out4 cmac8struc public data(
.out3,2,
specR,modw+singlerange+registerrange,rdx,
specA,modw,
mdbn,0efh, /* DB 0EFH */
mendm), /* ENDM */
/* POP dst:Ew */
pop1 cmac10struc data(
nil,1,
specE,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,8fh, /* DB 8FH */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* POP dst:Sd(ES) */
pop2 cmac16struc data(
.pop1,1,
specS,modd+singlerange+registerrange,res,
mdbit, /* DBIT 3(0),2(dst(0)),3(7) */
mnumberbits,3,0,
mformalbits,2,dst,0,
mnumberbits,3,7,
mendbit,
mendm), /* ENDM */
/* POP dst:Sd(SS,DS) */
pop3 cmac17struc data(
.pop2,1,
specS,modd+doublerange+registerrange,rss,rds,
mdbit, /* DBIT 3(0),2(dst(0)),3(7) */
mnumberbits,3,0,
mformalbits,2,dst,0,
mnumberbits,3,7,
mendbit,
mendm), /* ENDM */
/* POP dst:Rw */
pop4 cmac12struc public data(
.pop3,1,
specR,modw,
mdbit, /* DBIT 5(01011B),3(dst(0)) */
mnumberbits,5,0bh,
mformalbits,3,dst,0,
mendbit,
mendm), /* ENDM */
/* POPF */
popf1 cmac3struc public data(
nil,0,
mdbn,9dh, /* DB 9DH */
mendm), /* ENDM */
/* PUSH dst:Ew */
push1 cmac10struc data(
nil,1,
specE,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0ffh, /* DB 0FFH */
mmodrm1,6,dst, /* MODRM 6,dst */
mendm), /* ENDM */
/* PUSH dst:Sd */
push2 cmac15struc data(
.push1,1,
specS,modd,
mdbit, /* DBIT 3(0),2(dst(0)),3(6) */
mnumberbits,3,0,
mformalbits,2,dst,0,
mnumberbits,3,6,
mendbit,
mendm), /* ENDM */
/* PUSH dst:Rw */
push3 cmac12struc public data(
.push2,1,
specR,modw,
mdbit, /* DBIT 5(01010B),3(dst(0)) */
mnumberbits,5,0ah,
mformalbits,3,dst,0,
mendbit,
mendm), /* ENDM */
/* PUSHF */
pushf1 cmac3struc public data(
nil,0,
mdbn,9ch, /* DB 9CH */
mendm); /* ENDM */
end$module cmac3;


View File

@@ -0,0 +1,506 @@
$title ('CODEMACRO DEFINITIONS - PART 4')
cmac4:
do;
/*
modified 6/16/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:cmacd.lit)
$include (:f1:equals.lit)
$include (:f1:cmac.lit)
dcl
/* RCL dst:Eb,count:Db(1) */
rcl1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,2,dst, /* MODRM 2,dst */
mendm), /* ENDM */
/* RCL dst:Ew,count:Db(1) */
rcl2 cmac13struc data(
.rcl1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,2,dst, /* MODRM 2,dst */
mendm), /* ENDM */
/* RCL dst:Eb,count:Rb(CL) */
rcl3 cmac13struc data(
.rcl2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,2,dst, /* MODRM 2,dst */
mendm), /* ENDM */
/* RCL dst:Ew,count:Rb(CL) */
rcl4 cmac13struc public data(
.rcl3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,2,dst, /* MODRM 2,dst */
mendm), /* ENDM */
/* RCR dst:Eb,count:Db(1) */
rcr1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,3,dst, /* MODRM 3,dst */
mendm), /* ENDM */
/* RCR dst:Ew,count:Db(1) */
rcr2 cmac13struc data(
.rcr1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,3,dst, /* MODRM 3,dst */
mendm), /* ENDM */
/* RCR dst:Eb,count:Rb(CL) */
rcr3 cmac13struc data(
.rcr2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,3,dst, /* MODRM 3,dst */
mendm), /* ENDM */
/* RCR dst:Ew,count:Rb(CL) */
rcr4 cmac13struc public data(
.rcr3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,3,dst, /* MODRM 3,dst */
mendm), /* ENDM */
/* REP PREFX */
rep1 cmac3struc public data(
nil,0+prefix$on,
mdbn,0f3h, /* DB 0F3H */
mendm), /* ENDM */
/* REPE PREFX */
repe1 cmac3struc public data(
nil,0+prefix$on,
mdbn,0f3h, /* DB 0F3H */
mendm), /* ENDM */
/* REPNE PREFX */
repne1 cmac3struc public data(
nil,0+prefix$on,
mdbn,0f2h, /* DB 0F2H */
mendm), /* ENDM */
/* RET dst:Db */
ret1 cmac7struc data(
nil,1,
specD,modb,
mdbn,0c2h, /* DB 0C2H */
mdwf,dst, /* DW dst */
mendm), /* ENDM */
/* RET dst:Dw */
ret2 cmac7struc data(
.ret1,1,
specD,modw,
mdbn,0c2h, /* DB 0C2H */
mdwf,dst, /* DW dst */
mendm), /* ENDM */
/* RET */
ret3 cmac3struc public data(
.ret2,0,
mdbn,0c3h, /* DB 0C3H */
mendm), /* ENDM */
/* RETF dst:Db */
retf1 cmac7struc data(
nil,1,
specD,modb,
mdbn,0cah, /* DB 0CAH */
mdwf,dst, /* DW dst */
mendm), /* ENDM */
/* RETF dst:Dw */
retf2 cmac7struc data(
.retf1,1,
specD,modw,
mdbn,0cah, /* DB 0CAH */
mdwf,dst, /* DW dst */
mendm), /* ENDM */
/* RETF */
retf3 cmac3struc public data(
.retf2,0,
mdbn,0cbh, /* DB 0C3H */
mendm), /* ENDM */
/* ROL dst:Eb,count:Db(1) */
rol1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* ROL dst:Ew,count:Db(1) */
rol2 cmac13struc data(
.rol1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* ROL dst:Eb,count:Rb(CL) */
rol3 cmac13struc data(
.rol2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* ROL dst:Ew,count:Rb(CL) */
rol4 cmac13struc public data(
.rol3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,0,dst, /* MODRM 0,dst */
mendm), /* ENDM */
/* ROR dst:Eb,count:Db(1) */
ror1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,1,dst, /* MODRM 1,dst */
mendm), /* ENDM */
/* ROR dst:Ew,count:Db(1) */
ror2 cmac13struc data(
.ror1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,1,dst, /* MODRM 1,dst */
mendm), /* ENDM */
/* ROR dst:Eb,count:Rb(CL) */
ror3 cmac13struc data(
.ror2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,1,dst, /* MODRM 1,dst */
mendm), /* ENDM */
/* ROR dst:Ew,count:Rb(CL) */
ror4 cmac13struc public data(
.ror3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,1,dst, /* MODRM 1,dst */
mendm), /* ENDM */
/* SAHF */
sahf1 cmac3struc public data(
nil,0,
mdbn,9eh, /* DB 9EH */
mendm), /* ENDM */
/* SAL dst:Eb,count:Db(1) */
sal1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,4,dst, /* MODRM 4,dst */
mendm), /* ENDM */
/* SAL dst:Ew,count:Db(1) */
sal2 cmac13struc data(
.sal1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,4,dst, /* MODRM 4,dst */
mendm), /* ENDM */
/* SAL dst:Eb,count:Rb(CL) */
sal3 cmac13struc data(
.sal2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,4,dst, /* MODRM 4,dst */
mendm), /* ENDM */
/* SAL dst:Ew,count:Rb(CL) */
sal4 cmac13struc public data(
.sal3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,4,dst, /* MODRM 4,dst */
mendm), /* ENDM */
/* SAR dst:Eb,count:Db(1) */
sar1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,7,dst, /* MODRM 7,dst */
mendm), /* ENDM */
/* SAR dst:Ew,count:Db(1) */
sar2 cmac13struc data(
.sar1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,7,dst, /* MODRM 7,dst */
mendm), /* ENDM */
/* SAR dst:Eb,count:Rb(CL) */
sar3 cmac13struc data(
.sar2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,7,dst, /* MODRM 7,dst */
mendm), /* ENDM */
/* SAR dst:Ew,count:Rb(CL) */
sar4 cmac13struc public data(
.sar3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,7,dst, /* MODRM 7,dst */
mendm), /* ENDM */
/* SBB dst:Eb,src:Db */
sbb1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,3,dst, /* MODRM 3,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* SBB dst:Ew,src:Db */
sbb2 cmac14struc data(
.sbb1,2,
specE,modw,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,3,dst, /* MODRM 3,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SBB dst:Ew,src:Dsb */
sbb3 cmac14struc data(
.sbb2,2,
specE,modw,
specD,modsb,
msegfix,dst, /* SEGFIX dst */
mdbn,83h, /* DB 83H */
mmodrm1,3,dst, /* MODRM 3,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* SBB dst:Ew,src:Dw */
sbb4 cmac14struc data(
.sbb3,2,
specE,modw,
specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,3,dst, /* MODRM 3,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SBB dst:Ab,src:Db */
sbb5 cmac9struc data(
.sbb4,2,
specA,modb,
specD,modb,
mdbn,1ch, /* DB 1CH */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* SBB dst:Aw,src:Db */
sbb6 cmac9struc data(
.sbb5,2,
specA,modw,
specD,modb,
mdbn,1dh, /* DB 1DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SBB dst:Aw,src:Dw */
sbb7 cmac9struc data(
.sbb6,2,
specA,modw,
specD,modw,
mdbn,1dh, /* DB 1DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SBB dst:Eb,src:Rb */
sbb8 cmac12struc data(
.sbb7,2,
specE,modb,
specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,18h, /* DB 18H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* SBB dst:Ew,src:Rw */
sbb9 cmac12struc data(
.sbb8,2,
specE,modw,
specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,19h, /* DB 19H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* SBB dst:Rb,src:Eb */
sbb10 cmac12struc data(
.sbb9,2,
specR,modb,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,1ah, /* DB 1AH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* SBB dst:Rw,src:Ew */
sbb11 cmac12struc public data(
.sbb10,2,
specR,modw,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,1bh, /* DB 1BH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* SCAS dst:Eb */
scas1 cmac8struc data(
nil,1,
specE,modb,
mnosegfix,res,dst, /* NOSEGFIX ES,dst */
mdbn,0aeh, /* DB 0AEH */
mendm), /* ENDM */
/* SCAS dst:Ew */
scas2 cmac8struc public data(
.scas1,1,
specE,modw,
mnosegfix,res,dst, /* NOSEGFIX ES,dst */
mdbn,0afh, /* DB 0AFH */
mendm), /* ENDM */
/* SCASB */
SCASB1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0AEH,
MENDM),
/* SCASW */
SCASW1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0AFH,
MENDM),
/* SHR dst:Eb,count:Db(1) */
shr1 cmac13struc data(
nil,2,
specE,modb,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d0h, /* DB 0D0H */
mmodrm1,5,dst, /* MODRM 5,dst */
mendm), /* ENDM */
/* SHR dst:Ew,count:Db(1) */
shr2 cmac13struc data(
.shr1,2,
specE,modw,
specD,modb+singlerange+number$range,1,
msegfix,dst, /* SEGFIX dst */
mdbn,0d1h, /* DB 0D1H */
mmodrm1,5,dst, /* MODRM 5,dst */
mendm), /* ENDM */
/* SHR dst:Eb,count:Rb(CL) */
shr3 cmac13struc data(
.shr2,2,
specE,modb,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d2h, /* DB 0D2H */
mmodrm1,5,dst, /* MODRM 5,dst */
mendm), /* ENDM */
/* SHR dst:Ew,count:Rb(CL) */
shr4 cmac13struc public data(
.shr3,2,
specE,modw,
specR,modb+singlerange+register$range,rcl,
msegfix,dst, /* SEGFIX dst */
mdbn,0d3h, /* DB 0D3H */
mmodrm1,5,dst, /* MODRM 5,dst */
mendm); /* ENDM */
end$module cmac4;


View File

@@ -0,0 +1,441 @@
$title ('CODEMACRO DEFINITIONS - PART 5')
cmac5:
do;
/*
modified 6/16/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:cmacd.lit)
$include (:f1:equals.lit)
$include (:f1:cmac.lit)
dcl
/* STC */
stc1 cmac3struc public data(
nil,0,
mdbn,0f9h, /* DB 0F9H */
mendm), /* ENDM */
/* STD */
std1 cmac3struc public data(
nil,0,
mdbn,0fdh, /* DB 0FDH */
mendm), /* ENDM */
/* STI */
sti1 cmac3struc public data(
nil,0,
mdbn,0fbh, /* DB 0FBH */
mendm), /* ENDM */
/* STOS dst:Eb */
stos1 cmac8struc data(
nil,1,
specE,modb,
mnosegfix,res,dst, /* NOSEGFIX ES,dst */
mdbn,0aah, /* DB 0AAH */
mendm), /* ENDM */
/* STOS dst:Ew */
stos2 cmac8struc public data(
.stos1,1,
specE,modw,
mnosegfix,res,dst, /* NOSEGFIX ES,dst */
mdbn,0abh, /* DB 0ABH */
mendm), /* ENDM */
/* STOSB */
STOSB1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0AAH,
MENDM),
/* STOSW */
STOSW1 CMAC3STRUC PUBLIC DATA(
NIL,0,
MDBN,0ABH,
MENDM),
/* SUB dst:Eb,src:Db */
sub1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,5,dst, /* MODRM 5,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* SUB dst:Ew,src:Db */
sub2 cmac14struc data(
.sub1,2,
specE,modw,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,5,dst, /* MODRM 5,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SUB dst:Ew,src:Dsb */
sub3 cmac14struc data(
.sub2,2,
specE,modw,
specD,modsb,
msegfix,dst, /* SEGFIX dst */
mdbn,83h, /* DB 83H */
mmodrm1,5,dst, /* MODRM 5,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* SUB dst:Ew,src:Dw */
sub4 cmac14struc data(
.sub3,2,
specE,modw,
specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,5,dst, /* MODRM 5,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SUB dst:Ab,src:Db */
sub5 cmac9struc data(
.sub4,2,
specA,modb,
specD,modb,
mdbn,2ch, /* DB 2CH */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* SUB dst:Aw,src:Db */
sub6 cmac9struc data(
.sub5,2,
specA,modw,
specD,modb,
mdbn,2dh, /* DB 2DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SUB dst:Aw,src:Dw */
sub7 cmac9struc data(
.sub6,2,
specA,modw,
specD,modw,
mdbn,2dh, /* DB 2DH */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* SUB dst:Eb,src:Rb */
sub8 cmac12struc data(
.sub7,2,
specE,modb,
specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,28h, /* DB 28H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* SUB dst:Ew,src:Rw */
sub9 cmac12struc data(
.sub8,2,
specE,modw,
specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,29h, /* DB 29H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* SUB dst:Rb,src:Eb */
sub10 cmac12struc data(
.sub9,2,
specR,modb,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,2ah, /* DB 2AH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* SUB dst:Rw,src:Ew */
sub11 cmac12struc public data(
.sub10,2,
specR,modw,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,2bh, /* DB 2BH */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* TEST dst:Eb,src:Db */
test1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0f6h, /* DB 0F6H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* TEST dst:Ew,src:Db */
test2 cmac14struc data(
.test1,2,
specE,modw,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* TEST dst:Ew,src:Dw */
test3 cmac14struc data(
.test2,2,
specE,modw,
specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,0f7h, /* DB 0F7H */
mmodrm1,0,dst, /* MODRM 0,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* TEST dst:Ab,src:Db */
test4 cmac9struc data(
.test3,2,
specA,modb,
specD,modb,
mdbn,0a8h, /* DB 0A8H */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* TEST dst:Aw,src:Db */
test5 cmac9struc data(
.test4,2,
specA,modw,
specD,modb,
mdbn,0a9h, /* DB 0A9H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* TEST dst:Aw,src:Dw */
test6 cmac9struc data(
.test5,2,
specA,modw,
specD,modw,
mdbn,0a9h, /* DB 0A9H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* TEST dst:Eb,src:Rb */
test7 cmac12struc data(
.test6,2,
specE,modb,
specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,84h, /* DB 84H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* TEST dst:Ew,src:Rw */
test8 cmac12struc data(
.test7,2,
specE,modw,
specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,85h, /* DB 85H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* TEST dst:Rb,src:Eb */
test9 cmac12struc data(
.test8,2,
specR,modb,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,84h, /* DB 84H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* TEST dst:Rw,src:Ew */
test10 cmac12struc public data(
.test9,2,
specR,modw,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,85h, /* DB 85H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* WAIT */
wait1 cmac3struc public data(
nil,0,
mdbn,9bh, /* DB 9BH */
mendm), /* ENDM */
/* XCHG dst:Eb,src:Rb */
xchg1 cmac12struc data(
nil,2,
specE,modb,
specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,86h, /* DB 86H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* XCHG dst:Ew,src:Rw */
xchg2 cmac12struc data(
.xchg1,2,
specE,modw,
specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,87h, /* DB 87H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* XCHG dst:Rb,src:Eb */
xchg3 cmac12struc data(
.xchg2,2,
specR,modb,
specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,86h, /* DB 86H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* XCHG dst:Rw,src:Ew */
xchg4 cmac12struc data(
.xchg3,2,
specR,modw,
specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,87h, /* DB 87H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* XCHG dst:Rw,src:Aw */
xchg5 cmac14struc data(
.xchg4,2,
specR,modw,specA,modw,
mdbit, /* DBIT 5(10010B),3(dst(0)) */
mnumberbits,5,12h,
mformalbits,3,dst,0,
mendbit,
mendm), /* ENDM */
/* XCHG dst:Aw,src:Rw */
xchg6 cmac14struc public data(
.xchg5,2,
specA,modw,specR,modw,
mdbit, /* DBIT 5(10010B),3(dst(0)) */
mnumberbits,5,12h,
mformalbits,3,src,0,
mendbit,
mendm), /* ENDM */
/* XLAT dst:E */
xlat1 cmac7struc public data(
nil,1,
specE,nomod,
msegfix,dst, /* SEGFIX dst */
mdbn,0d7h, /* DB 0D7H */
mendm), /* ENDM */
/* XOR dst:Eb,src:Db */
xor1 cmac14struc data(
nil,2,
specE,modb,
specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,80h, /* DB 80H */
mmodrm1,6,dst, /* MODRM 6,dst */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* XOR dst:Ew,src:Db */
xor2 cmac14struc data(
.xor1,2,
specE,modw,specD,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,6,dst, /* MODRM 6,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* XOR dst:Ew,src:Dw */
xor3 cmac14struc data(
.xor2,2,
specE,modw,specD,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,81h, /* DB 81H */
mmodrm1,6,dst, /* MODRM 6,dst */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* XOR dst:Ab,src:Db */
xor4 cmac9struc data(
.xor3,2,
specA,modb,specD,modb,
mdbn,34h, /* DB 34H */
mdbf,src, /* DB src */
mendm), /* ENDM */
/* XOR dst:Aw,src:Db */
xor5 cmac9struc data(
.xor4,2,
specA,modw,specD,modb,
mdbn,35h, /* DB 35H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* XOR dst:Aw,src:Dw */
xor6 cmac9struc data(
.xor5,2,
specA,modw,specD,modw,
mdbn,35h, /* DB 35H */
mdwf,src, /* DW src */
mendm), /* ENDM */
/* XOR dst:Eb,src:Rb */
xor7 cmac12struc data(
.xor6,2,
specE,modb,specR,modb,
msegfix,dst, /* SEGFIX dst */
mdbn,30h, /* DB 30H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm), /* ENDM */
/* XOR dst:Ew,src:Rw */
xor8 cmac12struc data(
.xor7,2,
specE,modw,specR,modw,
msegfix,dst, /* SEGFIX dst */
mdbn,31h, /* DB 31H */
mmodrm2,src,dst, /* MODRM src,dst */
mendm),
/* XOR dst:Rb,src:Eb */
xor9 cmac12struc data(
.xor8,2,
specR,modb,specE,modb,
msegfix,src, /* SEGFIX src */
mdbn,32h, /* DB 32H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm), /* ENDM */
/* XOR dst:Rw,src:Ew */
xor10 cmac12struc public data(
.xor9,2,
specR,modw,specE,modw,
msegfix,src, /* SEGFIX src */
mdbn,33h, /* DB 33H */
mmodrm2,dst,src, /* MODRM dst,src */
mendm); /* ENDM */
end$module cmac5;


View File

@@ -0,0 +1,96 @@
$nolist
$eject
/* Here are the definitions for the */
/* codemacro instructions of the */
/* ASM86 assembler */
/* Commands within codemacros: */
declare
mdbn lit '0', /* DB with number */
mdbf lit '1', /* DB with formal parameter */
mdwn lit '2', /* DW with numbers */
mdwf lit '3', /* DW with formal parameter */
mddf lit '4', /* DD with formal parameter */
mdbit lit '5', /* DBIT */
mendm lit '6', /* ENDM */
mrelb lit '7', /* RELB */
mrelw lit '8', /* RELW */
mendbit lit '9', /* ENDBIT */
mmodrm1 lit '10', /* MODRM with 1 formal parameter */
mmodrm2 lit '11', /* MODRM with 2 formal parmeters */
msegfix lit '12', /* SEGFIX */
mnosegfix lit '13', /* NOSEGFIX */
mformalbits lit '14', /* define bits from formal par. */
mnumberbits lit '15'; /* define bits from number */
/* Specifier letters: */
declare
specA lit '0', /* accumulator, AX or AL */
specC lit '1', /* code, address expression */
specD lit '2', /* data, number used as immediate data */
specE lit '3', /* effective address, either a memory
address (specM) or register (specR) */
specM lit '4', /* memory address, variable (with or without
indexing) or [register expression] */
specR lit '5', /* general register only (not segment) */
specS lit '6', /* segment register */
specX lit '7'; /* simple variable name without indexing */
/* Modifier letters: */
declare
nomod lit '0',
modb lit '1', /* byte expression */
modw lit '2', /* word expression */
modsb lit '3', /* byte in range (-128,127) */
modd lit '4'; /* 2-word expression */
/* Segment override bytes: */
dcl
ESover lit '26h',
CSover lit '2eh',
SSover lit '36h',
DSover lit '3eh';
/* "AND"-masks for codemaco head flag */
declare
nopar$and lit '0fh', /* no of parameters, bit 0-3 */
prefix$and lit '10h'; /* prefix flag, bit 4 */
/* "OR"-masks for codemacro head flag */
declare
prefix$on lit '10h'; /* PREFIX on flag */
/* "AND"-masks for modifier-letter/range spec. byte */
declare
modletter$bit lit '07h', /* bits 0-2 */
range$spec$bit lit '0f8h', /* bits 3-7 */
modlettercount lit '0', /* bit position counters */
rangespeccount lit '3';
/* "OR"-masks for range-specifier bits */
declare
norange lit '0', /* no range specfier (bits 3-4) */
singlerange lit '08h', /* single range */
doublerange lit '10h', /* double range */
rangeand lit '18h',
number$range lit '0', /* bit 5 */
register$range lit '20h',
rangetypeand lit '20h';
$list


View File

@@ -0,0 +1,118 @@
$nolist
/*
modified 6/16/81 R. Silberstein
*/
declare
aaa1 byte external,
aad1 byte external,
aam1 byte external,
aas1 byte external,
adc11 byte external,
add11 byte external,
and10 byte external,
call3 byte external,
callf2 byte external,
cbw1 byte external,
clc1 byte external,
cld1 byte external,
cli1 byte external,
cmc1 byte external,
cmp11 byte external,
cmps2 byte external,
CMPSB1 BYTE EXTERNAL,
CMPSW1 BYTE EXTERNAL,
cwd1 byte external,
daa1 byte external,
das1 byte external,
dec3 byte external,
div2 byte external,
esc3 byte external,
hlt1 byte external,
idiv2 byte external,
imul2 byte external,
in4 byte external,
inc3 byte external,
int2 byte external,
into1 byte external,
iret1 byte external,
ja1 byte external,
jae1 byte external,
jb1 byte external,
jbe1 byte external,
jcxz1 byte external,
je1 byte external,
jg1 byte external,
jge1 byte external,
jl1 byte external,
jle1 byte external,
jmp2 byte external,
jmpf2 byte external,
jmps1 byte external,
jne1 byte external,
jno1 byte external,
jnp1 byte external,
jns1 byte external,
jo1 byte external,
jp1 byte external,
js1 byte external,
lahf1 byte external,
lds1 byte external,
les1 byte external,
lea1 byte external,
lock1 byte external,
lods2 byte external,
LODSB1 BYTE EXTERNAL,
LODSW1 BYTE EXTERNAL,
loop1 byte external,
loope1 byte external,
loopne1 byte external,
mov17 byte external,
movs2 byte external,
MOVSB1 BYTE EXTERNAL,
MOVSW1 BYTE EXTERNAL,
mul2 byte external,
neg2 byte external,
nop1 byte external,
not2 byte external,
or10 byte external,
out4 byte external,
pop4 byte external,
popf1 byte external,
push3 byte external,
pushf1 byte external,
rcl4 byte external,
rcr4 byte external,
rep1 byte external,
repe1 byte external,
repne1 byte external,
ret3 byte external,
retf3 byte external,
rol4 byte external,
ror4 byte external,
sahf1 byte external,
sal4 byte external,
sar4 byte external,
sbb11 byte external,
scas2 byte external,
SCASB1 BYTE EXTERNAL,
SCASW1 BYTE EXTERNAL,
shr4 byte external,
stc1 byte external,
std1 byte external,
sti1 byte external,
stos2 byte external,
STOSB1 BYTE EXTERNAL,
STOSW1 BYTE EXTERNAL,
sub11 byte external,
test10 byte external,
wait1 byte external,
xchg6 byte external,
xlat1 byte external,
xor10 byte external;
$list


View File

@@ -0,0 +1,57 @@
$nolist
clearcmindex: proc external;
end clearcmindex;
emit: proc external; /* emit codebytes for an instruction */
end emit;
emitdummies: proc external; /* emit dummy (NO-OPs) bytes if error */
end emitdummies;
commandtype: proc(comno,lg,pt) byte external;
dcl (comno,lg) byte,pt address;
end commandtype;
mDBNrout: proc external;
end mDBNrout;
mDBFrout: proc external;
end mDBFrout;
mDWNrout: proc external;
end mDWNrout;
mDWFrout: proc external;
end mDWFrout;
mDDFrout: proc external;
end mDDFrout;
mRELBrout: proc external;
end mRELBrout;
mRELWrout: proc external;
end mRELWrout;
mNOSEGFIXrout: proc external;
end mNOSEGFIXrout;
mSEGFIXrout: proc external;
end mSEGFIXrout;
mMODRM1rout: proc external;
end mMODRM1rout;
mMODRM2rout: proc external;
end mMODRM2rout;
mDBITrout: proc external;
end mDBITrout;
/* test if operands match instruction */
searchformatch: proc byte external;
end searchformatch;
$list


View File

@@ -0,0 +1,453 @@
$title ('CODEMACRO SUBROUTINE MODULE')
cmsubr:
do;
/*
modified 4/7/81 R. Silberstein
modified 4/13/81 R. Silberstein
modified 5/5/81 R. Silberstein
modified 9/2/81 R. Silberstein
*/
/*
This is the module to
1) test if a set of operands matches a given instruction
and
2) produce output code for matched instruction
The module interfaces the CODEOUTPUT module to
physically send code bytes to the HEX output file.
*/
$include (:f1:macro.lit)
$include (:f1:equals.lit)
$include (:f1:cmacd.lit)
$include (:f1:outp.lit)
$include (:f1:scan.ext)
$include (:f1:subr1.ext)
$INCLUDE (:F1:SUBR2.EXT)
$include (:f1:outp.ext)
$include (:f1:ermod.ext)
$include (:f1:cmsubr.x86)
$eject
dcl /* global variables */
bytevar based macroptr byte, /* variables within codemacros */
addrvar based macroptr addr,
emitbyte(80) byte, /* buffer of output codebytes */
emitindex byte, /* index of "emitbyte" */
bitcomtab(2) byte data /* legal commands within "DBIT" */
(mnumberbits,mformalbits);
$eject
/********** MICHELLANEOUS SUBROUTINES: **********/
clearcmindex: proc public;
emitindex=0;
end clearcmindex;
emit: proc public; /* emit codebytes for an instruction */
dcl i byte;
i=0ffh;
do while (i:=i+1) < emitindex;
call emitcodebyte(emitbyte(i),CSdata);
end$while;
end emit;
emitdummies: proc public; /* emit dummy (NO-OP-) bytes if error */
dcl (i,j) byte,nodum(4) byte data(2,5,6,8);
j=nooper;
if j>3 then j=3;
i=0ffh;
do while (i:=i+1) < nodum(j);
call emitcodebyte(90h,CSdata); /* 90H = NOP */
end$while;
end emitdummies;
emitsinglebyte: proc(ch); /* fill local emitbuffer with a new byte */
dcl ch byte;
if noerror then$do
emitbyte(emitindex)=ch;
emitindex=emitindex+1;
end$if;
end emitsinglebyte;
emitsingleword: proc (var); /* fill 2 new bytes into emitbuffer */
dcl var addr, byt1 byte at(.var), byt2 byte at(.var+1);
call emitsinglebyte(byt1);
call emitsinglebyte(byt2);
end emitsingleword;
incrmacroptr: proc;
macroptr=macroptr+1;
end incrmacroptr;
getoperadr: proc address;
dcl pt address;
pt=.operands(bytevar);
call incrmacroptr;
return pt;
end getoperadr;
/* recognize codemacro command type */
commandtype: proc(comno,lg,pt) byte public;
dcl (comno,lg,i) byte,pt address,ch based pt(1) byte;
i=0ffh;
do while (i:=i+1) < lg;
if comno=ch(i) then$do call incrmacroptr; return i; end$if;
end$while;
return lg;
end commandtype;
$eject
/******* CODEMACRO COMMAND SUBROUTINES: ********/
mDBNrout: proc public;
call emitsinglebyte(bytevar);
call incrmacroptr;
end mDBNrout;
mDBFrout: proc public;
dcl pt address,opr based pt operandstruc;
pt=getoperadr;
call emitsinglebyte(opr.offset);
end mDBFrout;
mDWNrout: proc public;
call emitsingleword(addrvar);
call incrmacroptr;
call incrmacroptr;
end mDWNrout;
mDWFrout: proc public;
dcl pt address,opr based pt operandstruc;
pt=getoperadr;
call emitsingleword(opr.offset);
end mDWFrout;
mDDFrout: proc public;
dcl pt address,opr based pt operandstruc;
pt=getoperadr;
if (opr.sflag and segmbit) = 0 then call errmsg(misssegminfo);
call emitsingleword(opr.offset);
call emitsingleword(opr.segment);
end mDDFrout;
mRELBrout: proc public;
dcl pt address,opr based pt operandstruc,displ addr;
pt=getoperadr;
displ=opr.offset-cip-2;
if (opr.segment <> csegvalue) or (typecalc(displ)=wrd) then$do
call errmsg(laboutofrange);
end$if;
call emitsinglebyte(displ);
IF ABSADDR (0) = SPACE THEN$DO
CALL HEX2OUT (OPR.OFFSET, .ABSADDR);
END$IF;
end mRELBrout;
mRELWrout: proc public;
dcl pt address,opr based pt operandstruc;
pt=getoperadr;
if opr.segment <> csegvalue then call errmsg(laboutofrange);
call emitsingleword(opr.offset-cip-3);
IF ABSADDR (0) = SPACE THEN$DO
CALL HEX2OUT (OPR.OFFSET, .ABSADDR);
END$IF;
end mRELWrout;
mNOSEGFIXrout: proc public;
dcl (segr,flag,segt) byte,pt address,opr based pt operandstruc;
segr=bytevar;
call incrmacroptr;
pt=getoperadr;
if (opr.baseindex and nooverridebit) = 0 then$do
flag=opr.sflag;
segt=shr(flag,segtypecount) and 3;
noerror=(segt=segr);
end$if;
end mNOSEGFIXrout;
mSEGFIXrout: proc public;
dcl pt address,opr based pt operandstruc,(segr,override,sflag) byte;
DSovertest: proc byte;
segr=shr(opr.baseindex,baseregcount) and 1;
return (((sflag and bregbit) <> 0) and (segr=1)); /* 1 = BP */
end DSovertest;
pt=getoperadr;
sflag=opr.sflag;
if (opr.baseindex and nooverridebit) = 0 then$do
segr=shr(sflag,segtypecount) and 3;
do case segr;
do; override=true; segr=ESover; end; /* ES */
do; override=true; segr=CSover; end; /* CS */
do; override=not DSovertest; segr=SSover; end; /* SS */
do; override=DSovertest; segr=DSover; end; /* DS */
end$case;
if override then call emitsinglebyte(segr);
end$if;
end mSEGFIXrout;
MODRM: proc (regfield,pt);
dcl pt address,opr based pt operandstruc,
(regfield,modfield,rmfield,dispflag,stype,sflag,segr) byte,
BASEIND BYTE,
offset addr,
displow byte at(.offset),disphigh byte at (.offset+1);
disptype: proc byte;
if segr=rcs then return 2; /* disp always 2 for variable in CS */
if offset = 0 then return 0;
return typecalc(offset);
end disptype;
indextype: proc byte;
if (sflag and iregbit) <> 0 then$do
if (sflag and bregbit) <> 0 then return 0;
return 1;
end$if;
return 2;
end indextype;
offset=opr.offset; /* pick up operand attributes */
stype=opr.stype;
sflag=opr.sflag;
segr=shr(sflag,segtypecount) and 3;
BASEIND = OPR.BASEINDEX AND (BASEREGBIT OR INDEXREGBIT);
if stype=reg then$do
rmfield=offset;
modfield=11b;
dispflag=0;
else$do
if (sflag and (iregbit or bregbit)) = 0 then$do
rmfield=110b;
modfield=0;
dispflag=2;
else$do
dispflag=disptype; /* get no of DISP bytes */
modfield=dispflag;
do case indextype;
/* both base- and index-reg */
RMFIELD = BASEIND AND (INDEXREGBIT OR BASEREGBIT);
/* index reg only */
RMFIELD = 100B OR (BASEIND AND INDEXREGBIT);
do; /* base reg only */
IF (BASEIND AND BASEREGBIT) > 0 THEN$DO
rmfield=110b;
/* mod=00 and r/m=110B is a special case */
if dispflag=0 then$do
dispflag,modfield=1;
end$if;
else$do
rmfield=111b;
end$if;
end;
end$case;
end$if;
end$if;
regfield=shl(regfield,3) and 38h;
modfield=shl(modfield,6) and 0c0h;
call emitsinglebyte(regfield or modfield or rmfield);
if dispflag > 0 then$do
call emitsinglebyte(displow);
if dispflag=2 then call emitsinglebyte(disphigh);
end$if;
end MODRM;
mMODRM1rout: proc public;
dcl regfield byte;
regfield=bytevar;
call incrmacroptr;
call MODRM(regfield,getoperadr);
end mMODRM1rout;
mMODRM2rout: proc public;
dcl regfield byte,pt address,opr based pt operandstruc;
pt=getoperadr;
regfield=opr.offset;
call MODRM(regfield,getoperadr);
end mMODRM2rout;
mDBITrout: proc public;
dcl (result,crbit) byte,bittab(8) byte data(1,2,4,8,16,32,64,128);
join: proc(numb,nobit,noshift);
dcl (numb,nobit,noshift) byte;
if noshift > 0 then numb=shr(numb,noshift);
if nobit < 8 then numb=shl(numb,8-nobit);
do while (crbit <> 0ffh) and (nobit > 0);
if (numb and 80h) <> 0 then result=result or bittab(crbit);
crbit=crbit-1;
nobit=nobit-1;
numb=shl(numb,1);
end$while;
end join;
NUMBERBITSrout: proc;
dcl nobit byte;
nobit=bytevar;
call incrmacroptr;
call join(bytevar,nobit,0);
call incrmacroptr;
end NUMBERBITSrout;
FORMBITSrout: proc;
dcl (nobit,numb) byte,pt address,opr based pt operandstruc;
nobit=bytevar;
call incrmacroptr;
pt=getoperadr;
numb=opr.offset;
call join(numb,nobit,bytevar);
call incrmacroptr;
end FORMBITSrout;
result=0;
crbit=7; /* current bit position */
do while bytevar <> mendbit; /* do until ENDBIT command */
do case commandtype(bytevar,length(bitcomtab),.bitcomtab);
call NUMBERBITSrout;
call FORMBITSrout;
do; end;
end$case;
end$while;
call incrmacroptr; /* skip ENDBIT command */
call emitsinglebyte(result);
end mDBITrout;
$eject
/********* ROUTINES TO MATCH OPERANDS TO INSTRUCTION ********/
/* test user operand against codemacro parameter */
matchsingleop: proc(opno) byte;
dcl (match,specletter,modletter,range,rangetype) byte,
(rangev1,rangev2,opno) byte,
pt address, oper based pt operandstruc;
rangetest: proc byte; /* perform rangetest */
dcl opervalue byte;
rangev1=bytevar;
call incrmacroptr;
if range=doublerange then$do
rangev2=bytevar;
call incrmacroptr;
end$if;
opervalue=oper.offset;
if range=doublerange then$do
return ((opervalue>=rangev1) and (opervalue<=rangev2));
else$do
return (opervalue=rangev1);
end$if;
end rangetest;
modlettertest: proc byte;
dcl numb addr,(styp,modbyt) byte;
styp=oper.stype;
if styp=lab then return true;
modbyt=oper.sflag and typebit;
if styp = reg then return (modbyt=modletter);
if styp = variable then
return ((modbyt=nomod) or (modbyt=modletter));
if styp=number then$do
numb=oper.offset;
do case modletter-1;
return not wrdtest(numb); /* BYTE */
return wrdtest(numb); /* WORD */
return (typecalc(numb)=byt); /* signed BYTE */
return false; /* DWORD */
end$case;
end$if;
return false;
end modlettertest;
speclettertest: proc byte;
dcl (opertype,locvalue,loctype) byte;
memtest: proc byte;
return (opertype=variable);
end memtest;
opertype=oper.stype;
locvalue=oper.offset;
loctype=oper.sflag and typebit;
do case specletter;
/* A - accumulator (AX or AL) */
return ((opertype=reg) and (locvalue=rax));
/* C - code reference,i.e. label */
return (opertype=lab);
/* D - immediate data */
return (opertype=number);
/* E - effective address, i.e. memory address or register */
return (memtest or (opertype=reg));
/* M - memory address */
return memtest;
/* R - register except segment register */
return ((opertype=reg) and (loctype <> dwrd));
/* S - segment register */
return ((opertype=reg) and (loctype = dwrd));
/* X - memory address without indexing */
return ((opertype=variable) and
((oper.sflag and (iregbit or bregbit))=0));
end$case;
end speclettertest;
specletter=bytevar; /* pick up codemacro attributes */
call incrmacroptr;
modletter=bytevar and modletter$bit;
range=bytevar and range$and;
rangetype=bytevar and rangetype$and;
call incrmacroptr;
pt=.operands(opno); /* address of current user operand */
match=true;
if range <> norange then match=rangetest;
if modletter <> 0 then match=match and modlettertest;
if match then match=speclettertest;
return match;
end matchsingleop;
/* test if operands match a specific codemacro */
matchingops: proc byte;
dcl savept address,(nopara,match,parno) byte;
savept=macroptr;
call incrmacroptr; /* macroptr=macroptr+2 */
call incrmacroptr;
nopara=bytevar; /* pick up no of parameters */
call incrmacroptr; /* advance to first formal */
if (nopara and prefix$on) <> 0 then return true; /* PREFIX */
if nopara <> nooper then$do
match=false;
else$do
match=true;
parno=0ffh;
do while (parno:=parno+1) < nopara;
match=match and matchsingleop(parno);
end$while;
end$if;
if not match then macroptr=savept;
return match;
end matchingops;
/* test if operands match instruction */
searchformatch: proc byte public;
dcl next based macroptr address;
macroptr=firstmacroptr;
do forever;
if matchingops then return true;
if next=0 then return false;
macroptr=next;
end$forever;
end searchformatch;
end$module cmsubr;


View File

@@ -0,0 +1,74 @@
$nolist
/*
modified 4/13/81 R. Silberstein
modified 9/2/81 R. Silberstein
*/
/* Error numbers: */
dcl
laboutofrange lit '22', /* label out of range */
misssegminfo lit '23'; /* missing segment info in operand */
/* Structures: */
dcl
symbolstruc lit 'struc(
length addr,
stype byte,
sflag byte,
segment addr,
offset addr,
baseindex byte)',
operandstruc lit 'symbolstruc';
/* define bits of SFLAG of structures above */
dcl
type$bit lit '7h', /* bit 0-2 */
segtypebit lit '18h', /* bit 3-4 */
segmbit lit '20h', /* bit 5 */
iregbit lit '40h', /* bit 6 */
bregbit lit '80h', /* bit 7 */
/* left-shift counters */
typecount lit '0',
segtypecount lit '3',
segmcount lit '5',
iregcount lit '6',
bregcount lit '7',
/* define bits of BASEINDEX byte of structures above */
indexregbit lit '01h', /* bit 0 */
baseregbit lit '02h', /* bit 1 */
nooverridebit lit '40h', /* bit 6 */
/* left shift counters */
indexregcount lit '0',
baseregcount lit '1',
noovercount lit '6';
/* Mischellaneous global variables: */
dcl
ABSADDR (4) BYTE EXTERNAL, /* ABSOLUTE ADDRESS FIELD */
cip addr external, /* current instruction pointer */
csegvalue addr external, /* current segment value */
noerror byte external, /* errorflag in codemacro decoding */
firstmacroptr address external, /* pointer at first codemacro */
macroptr address external, /* current pointer within macros */
fullsymbtab byte external, /* full if symboltable is full */
nooper byte external, /* no of instruction operands */
operands(4) operandstruc /* instruction operands,max 4 */
external;
$list


View File

@@ -0,0 +1,12 @@
$nolist
/* Special file devices if not diskfile : */
dcl
null lit '''Z''-''A''', /* file devices */
printer lit '''Y''-''A''',
console lit '''X''-''A''',
validdisk lit '''P''-''A''';
$list


View File

@@ -0,0 +1,7 @@
$nolist
decodeline: proc external;
end decodeline;
$list


View File

@@ -0,0 +1,355 @@
$title ('DECODE LINE MODULE')
decodel:
do;
/*
modified 3/26/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/9/81 R. Silberstein
modified 4/10/81 R. Silberstein
modified 7/24/81 R. Silberstein
*/
/*
This is the module to decode each logical sourceline.
The module takes care of all symbol definitions, and
activates the PSEUDO-module and the INSTRUCTION-module
to perform the assembly of the current non-empty source-
line.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:equals.lit)
$include (:f1:ermod.lit)
$include (:f1:subr1.ext)
$include (:f1:subr2.ext)
$include (:f1:scan.ext)
$include (:f1:print.ext)
$include (:f1:instr.ext)
$include (:f1:pseud1.ext)
$include (:f1:pseud2.ext)
$include (:f1:ermod.ext)
$include (:f1:symb.ext)
$include (:f1:exglob.ext)
$include (:f1:dline.x86)
$include (:f1:cm.ext)
saveaccum: proc;
acclensave=acclen;
call copy(acclen,.accum(0),.accumsave(0));
end saveaccum;
exchangeaccum: proc;
dcl locacclen byte,locaccum(80) byte;
locacclen=acclensave;
call copy(acclensave,.accumsave(0),.locaccum(0));
call saveaccum;
acclen=locacclen;
call copy(locacclen,.locaccum(0),.accum(0));
end exchangeaccum;
clearsymbol: proc;
CALL FILL (0, .CURRENTSYMBOL.BASEINDEX-.CURRENTSYMBOL+1, .CURRENTSYMBOL);
end clearsymbol;
pseudotype: proc(lg,ptr) byte;
dcl (lg,i,lvalue) byte,ptr address,pstable based ptr (1) byte;
if token.type <> pseudo then return lg+1;
i=0ffh;
do while (i:=i+1) < lg;
lvalue=token.value;
if lvalue=pstable(i) then$do
call scan; /* skip found pseudo */
return i;
end$if;
end$while;
return i;
end pseudotype;
/* test if symbol if double defined or "neglected" symbol */
not$doub$negl: proc(errno) byte;
dcl (errno,errfl) byte;
if pass = 0 then$do
if findsymbol(acclensave,.accumsave,.symbtabadr) then$do
call getattributes(symbtabadr,.currentsymbol);
if currentsymbol.stype <> neglected then$do
currentsymbol.stype=doubledefined;
call enterattributes(symbtabadr,.currentsymbol);
end$if;
return false;
end$if;
else$do
/* pass 1 and pass 2 */
if not findsymbol(acclensave,.accumsave,.symbtabadr) then
return false;
call getattributes(symbtabadr,.currentsymbol);
errfl=true;
if currentsymbol.stype=neglected then$do
errno=neglecterr;
else$do
if currentsymbol.stype<>doubledefined then errfl=false;
end$if;
if errfl then$do
call exchangeaccum;
call errmsg(errno);
call exchangeaccum;
return false;
end$if;
end$if;
return true;
end not$doub$negl;
newsym: proc byte; /* enter new symbol into table */
if pass=0 then$do
if not newsymbol(acclensave,.accumsave,.symbtabadr) then$do
fullsymbtab=true;
return false;
end$if;
end$if;
return true;
end newsym;
/* set up symbol attributes for label,DB,DW,DD,RS */
setupattr: proc (styp,sfla);
dcl (styp,sfla,segtyp) byte;
segtyp=shl(csegtype,segtypecount) and segtypebit;
currentsymbol.stype=styp;
if csegspec then sfla=sfla or segmbit;
currentsymbol.sflag=sfla or segtyp;
currentsymbol.segment=csegvalue;
currentsymbol.offset=cip;
end setupattr;
entatr: proc; /* enter attributes of current symbol into table */
if pass <> 2 then$do
call enter$attributes(symbtabadr,.currentsymbol);
end$if;
end entatr;
/* decode instruction */
decodeinstr: proc;
if csegtype <> rcs then$do
call errmsg(instrerr);
call skip$rest$of$line;
else$do
CALL LISTCIP;
call instruction; /* decode instruction */
end$if;
end decodeinstr;
labinstruction: proc; /* scan labelled instruction */
dcl symb based codemacroptr symbolstruc;
call saveaccum;
/* enter label into symbol table */
if not$doub$negl(doubledeflab) then$do
if newsym then$do
call setupattr(lab,wrd);
call entatr;
end$if;
end$if;
call scan; /* skip ":" */
call scan; /* allow empty instruction */
if emptyline then$do
call skip$rest$of$line;
else$do
if findcodemacro(acclen,.accum(0),.codemacroptr) then$do
call scan; /* skip codemacro */
call decode$instr;
else$do
call errmsg(illegalmacro);
end$if;
end$if;
end labinstruction;
no$ident$pseudo: proc; /* branch to correct pseudo routine */
dcl ptable(*) byte data( /* define legal unnamed pseudos */
pif,pendif,pinclude,pcseg,pdseg,psseg,peseg,porg,pdb,
pdw,pdd,prb,prs,prw,pend,ppagesize,ppagewidth,
ptitle,peject,psimform,pcodemacro,plist,pnolist,PIFLIST,PNOIFLIST,
psegfix,pnosegfix,pmodrm,prelb,prelw,pdbit,pendm);
do case pseudotype(length(ptable),.ptable); /* branch */
call IFrout;
call ENDIFrout;
call INCLUDErout;
call CSEGrout;
call DSEGrout;
call SSEGrout;
call ESEGrout;
call ORGrout;
if codemacro$flag then call db$cm$rout;
else call DBrout;
if codemacro$flag then call dw$cm$rout;
else call DWrout;
if codemacro$flag then call dd$cm$rout;
else call DDrout;
call RSrout(byt); /* RB */
call RSrout(byt); /* RS */
call RSrout(wrd); /* RW */
call ENDrout;
call PAGESIZErout;
call PAGEWIDTHrout;
call TITLErout;
call EJECTrout;
call SIMFORMrout;
call CODEMACROrout;
call LISTrout;
call NOLISTrout;
CALL IFLISTROUT;
CALL NOIFLISTROUT;
call segfix$cm$rout; /* cm */
call nosegfix$cm$rout; /* cm */
call modrm$cm$rout; /* cm */
call relb$cm$rout; /* cm */
call relw$cm$rout; /* cm */
call dbit$cm$rout; /* cm */
call end$cm$rout; /* cm */
do; /* error, illegal pseudo */
call errmsg(illegalpseudo);
call skip$rest$of$line;
end;
end$case;
end no$ident$pseudo;
identpseudo: proc(normal); /* scan a named pseudo instruction */
dcl (noerr,normal) byte,symb based codemacroptr symbolstruc;
entervar: proc(typ);
dcl typ byte;
noerr=false;
if not$doub$negl(doubledefvar) then$do
if newsym then$do
call setupattr(variable,typ);
noerr=true;
end$if;
end$if;
end entervar;
enter: proc;
if noerr then call entatr;
end enter;
/* legal pseudos: DB,DW,DD,RB,RS,RW,EQU */
dcl pseudotable(7) byte data(pdb,pdw,pdd,prb,prs,prw,pequ);
call clearsymbol; /* clear attributes of current symbol */
if normal then$do /* unormal if EQU with instruction parameter */
call saveaccum;
call scan; /* scan actual pseudo */
end$if;
do case pseudotype(length(pseudotable),.pseudotable);
do; /* DB */
call entervar(byt);
call DBrout;
call enter;
end;
do; /* DW */
call entervar(wrd);
call DWrout;
call enter;
end;
do; /* DD */
call entervar(dwrd);
call DDrout;
call enter;
end;
do; /* RB */
call entervar(byt);
call RSrout(byt);
call enter;
end;
do; /* RS */
call entervar(byt);
call RSrout(byt);
call enter;
end;
do; /* RW */
call entervar(wrd);
call RSrout(wrd);
call enter;
end;
do; /* EQU */
if not$doub$negl(doubledefsymb) then$do
if newsym then$do
call EQUrout;
else$do
call skip$rest$of$line;
end$if;
else$do
call skip$rest$of$line;
end$if;
end;
do; /* illegal pseudo instruction */
call errmsg(illegalpseudo);
call skip$rest$of$line;
end;
do; /* missing pseudo instruction */
call errmsg(missingpseudo);
call skip$rest$of$line;
end;
end$case;
end identpseudo;
decodeline: proc public;
first$item$type: proc byte;
dcl typ byte;
typ=token.type;
if typ=pseudo then return 3;
if typ=ident and nextch=':' then return 2;
if (typ=ident) or (typ=operator) then$do
if findcodemacro(acclen,.accum(0),.codemacroptr) then$do
call saveaccum;
call scan; /* skip found codemacro */
typ=token.value;
if (token.type=pseudo) and (typ=pequ) then return 5;
return 4;
end$if;
end$if;
if typ <> ident then return 0; /* error */
return 1;
end first$item$type;
if accum(0) <> cr then$do /* skip blank lines */
do case first$item$type;
do; /* error,skip rest of line */
call errmsg(first$item); /* error handler */
call skip$rest$of$line;
end;
call ident$pseudo(true); /* named pseudo instruction */
call lab$instruction; /* label (followed by instruction) */
call no$ident$pseudo; /* pseudo instruction */
call decodeinstr; /* code instruction */
call identpseudo(false); /* EQU with instruction parameter */
end$case;
end$if;
end decodeline;
end$module decodel;


View File

@@ -0,0 +1,24 @@
$nolist
dcl
pass byte external, /* current pass no, 1,2,3 */
prefix (240) byte external, /* prefix to source line */
prefixptr byte external, /* pointer to prefix buffer */
accumsave(80) byte external,
acclensave byte external,
/* Mischellaneous variables: */
fullsymbtab byte external, /* full if symboltable is full */
currentsymbol symbolstruc /* current scanned symbol */
external,
symbtabadr address external, /* pointer at symbol in table */
codemacroptr address external, /* pointer to found codemacro */
codemacro$flag byte external; /* true if building a codemacro */
$list


View File

@@ -0,0 +1,132 @@
$nolist
/*
modified 7/24/81 R. Silberstein
*/
/* Symbol types : */
dcl
reg lit '0', /* register */
pseudo lit '1', /* pseudo instruction */
code lit '2', /* instruction */
string lit '3', /* character string */
spec lit '4', /* special character */
number lit '5', /* 8 or 16 bit number */
variable lit '6',
lab lit '7', /* label */
operator lit '8', /* operator in expressions */
doubledefined lit '0f9h', /* doubled defined symbol */
neglected lit '0fah', /* neglected symb., never to be def. */
ident lit '0fbh', /* identificator, scanner output */
error lit '0fch', /* error, scanner output */
udefsymb lit '0fdh', /* undefined symbol */
symbol lit '0feh', /* variable,label or undefined symb. */
deletedsymb lit '0ffh'; /* deleted symbol (not used */
/* Symbol description values */
dcl
nil lit '0', /* no specification */
byt lit '1', /* symbol is 8-bit type */
wrd lit '2', /* symbol is 16 bit type */
dwrd lit '4'; /* symbol is 2*16 bit type
or a segment register */
/* Register values : */
dcl
rax lit '0', /* 16 bit registers */
rcx lit '1',
rdx lit '2',
rbx lit '3',
rsp lit '4',
rbp lit '5',
rsi lit '6',
rdi lit '7',
ral lit '0', /* 8 bit registers */
rcl lit '1',
rdl lit '2',
rbl lit '3',
rah lit '4',
rch lit '5',
rdh lit '6',
rbh lit '7',
res lit '0', /* segment registers */
rcs lit '1',
rss lit '2',
rds lit '3';
/* Pseudo instructions: */
dcl
pdb lit '0',
pdd lit '1',
pdw lit '2',
pif lit '3',
prs lit '4',
pend lit '5',
pequ lit '6',
porg lit '7',
pcseg lit '8',
pdbit lit '9',
pdseg lit '10',
pendm lit '11',
peseg lit '12',
prelb lit '13',
prelw lit '14',
psseg lit '15',
pendif lit '16',
pmodrm lit '17',
ptitle lit '18',
psegfix lit '19',
pinclude lit '20',
peject lit '21',
psimform lit '22',
pnosegfix lit '23',
ppagesize lit '24',
pcodemacro lit '25',
ppagewidth lit '26',
plist lit '27',
pnolist lit '28',
prb lit '29', /* added in vers. 2.0 */
prw lit '30',
PIFLIST LIT '31',
PNOIFLIST LIT '32';
/* Symbolic operators */
dcl
oshort lit '0', /* 8-bit value of expression */
oor lit '1', /* logical OR */
oxor lit '2', /* logical XOR */
oand lit '3', /* logical AND */
onot lit '4', /* logical NOT */
oeq lit '5', /* equal */
ogt lit '6', /* greater */
oge lit '7', /* greater or equal */
olt lit '8', /* less */
ole lit '9', /* less or equal */
one lit '10', /* not equal */
omod lit '11', /* arithmetic MOD */
oshl lit '12', /* shift left */
oshr lit '13', /* shift rigth */
optr lit '14', /* take type of 1. op, value of 2. */
ooffset lit '15', /* offset value of operand */
oseg lit '16', /* segment value of operand */
otype lit '17', /* type value of operand */
olength lit '18', /* length attribute of variables */
olast lit '19', /* length - 1 */
leftbracket lit '''[''',
rightbracket lit ''']''';
$list


View File

@@ -0,0 +1,8 @@
$nolist
errmsg: proc(errno) external;
dcl errno byte;
end errmsg;
$list


View File

@@ -0,0 +1,44 @@
$nolist
/*
modified 4/24/81 R. Silberstein
*/
/*
This is all assembler error numbers.
For each error number there is a
corresponding error TEXT. The texts are
defined in the module ERMOD.PLM.
*/
dcl
firstitem lit '0', /* error in first item */
missingpseudo lit '1',
illegalpseudo lit '2',
doubledefvar lit '3', /* doubled defined errors: */
doubledeflab lit '4',
illegalmacro lit '5', /* illegal instruction name */
end$of$line$err lit '6', /* garabage at end of line */
opmismatch lit '7', /* operands mismatch instruction */
illioper lit '8', /* illegal instruction operand */
missinstr lit '9', /* missing instruction */
udefsymbol lit '10', /* undefined element of expression */
pseudooperr lit '11', /* illegal pseudo operand */
nestediferr lit '12', /* nested IF illegal - ignored */
ifparerr lit '13', /* illegal IF operand - IF ignored */
missiferr lit '14', /* no matching "IF" for "ENDIF" */
neglecterr lit '15', /* neglected symbol */
doubledefsymb lit '16', /* doubled defined symbol */
instrerr lit '17', /* instruction not in code segm. */
filesynterr lit '18', /* file name syntax error */
nestedincludeerr lit '19', /* nested INCLUDE not legal */
illexprelem lit '20', /* illegal expression element */
misstypeinfo lit '21', /* missing type info in operands */
laboutofrange lit '22', /* label out of range */
misssegminfo lit '23', /* missing segment info in operand */
codemacroerr lit '24'; /* error in codemacrobuilding */
$list


View File

@@ -0,0 +1,148 @@
$title ('ERROR MESSAGE MODULE')
errorm:
do;
/*
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/7/81 R. Silberstein
modified 4/24/81 R. Silberstein
*/
/*
This is the module to perform error message
printout to the print file. The interface from
other modules goes through the subroutine
ERRMSG ( errornumber )
This routine also increments the global variable
"ERRORS" which contains the accumulated number
of errors throughout the assembly.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:ermod.lit)
$include (:f1:subr1.ext)
$include (:f1:subr2.ext)
$include (:f1:print.ext)
$include (:f1:global.ext)
/* Error messages : */
dcl
nulltext(1) byte data (0), /* dummy text */
tex00(*) byte data ('ILLEGAL FIRST ITEM',0),
tex01(*) byte data ('MISSING PSEUDO INSTRUCTION',0),
tex02(*) byte data ('ILLEGAL PSEUDO INSTRUCTION',0),
tex03(*) byte data ('DOUBLE DEFINED VARIABLE',0),
tex04(*) byte data ('DOUBLE DEFINED LABEL',0),
tex05(*) byte data ('UNDEFINED INSTRUCTION',0),
tex06(*) byte data ('GARBAGE AT END OF LINE - IGNORED',0),
tex07(*) byte data ('OPERAND(S) MISMATCH INSTRUCTION',0),
tex08(*) byte data ('ILLEGAL INSTRUCTION OPERANDS',0),
tex09(*) byte data ('MISSING INSTRUCTION',0),
tex10(*) byte data ('UNDEFINED ELEMENT OF EXPRESSION',0),
tex11(*) byte data ('ILLEGAL PSEUDO OPERAND',0),
tex12(*) byte data ('NESTED "IF" ILLEGAL - "IF" IGNORED',0),
tex13(*) byte data ('ILLEGAL "IF" OPERAND - "IF" IGNORED',0),
tex14(*) byte data ('NO MATCHING "IF" FOR "ENDIF"',0),
tex15(*) byte data ('SYMBOL ILLEGALLY FORWARD REFERENCED - ',
'NEGLECTED',0),
tex16(*) byte data ('DOUBLE DEFINED SYMBOL - ',
'TREATED AS UNDEFINED',0),
tex17(*) byte data ('INSTRUCTION NOT IN CODE SEGMENT',0),
tex18(*) byte data ('FILE NAME SYNTAX ERROR',0),
tex19(*) byte data ('NESTED INCLUDE NOT ALLOWED',0),
tex20(*) byte data ('ILLEGAL EXPRESSION ELEMENT',0),
tex21(*) byte data ('MISSING TYPE INFORMATION IN OPERAND(S)',0),
tex22(*) byte data ('LABEL OUT OF RANGE',0),
tex23(*) byte data ('MISSING SEGMENT INFORMATION IN OPERAND',0),
tex24(*) byte data ('ERROR IN CODEMACROBUILDING',0),
/* Error-message pointer table: */
texttab(*) address data (.tex00,.tex01,.tex02,.tex03,.tex04,
.tex05,.tex06,.tex07,.tex08,
.tex09,.tex10,.tex11,.tex12,.tex13,
.tex14,.tex15,.tex16,.tex17,.tex18,
.tex19,.tex20,.tex21,.tex22,.tex23,
.tex24,.nulltext);
/* Additional text strings: */
dcl
errnotext(*) byte data ('** ERROR NO:',0),
neartext(*) byte data (' ** NEAR: "',0),
spacetext(*) byte data (' ',0);
/* Table of defined error numbers: */
dcl
errtab (*) byte data (firstitem,missingpseudo,
illegalpseudo,doubledefvar,doubledeflab,
illegalmacro,end$of$line$err,opmismatch,
illioper,missinstr,udefsymbol,
pseudooperr,nestediferr,ifparerr,
missiferr,neglecterr,doubledefsymb,
instrerr,filesynterr,
nestedincludeerr,illexprelem,misstypeinfo,
laboutofrange,misssegminfo,codemacroerr);
/* Subroutines: */
printtext: proc(txt);
dcl txt address,ch based txt (1) byte,i byte;
i=0ffh;
do while ch(i:=i+1) <> 0;
call printsinglebyte(ch(i));
end$while;
end printtext;
locerrmsg: proc(erno);
dcl t address,help(5) byte,(helpstop,erno,i) byte;
errortype: proc byte;
i=0ffh;
do while (i:=i+1) < length(errtab);
if erno = errtab(i) then return i;
end$while;
return length(errtab);
end errortype;
helpstop,accum(acclen)=0;
call decout(erno,.help(0));
t=texttab(errortype); /* pick up correct error text */
call printtext(.errnotext); /* print error message line */
call printtext(.help(2));
if accum(0) <> cr then$do
call printtext(.neartext);
call printtext(.accum(0)); /* (print current token) */
CALL PRINTSINGLEBYTE ('"');
end$if;
call printtext(.spacetext);
call printtext(t);
call printcrlf;
end locerrmsg;
/* Public routine: */
errmsg: proc(erno) public;
dcl erno byte;
if print$on OR PRINTSWITCHOFF then$do
if not errorprinted then$do
errorprinted=true;
call locerrmsg(erno);
errors=errors+1;
end$if;
end$if;
end errmsg;
end$module errorm;


View File

@@ -0,0 +1,22 @@
$nolist
dcl
cip addr external, /* current instruction pointer */
csegtype byte external, /* current segment type, code,data */
csegvalue addr external, /* current segment value */
csegspec byte external, /* true if segment value specified */
dspec byte external,
curdseg addr external, /* current data segment value */
token struc( /* actual token scanned */
type byte,
descr byte,
value addr) external, /* token value */
nextch byte external, /* next input character */
acclen byte external, /* accumulator length */
accum(80) byte external, /* actual token scanned */
nooper byte external, /* no of instruction operands */
operands(4) operandstruc /* instruction operands,max 4 */
external;
$list


View File

@@ -0,0 +1,24 @@
$nolist
/*
modified 8/19/81 R. Silberstein
*/
operand: proc byte external;
end operand;
NOFORWARDOPER: PROC BYTE EXTERNAL;
END NOFORWARDOPER;
expression: proc(pt) byte external;
dcl pt address;
end expression;
noforwardexpr: proc(pt) byte external;
dcl pt address;
end noforwardexpr;
$list


View File

@@ -0,0 +1,516 @@
$title ('EXPRESSION MODULE')
expres:
do;
/*
modified 4/8/81 R. Silberstein
modified 4/24/81 R. Silberstein
modified 8/19/81 R. Silberstein
*/
/*
This is the module to evaluate expressions and
instruction operands. The entry subroutines are:
EXPRESSION (resultfield) byte
OPERAND byte
The expression subroutine evaluates a numeric or
memory expression. The "operand" routine evalates
a single instruction operand. Both routines return
FALSE if an error is found,otherwise true.
*/
$include (:f1:macro.lit)
$include (:f1:expr.x86)
$include (:f1:ermod.ext)
$include (:f1:exglob.ext)
$INCLUDE (:F1:SUBR2.EXT)
$eject
/************** global variables: ************/
dcl
maxlev lit '5', /* max no of nested parenthesis */
parlevel byte, /* current no of parenthesis level */
stck(600) byte, /* local stack within module */
savestack addr, /* save of initial entry stack */
expresserr byte, /* error flag */
noforward byte, /* true if undefined symbols to be neglected */
bracketlegal byte, /* true if bracket expression is legal */
udefflag byte; /* true if an udefined element found */
$eject
$include (:f1:bnf.tex)
$eject
/************ michellaneous subroutines: ***********/
exprexit: proc (dummy);
dcl dummy byte;
stackptr=savestack;
end exprexit;
errorexit: proc; /* return if wrong syntax */
dcl dummy byte at (.udefflag);
expresserr=false;
call exprexit(dummy);
end errorexit;
clearoperand: proc(p);
dcl p address,oper based p operandstruc;
CALL FILL (0, .OPER.BASEINDEX - .OPER + 1, P);
OPER.BASEINDEX = NOOVERRIDEBIT;
end clearoperand;
/* routine to test if current token is member of a given
set of special characters.
Entry parameters: base = exitvalue if token is 1. member of set
numbel = no of elements in set
pt = pointer to list of elements
Exit value: routine= 0ffh if token not member of list
routine= base+i if token is element i,
token is skipped */
specmember: proc (base,numbel,pt) byte;
dcl (base,numbel,i) byte,pt address,list based pt (1) byte;
i=0ffh;
do while (i:=i+1) < numbel;
if specialtoken(list(i)) then$do call scan; return base+i; end$if;
end$while;
return 0ffh;
end specmember;
/* Routine to test if current token is member of a given set of
operators.
Entry/exit : see "specmember" header */
opmember: proc(base,numbel,pt) byte;
dcl (base,numbel,i,byteval) byte,pt address,list based pt (1) byte;
if token.type = operator then$do
i=0ffh;
do while (i:=i+1) < numbel;
byteval=token.value;
if byteval=list(i) then$do call scan; return base+i; end$if;
end$while;
end$if;
return 0ffh;
end opmember;
/* test if both operands are numbers, if not, error */
numbtest: proc (ptl,ptr);
dcl (ptl,ptr) address,(left based ptl,rigth based ptr) operandstruc;
if (left.stype <> number) or (rigth.stype <> number) then
call errorexit;
end numbtest;
/* find resulting symbol type as result of an addition or a
subtraction, test if illegal types */
typefind: proc (ptl,ptr);
dcl (ptl,ptr) address,stype byte,
(left based ptl,rigth based ptr) operandstruc;
dcl err lit '07fh',
crosstab(9) byte data(number,variable,lab,variable,err,err,
lab,err,err);
typeno: proc(typ) byte;
dcl typ byte;
if typ=number then return 0;
if typ=variable then return 1;
if typ=lab then return 2;
call errorexit; /* illegal member of expression */
end typeno;
stype=crosstab(typeno(left.stype)*3+typeno(rigth.stype));
if stype=err then call errorexit;
left.length=left.length+rigth.length;
left.stype=stype;
end typefind;
/* take care of segment specification in front of variables
syntax: <over>: variable, <over>=ES/SS/DS/CS */
segover: proc(pt) byte;
dcl pt address,segreg based pt byte;
if (token.type=reg) and (token.descr=dwrd) then$do
if nextch=':' then$do
segreg=token.value;
segreg=(shl(segreg,segtypecount) and segtypebit) or segmbit;
call scan; /* skip segment register */
call scan; /* skip : */
return 0;
end$if;
end$if;
return 0ffh;
end segover;
/* create a number operator */
createnumber: proc(p,n);
dcl p address,n addr,oper based p operandstruc;
call clearoperand(.oper);
oper.stype=number;
oper.offset=n;
end createnumber;
/* get current identificator, perform symboltable lookup
set undefined-symbol-flag if symbol not defined,
treat undefined symbols as numbers */
finditem: proc (pt);
dcl pt address,left based pt operandstruc,symbptr address,i byte;
if token.type <> ident then$do
call clearoperand(.left);
left.stype=token.type;
left.sflag=token.descr;
left.offset=token.value;
else$do
if findsymbol(acclen,.accum(0),.symbptr) then$do
call getattributes(symbptr,.left);
i=left.stype;
if (i=neglected) or (i=doubledefined) or (i=udefsymb) then$do
udefflag=true;
left.stype=number;
expresserr=false;
call errmsg(udefsymbol);
end$if;
else$do
/* symbol undefined - test if it is to be "neglected" */
expresserr=false;
if noforward then$do
if not newsymbol(acclen,.accum,.symbptr) then$do
call errorexit;
end$if;
left.stype=neglected;
call enterattributes(symbptr,.left);
end$if;
call errmsg(udefsymbol);
udefflag=true;
end$if;
end$if;
call scan;
end finditem;
/* recognize the different symboltypes for the II (identicator)
subroutine */
symtyp: proc(pt) byte;
dcl pt address, left based pt operandstruc,i byte;
if specialtoken('$') then return 0;
if specialtoken('.') then return 1;
if token.type=string then$do
if (acclen > 0) and (acclen < 3 ) then return 2;
return 4; /* error */
end$if;
call finditem(.left);
i=left.stype;
if (i=pseudo) or (i=operator) or (i=spec) then return 4; /* error */
return 3;
end symtyp;
$eject
/********** subroutines for each "NON-TERMINAL" **********/
/********** in "BNF" syntax **********/
II: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,
doublebyt addr at (.accum(0)),saveb byte;
do case symtyp(.left);
do; /* $ */
left.stype=lab;
left.sflag=wrd;
left.offset=cip;
if csegspec then$do /* pick up current segment specification */
left.sflag=shl(csegtype,segtypecount) or segmbit or wrd;
left.segment=csegvalue;
end$if;
call scan; /* skip $ */
end;
do; /* . number */
call scan; /* skip . */
call finditem(.left);
if left.stype <> number then call errorexit;
left.stype=variable;
left.segment=curdseg;
left.sflag=shl(rds,segtypecount) and segtypebit;
if dspec then left.sflag=left.sflag or segmbit;
end;
do; /* string */
if acclen=1 then$do
call createnumber(.left,accum(0));
else$do
saveb=accum(0);
accum(0)=accum(1);
accum(1)=saveb;
call createnumber(.left,doublebyt);
end$if;
call scan; /* skip string */
end;
do; end; /* number,label,variable,register */
call errorexit;
end$case;
end II;
BB: proc (pt) reentrant;
dcl pt address,left based pt operandstruc;
if specialtoken('(') then$do
if (parlevel:=parlevel+1) > maxlev-1 then call errorexit;
call scan;
call EE(.left);
if not specialtoken(')') then call errorexit;
parlevel=parlevel-1;
call scan;
return;
end$if;
if specialtoken(leftbracket) then$do
if not bracketlegal then call errorexit;
bracketlegal=false;
call scan; /* skip leftbracket */
call clearoperand(.left);
left.stype=number;
if not bracketexpr(.left) then call errorexit;
return;
end$if;
call II(.left);
end BB;
FF: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,rigth operandstruc,
opertyp byte,val addr;
if (opertyp:=opmember(0,5,.(oseg,ooffset,otype,olength,olast)))
<> 0ffh then$do
call BB(.left);
do case opertyp;
do; /* SEG */
if (left.sflag and segmbit) = 0 then call errorexit;
call createnumber(.left,left.segment);
end;
do; /* OFFSET */
call createnumber(.left,left.offset);
end;
do; /* TYPE */
call createnumber(.left,left.sflag and typebit);
end;
do; /* LENGTH */
call createnumber(.left,left.length);
end;
do; /* LAST */
if (val:=left.length) = 0 then val=1;
call createnumber(.left,val-1);
end;
end$case;
else$do
call BB(.left);
do while opmember(0,1,.(optr)) <> 0ffh;
call BB(.rigth);
left.stype=rigth.stype;
left.segment=rigth.segment;
left.offset=rigth.offset;
left.baseindex=rigth.baseindex;
left.sflag=(left.sflag and typebit) or (rigth.sflag and
(not typebit));
end$while;
end$if;
end FF;
SS: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,segreg byte;
if segover(.segreg) <> 0ffh then$do
call FF(.left);
left.sflag=(left.sflag and (not segtypebit)) or segreg;
left.baseindex=left.baseindex and (not nooverridebit);
else$do
call FF(.left);
end$if;
end SS;
MM: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,opertyp byte;
if (opertyp:=specmember(0,2,.('+-'))) <> 0ffh then$do
call MM(.left);
call numbtest(.left,.left);
if opertyp=1 then$do
left.offset=-left.offset;
end$if;
else$do
call SS(.left);
end$if;
end MM;
TT: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,rigth operandstruc,
opertyp byte,(leftval,rigthval) addr;
call MM(.left);
do while (opertyp:=specmember(0,2,.('*/')) and
opmember(2,3,.(omod,oshl,oshr))) <> 0ffh;
call MM(.rigth);
call numbtest(.left,.rigth);
leftval=left.offset;
rigthval=rigth.offset;
do case opertyp;
leftval=leftval*rigthval;
leftval=leftval/rigthval;
leftval=leftval mod rigthval;
if rigthval>0 and rigthval<16 then leftval=shl(leftval,rigthval);
if rigthval>0 and rigthval<16 then leftval=shr(leftval,rigthval);
end$case;
left.offset=leftval;
end$while;
end TT;
PP: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,rigth operandstruc,
opertyp byte;
call TT(.left);
do while (opertyp:=specmember(0,2,.('+-'))) <> 0ffh;
call TT(.rigth);
call typefind(.left,.rigth);
if opertyp=0 then$do
left.offset=left.offset+rigth.offset;
else$do
left.offset=left.offset-rigth.offset;
end$if;
end$while;
end PP;
RR: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,rigth operandstruc,
opertyp byte,(leftval,rigthval) addr;
call PP(.left);
if (opertyp:=opmember(0,6,.(oeq,olt,ole,ogt,oge,one))) <> 0ffh
then$do
call PP(.rigth);
call numbtest(.left,.rigth);
leftval=left.offset;
rigthval=rigth.offset;
do case opertyp;
leftval = (leftval = rigthval);
leftval = (leftval < rigthval);
leftval = (leftval <= rigthval);
leftval = (leftval > rigthval);
leftval = (leftval >= rigthval);
leftval = (leftval <> rigthval);
end$case;
IF LEFTVAL = 0FFH THEN LEFTVAL = 0FFFFH;
left.offset=leftval;
end$if;
end RR;
NN: proc (pt) reentrant;
dcl pt address,left based pt operandstruc;
if opmember(0,1,.(onot)) <> 0ffh then$do
call NN(.left);
call numbtest(.left,.left);
left.offset=not left.offset;
else$do
call RR(.left);
end$if;
end NN;
AA: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,rigth operandstruc;
call NN(.left);
do while opmember(0,1,.(oand)) <> 0ffh;
call NN(.rigth);
call numbtest(.left,.rigth);
left.offset=left.offset and rigth.offset;
end$while;
end AA;
EE: proc (pt) reentrant;
dcl pt address,left based pt operandstruc,right operandstruc,
opertype byte;
call AA(.left);
do while (opertype:=opmember(0,2,.(oor,oxor))) <> 0ffh;
call AA(.right);
call numbtest(.left,.right);
if opertype=0 then$do
left.offset=left.offset or right.offset;
else$do
left.offset=left.offset xor right.offset;
end$if;
end$while;
end EE;
$eject
/*************** MAIN SUBROUTINES ***************/
realexpress: proc(pt);
dcl pt address,oper based pt operandstruc,
dummy byte at(.udefflag);
savestack=stackptr; /* use local stack for reentrant routines */
stackptr=.stck(length(stck));
call EE(.oper);
call exprexit(dummy);
end realexpress;
express: proc(pt) byte;
dcl pt address,oper based pt operandstruc;
expresserr=true;
udefflag=false;
parlevel=0;
call realexpress(.oper);
if udefflag then$do
oper.stype=number;
oper.sflag=byt;
oper.offset=0;
end$if;
return expresserr;
end express;
/* normal expression */
expression: proc (pt) byte public;
dcl pt address;
noforward=false;
bracketlegal=false;
return express(pt);
end expression;
/* special expression - mark all undefined symbols as "neglected" */
noforwardexpr: proc(pt) byte public;
dcl pt address;
noforward=true;
bracketlegal=false;
return express(pt);
end noforwardexpr;
OPERND: PROC BYTE;
dcl exitvalue byte,pt address,oper based pt operandstruc;
pt=.operands(nooper);
exitvalue=true;
bracketlegal=true;
exitvalue=express(pt);
if specialtoken(leftbracket) then$do
if bracketlegal then$do
call scan;
exitvalue=exitvalue and bracketexpr(pt);
else$do
exitvalue=false;
end$if;
end$if;
return exitvalue;
END OPERND;
OPERAND: PROC BYTE PUBLIC;
NOFORWARD = FALSE;
RETURN OPERND;
END OPERAND;
NOFORWARDOPER: PROC BYTE PUBLIC;
NOFORWARD = TRUE;
RETURN OPERND;
END NOFORWARDOPER;
end$module expres;


View File

@@ -0,0 +1,147 @@
$nolist
/*
modified 4/24/81 R. Silberstein
*/
/* Symbol types : */
dcl
reg lit '0', /* register */
pseudo lit '1', /* pseudo instruction */
code lit '2', /* instruction */
string lit '3', /* character string */
spec lit '4', /* special character */
number lit '5', /* 8 or 16 bit number */
variable lit '6',
lab lit '7', /* label */
operator lit '8', /* operator in expressions */
doubledefined lit '0f9h', /* doubled defined symbol */
neglected lit '0fah', /* neglected symb.,never to be def. */
ident lit '0fbh', /* identificator, scanner output */
udefsymb lit '0fdh', /* undefined symbol */
symbol lit '0feh', /* variable,label or undef. symb. */
deletedsymb lit '0ffh'; /* deleted symbol (not used */
/* Symbol description values */
dcl
nil lit '0', /* no specification */
byt lit '1', /* symbol is 8-bit type */
wrd lit '2', /* symbol is 16 bit type */
dwrd lit '4'; /* symbol is 2*16 bit type
or a segment register */
/* Register values : */
dcl
rbx lit '3',
rbp lit '5',
rsi lit '6',
rdi lit '7',
res lit '0', /* segment registers */
rcs lit '1',
rss lit '2',
rds lit '3';
/* Symbolic operators */
dcl
oshort lit '0', /* 8-bit value of expression */
oor lit '1', /* logical OR */
oxor lit '2', /* logical XOR */
oand lit '3', /* logical AND */
onot lit '4', /* logical NOT */
oeq lit '5', /* equal */
ogt lit '6', /* greater */
oge lit '7', /* greater or equal */
olt lit '8', /* less */
ole lit '9', /* less or equal */
one lit '10', /* not equal */
omod lit '11', /* arithmetic MOD */
oshl lit '12', /* shift left */
oshr lit '13', /* shift rigth */
optr lit '14', /* take type of 1. op, value of 2. */
ooffset lit '15', /* offset value of operand */
oseg lit '16', /* segment value of operand */
otype lit '17', /* type value of operand */
olength lit '18', /* length attribute of variables */
olast lit '19', /* length - 1 */
leftbracket lit '''[''',
rightbracket lit ''']''';
dcl
operandstruc lit 'struc(
length addr,
stype byte,
sflag byte,
segment addr,
offset addr,
baseindex byte)',
/* define bits of SFLAG of structures above */
type$bit lit '7h', /* bit 0-2 */
segtypebit lit '18h', /* bit 3-4 */
segmbit lit '20h', /* bit 5 */
iregbit lit '40h', /* bit 6 */
bregbit lit '80h', /* bit 7 */
/* left-shift counters */
typecount lit '0',
segtypecount lit '3',
segmcount lit '5',
iregcount lit '6',
bregcount lit '7',
/* define bits of BASEINDEX byte of structures above */
indexregbit lit '7', /* bit 0-2 */
baseregbit lit '38h', /* bit 3-5 */
nooverridebit lit '40h', /* bit 6 */
/* left shift counters */
indexregcount lit '0',
baseregcount lit '3',
noovercount lit '6';
dcl
udefsymbol lit '10'; /* undefined elem. of expression */
newsymbol: proc(lg,stradr,result) byte external;
dcl lg byte,(stradr,result) addr;
end newsymbol;
findsymbol: proc(lg,stradr,result) byte external;
dcl lg byte,(stradr,result) addr;
end findsymbol;
getattributes: proc(symbadr,dest) external;
dcl (symbadr,dest) addr;
end getattributes;
enterattributes: proc(symbadr,source) external;
dcl (symbadr,source) addr;
end enterattributes;
scan: proc external;
end scan;
specialtoken: proc (tok) byte external;
dcl tok byte;
end specialtoken;
bracketexpr: proc (pt) byte external;
dcl pt address;
end bracketexpr;
$list


View File

@@ -0,0 +1,71 @@
$nolist
/*
modified 3/28/81 R. Silberstein
modified 6/16/81 R. Silberstein
*/
outhexbyte: proc(ch) external;
dcl ch byte;
end outhexbyte;
outprintbyte: proc(ch) external;
dcl ch byte;
end outprintbyte;
outsymbolbyte: proc(ch) external;
dcl ch byte;
end outsymbolbyte;
insourcebyte: proc byte external;
end insourcebyte;
inincludebyte: proc byte external;
end inincludebyte;
opensource: proc external;
end opensource;
openinclude: proc external;
end openinclude;
openhex: proc external;
end openhex;
openprint: proc external;
end openprint;
opensymbol: proc external;
end opensymbol;
close$source: proc external;
end close$source;
rewindsource: proc external;
end rewindsource;
close$include: proc external;
end close$include;
closehex: proc external;
end closehex;
closeprint: proc external;
end closeprint;
closesymbol: proc external;
end closesymbol;
i$file$setup: proc(dev,filnam,filtyp) external;
dcl dev byte,(filnam,filtyp) addr;
end i$file$setup;
filesetup: proc byte external;
end filesetup;
$list


View File

@@ -0,0 +1,492 @@
$title('FILE AND I/O MODULE')
file:
do;
/*
modified 3/26/81 R. Silberstein
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/7/81 R. Silberstein
modified 4/16/81 R. Silberstein
modified 6/16/81 R. Silberstein
modified 9/14/81 R. Silberstein
*/
/*
This is the modules to perform BYTE i/o to
the following 5 logical devices:
source - file
include - file
hex - file
symbol - file
print - file
Each of the logical files may be assigned to the
following physical devices :
null (not legal for source and include file)
console
printer (not legal for source and include file)
disk
The module defines the following set
of public subroutines:
INSOURCEBYTE - read 1 byte from source file
ININCLUDEBYTE - read 1 byte from include file
OUTHEXBYTE (ch) - write 1 byte to hex file
OUTSYMBOLBYTE (ch) - write 1 byte to symbol file
OUTPRINTBYTE (ch) - write 1 byte to print file
OPENSOURCE - open source file
OPENINCLUDE - open include file
OPENHEX - open hex file
OPENSYMBOL - open symbol file
OPENPRINT - open print file
REWINDSOURCE - rewind source file
CLOSESOURCE - close source file
CLOSEINCLUDE - close include file
CLOSEHEX - close hex file
CLOSESYMBOL - close symbol file
CLOSEPRINT - close print file
In addition, 2 subroutines to set up the correct
file names and routing to correct physical device
are included. These are:
FILESETUP
I$FILESETUP
The "filesetup" routine sets up the source, hex, symbol
and print files by scanning the user command tail of the
program activating line. The format of the command line
is described in the program format section of the user's
manual. The routine also initiates the global string array
"SOURCENAME" with the source file name, this array to be
used later by the printout module.
The "ifilesetup" sets up the format of the include file
given by the INCLUDE command of the assembler.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:dev.lit)
$include (:f1:io.ext)
$include (:f1:subr1.ext)
$include (:f1:subr2.ext)
$INCLUDE (:F1:TEXT.EXT)
$include (:f1:global.ext)
dcl
diskunit byte,
nulltype lit '0', /* subroutine "devicetype" */
consoletype lit '1',
printertype lit '2',
disktype lit '3',
dr lit '0', /* drive code in fcb block */
fn lit '1', /* filename in fcb block */
ft lit '9', /* filetype in fcb block */
ex lit '12', /* file extension number */
s2 lit '14',
nr lit '32', /* file record number */
dollar lit '''$''',
asmdefault(3) byte data ('A86'), /* different file types */
hexdefault(3) byte data ('H86'),
lstdefault(3) byte data ('LST'),
symdefault(3) byte data ('SYM'),
sourcefile file$i$structure,
includefile file$i$structure,
hexfile file$o$structure,
printfile file$o$structure,
symbolfile file$o$structure;
clearfcb: proc(fcbpt,defaultpt);
dcl
(fcbpt,defaultpt) addr,
dest based fcbpt (1) byte;
CALL FILL (0, 33, FCBPT);
CALL FILL (' ', 8, FCBPT+FN);
call copy(3,defaultpt,.dest(ft));
end clearfcb;
clearcontrol: procedure(point,defaultptr);
dcl (point,defaultptr) addr,
x based point file$o$structure;
call clearfcb(.x.fcbblock,defaultptr);
x.disk=diskunit;
end clearcontrol;
devicetype: proc(ch) byte;
dcl ch byte;
if ch=null then return nulltype;
if ch=console then return consoletype;
if ch=printer then return printertype;
return disktype;
end devicetype;
disk$select: procedure(disk);
dcl disk byte;
if diskunit <> disk then$do
diskunit=disk;
call select$disk(diskunit);
end$if;
end disk$select;
inbyte: proc (ptr) byte;
dcl ptr addr,
x based ptr file$i$structure,
ch byte,
i addr;
i=x.bufptr;
if i=length(x.buffer) then$do
i=0;
call disk$select(x.disk);
do while i < length(x.buffer);
call SET$DMA$ADDRESS (.x.buffer(i));
IF (CH := READ$RECORD (.X.FCBBLOCK)) <> 0 THEN$DO
IF CH = 1 THEN$DO
X.BUFFER (I) = END$OF$FILE;
I = LENGTH (X.BUFFER);
ELSE$DO
CALL FILEABORT (.X, .DISKREADERRTEXT);
END$IF;
else$do
i=i+128;
end$if;
end$while;
i=0;
end$if;
ch=x.buffer(i);
x.bufptr=i+1;
return ch;
end inbyte;
FLUSHBUFFER: PROCEDURE (PTR);
DECLARE (PTR, I) ADDRESS, X BASED PTR FILE$O$STRUCTURE;
call disk$select(x.disk);
i=0;
do while i < x.bufptr;
call SET$DMA$ADDRESS (.x.buffer(i));
IF WRITE$RECORD (.X.FCBBLOCK) > 0 THEN
CALL FILEABORT (.X, .DISKWRITEERRTXT);
i=i+128;
end$while;
END FLUSHBUFFER;
outbyte: proc(ch,ptr);
dcl ch byte,
ptr addr,
x based ptr file$o$structure,
i addr;
do case devicetype(x.disk);
/* null */
do; end; /* do nothing */
/* console */
call write$console(ch);
/* printer */
call write$list(ch);
/* disk file */
do;
i=x.bufptr;
if i=length(x.buffer) then$do
CALL FLUSHBUFFER (PTR);
i=0;
end$if;
x.buffer(i)=ch;
x.bufptr=i+1;
end;
end$case;
end outbyte;
open$input: proc (ptr);
dcl ptr addr,
x based ptr file$i$structure;
x.bufptr=length(x.buffer);
call disk$select(x.disk);
IF LOW (VERSION) >= 30H THEN$DO
IF OPEN$RO$FILE (.X.FCBBLOCK) <> 0FFH THEN RETURN;
ELSE$DO
IF OPEN$FILE (.X.FCBBLOCK) <> 0FFH THEN RETURN;
END$IF;
CALL FILEABORT (.X, .OPENERRTEXT);
end open$input;
open$output: proc(ptr);
dcl ptr addr,
x based ptr file$o$structure;
if devicetype(x.disk)=disktype then$do
x.bufptr=0;
call disk$select(x.disk);
CALL delete$file(.x.fcbblock);
if create$file(.x.fcbblock) = 0ffh then
CALL FILEABORT (.X, .MAKEERRTEXT);
end$if;
end open$output;
outputclose: proc(ptr);
dcl ptr addr,
x based ptr file$o$structure;
if devicetype(x.disk)=disktype then$do
call outbyte(end$of$file,.x);
CALL FLUSHBUFFER (PTR);
IF CLOSE$FILE (.X.FCBBLOCK) = 0FFH THEN
CALL FILEABORT (.X, .CLOSEERRTEXT);
end$if;
end outputclose;
INPUT$CLOSE: PROCEDURE (PTR);
DECLARE PTR ADDRESS, X BASED PTR FILE$I$STRUCTURE;
CALL DISK$SELECT (X.DISK);
CALL SET$DMA$ADDRESS (.X.BUFFER);
IF CLOSE$FILE (.X.FCBBLOCK) THEN;
END INPUT$CLOSE;
outhexbyte: proc(ch) public;
dcl ch byte;
call outbyte(ch,.hex$file);
end outhexbyte;
outprintbyte: proc(ch) public;
dcl ch byte;
if printfile.disk=console then$do
call write$console(ch);
else$do
if error$printed then call write$console(ch);
call outbyte(ch,.printfile);
end$if;
end outprintbyte;
outsymbolbyte: proc(ch) public;
dcl ch byte;
call outbyte(ch,.symbolfile);
end outsymbolbyte;
insourcebyte: proc byte public;
return inbyte(.sourcefile);
end insourcebyte;
inincludebyte: proc byte public;
return inbyte(.includefile);
end inincludebyte;
opensource: proc public;
CALL open$input(.sourcefile);
end opensource;
openinclude: proc public;
CALL open$input(.includefile);
end openinclude;
openhex: proc public;
CALL open$output(.hexfile);
end openhex;
openprint: proc public;
CALL open$output(.printfile);
end openprint;
opensymbol: proc public;
CALL open$output(.symbolfile);
end opensymbol;
close$source: proc public;
call input$close (.source$file);
end close$source;
rewindsource: proc public;
sourcefile.fcbblock(nr)=0;
sourcefile.bufptr=length(sourcefile.buffer);
if sourcefile.fcbblock(ex) <> 0 then$do
sourcefile.fcbblock(ex)=0;
sourcefile.fcbblock(s2)=0;
CALL opensource;
end$if;
end rewindsource;
close$include: proc public;
call input$close (.include$file);
end close$include;
closehex: proc public;
call outputclose(.hexfile);
end closehex;
closeprint: proc public;
call outputclose(.printfile);
end closeprint;
closesymbol: proc public;
call outputclose(.symbolfile);
end closesymbol;
i$file$setup: proc(dev,filnam,filtyp) public;
dcl dev byte,(filnam,filtyp) addr;
call clearcontrol(.includefile,filtyp);
includefile.disk=dev;
call copy(8,filnam,.includefile.fcbblock(fn));
end i$file$setup;
filesetup: proc byte public;
dcl
ch byte, /* pick up character */
i byte, /* counter */
noleft byte, /* no of characters left in tbuff */
bpt byte, /* index of tbuff */
exitvalue byte, /* exitvalue of subroutine */
flag byte; /* program logic flag */
nextch: proc byte;
if noleft > 0 then$do
ch=tbuff(bpt);
noleft=noleft-1;
bpt=bpt+1;
else$do
ch=cr;
end$if;
return ch;
end nextch;
getdsk: procedure (p);
declare p address, dsk based p byte;
ch=upper(nextch); /* test selected disk drive */
if letter(ch) then$do
dsk=ch-'A';
if dsk > validdisk then
if dsk < console then
exitvalue = false; /* invalid drive */
else$do
exitvalue=false;
noleft=0;
end$if;
end getdsk;
exitvalue=true;
/* save current disk */
default$drive,diskunit=interrogate$disk;
/* enter user selected disk */
if fcb(dr) <> 0 then$do
call selectdisk(diskunit:=fcb(dr)-1);
end$if;
/* clear control blocks */
call clearcontrol(.sourcefile,.asmdefault);
call clearcontrol(.hexfile,.hexdefault);
call clearcontrol(.printfile,.lstdefault);
call clearcontrol(.symbolfile,.symdefault);
call copy(8,.fcb(fn),.sourcefile.fcbblock(fn));
call copy(8,.fcb(fn),.hexfile.fcbblock(fn));
call copy(8,.fcb(fn),.printfile.fcbblock(fn));
call copy(8,.fcb(fn),.symbolfile.fcbblock(fn));
if FCB (FT) <> SPACE then$do /* pick up specified source file type */
call copy(3,.fcb(ft),.sourcefile.fcbblock(ft));
end$if;
/* Move source file name to SOURCENAME */
CALL FILL (SPACE, LENGTH (SOURCENAME), .SOURCENAME);
i=0;
do while i<8 and (sourcename(i):=sourcefile.fcbblock(fn+i)) <> space;
i=i+1;
end$while;
sourcename(i)='.';
i=i+1;
call copy(3,.sourcefile.fcbblock(ft),.sourcename(i));
/* Test if file parameters */
noleft=tbuff(0);
bpt=1;
FLAG = FALSE;
IF FCB16 (1) <> SPACE THEN$DO
IF FCB16 (1) <> DOLLAR THEN$DO
EXITVALUE = FALSE;
ELSE$DO
DO WHILE (NOLEFT > 0) AND (NEXTCH <> DOLLAR);
END$WHILE;
FLAG = TRUE;
END$IF;
END$IF;
if flag then$do
/* file parameters present - pick them up */
do while noleft > 0;
if (ch:=upper(nextch)) <> space then$do
/* A-parameter */
IF CH = 'A' THEN call getdsk(.sourcefile.disk);
/* H-parameter */
ELSE IF CH = 'H' THEN call getdsk(.hexfile.disk);
/* P-parameter */
ELSE IF CH = 'P' THEN call getdsk(.printfile.disk);
/* S-parameter */
ELSE IF CH = 'S' THEN call getdsk(.symbolfile.disk);
/* F-parameter */
ELSE IF CH = 'F' THEN$DO
if (ch:=upper(nextch)) = 'I' then$do
intel$hex$on=true;
else$do
if ch= 'D' then$do
intel$hex$on=false;
else$do
exitvalue=false;
noleft=0;
endif;
endif;
END$IF;
/* error,no legal parameter */
ELSE
DO;
exitvalue=false;
noleft=0;
END$DO;
end$if;
end$while;
end$if;
printdevice=printfile.disk; /* set global printdevice flag */
SYMBOLDEVICE = SYMBOLFILE.DISK;
INCLUDE$DEFAULT = SOURCEFILE.DISK;
/* input must be from a disk file */
if devicetype(sourcefile.disk) <> disktype then$do
exitvalue=false;
end$if;
return exitvalue;
end filesetup;
end file;


View File

@@ -0,0 +1,114 @@
$nolist
/*
modified 3/28/81 R. Silberstein
modified 4/16/81 R. Silberstein
modified 7/24/81 R. Silberstein
modified 9/2/81 R. Silberstein
*/
dcl
pass byte external, /* current pass no, 1,2,3 */
/* address counters */
cip addr external, /* current instruction pointer */
csegtype byte external, /* current segment type, code,data,
stack or extra data */
csegvalue addr external, /* current segment value */
csegspec byte external, /* true if segment value specified */
escip addr external, /* current ES instruction pointer */
cscip addr external, /* current CS instruction pointer */
sscip addr external, /* current SS instruction pointer */
dscip addr external, /* current DS instruction pointer */
curcseg addr external, /* current code segment value */
curdseg addr external, /* current data segment value */
cursseg addr external, /* current stack segment value */
cureseg addr external, /* current extra segment value */
cspec byte external, /* true if code segm. value given */
dspec byte external, /* true if data segm. value given */
sspec byte external, /* true if stack segment given */
espec byte external, /* true if extra segment given */
/* print output parameters */
print$on byte external, /* on/off flag */
printswitchoff byte external, /* set/reset by NOLIST/LIST */
IFLIST BYTE EXTERNAL, /* SET/RESET BY IFLIST/NOIFLIST */
maxcol byte external, /* pagewidth */
sourcename (12) byte external, /* source file name */
savesource (12) byte external, /* source file during INLUDE file */
printdevice byte external, /* printfile device */
SYMBOLDEVICE BYTE EXTERNAL, /* SYMBOL FILE DEVICE */
title (30) byte external, /* user specified program title */
pagesize byte external, /* page size */
simform byte external, /* true if formfeed simulation */
sourcebuf (80) byte external, /* source input to be printed */
sourceptr byte external, /* source buffer pointer */
prefix (240) byte external, /* prefix to source line */
prefixptr byte external, /* pointer to prefix buffer */
ABSADDR (4) BYTE EXTERNAL, /* ABSOLUTE ADDRESS FIELD */
/* io error status */
errors addr external, /* counts no of errors */
/* scanner variables: */
token struc( /* actual token scanned */
type byte, /* token type, legal values :
reg - register
pseudo - pseudo code
string - text string
spec - special character
number - number
operator - aritmetic operator
ident - identifier */
descr byte, /* token description, legal values:
nil - no specification
byte - 8 bit type
word - 16 bit type
dword - 32 bit type */
value addr) external, /* token value */
nextch byte external, /* next input character */
acclen byte external, /* accumulator length */
accum(80) byte external, /* actual token scanned */
accumsave(80) byte external,
acclensave byte external,
eofset byte external, /* true if end-of-file found */
/* Mischellaneous variables: */
intel$hex$on byte external, /* true if INTEL hex format */
noerror byte external, /* codemacro decoding errorflag */
errorprinted byte external, /* true if an error is printed */
firstmacroptr address external, /* pointer at first codemacro */
macroptr address external, /* current pointer within macros */
fullsymbtab byte external, /* full if symboltable is full */
include$on byte external, /* true if INCLUDEfile input */
IFLEVEL BYTE EXTERNAL, /* IF-ENDIF NESTING LEVEL */
currentsymbol symbolstruc /* current scanned symbol */
external,
symbtabadr address external, /* pointer at symbol in table */
nooper byte external, /* no of instruction operands */
operands(4) operandstruc /* instruction operands,max 4 */
external,
codemacroptr address external, /* pointer to found codemacro */
help(5) byte external, /* ascii number scratch area */
i byte external, /* scratch variable */
default$drive byte external, /* default disk drive */
include$default byte external, /* default drive for include file */
codemacro$flag byte external; /* true if building a codemacro */
globalinit: procedure external; /* initiate some globals */
end globalinit;
$list


View File

@@ -0,0 +1,168 @@
$title ('GLOBAL VARIABLES')
global:
do;
/*
modified 3/28/81 R. Silberstein
modified 4/16/81 R. Silberstein
modified 4/20/81 R. Silberstein
modified 7/24/81 R. Silberstein
modified 9/2/81 R. Silberstein
*/
/*
This module defines all the global variables
of the assmembler.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$INCLUDE (:F1:SUBR2.EXT)
dcl
/* dummy structure forces contiguous storage */
glob structure (
pass byte, /* current pass no, 1,2,3 */
/* address counters */
cip addr, /* current instruction pointer */
csegtype byte, /* current segment type, code,data,
stack or extra data */
csegvalue addr, /* current segment value */
csegspec byte, /* true if segment value specified */
escip addr, /* current ES instruction pointer */
cscip addr, /* current CS instruction pointer */
sscip addr, /* current SS instruction pointer */
dscip addr, /* current DS instruction pointer */
curcseg addr, /* current code segment value */
curdseg addr, /* current data segment value */
cursseg addr, /* current stack segment value */
cureseg addr, /* current extra segment value */
cspec byte, /* true if code segment value given */
dspec byte, /* true if data segment value given */
sspec byte, /* true if stack segment value given */
espec byte, /* true if extra segment value given */
/* print output parameters */
print$on byte, /* on/off flag */
printswitchoff byte, /* set/reset by NOLIST/LIST */
IFLIST BYTE, /* SET/RESET BY IFLIST/NOIFLIST */
maxcol byte); /* pagewidth */
dcl
sourcename (12) byte public, /* source file name */
sourcestop byte, /* used to contain zero */
savesource (12) byte public, /* source file during INLUDE file */
printdevice byte public, /* print file device */
SYMBOLDEVICE BYTE PUBLIC, /* SYMBOL FILE DEVICE */
title (30) byte public, /* user specified program title */
stoptitle byte, /* used to contain zero */
pagesize byte public, /* page size */
simform byte public, /* true if formfeed is to be simulated*/
sourcebuf (80) byte public, /* copy of source input to be printed*/
sourceptr byte public, /* source buffer pointer */
prefix (240) byte public, /* prefix to source line */
prefixptr byte public, /* pointer to prefix buffer */
ABSADDR (4) BYTE PUBLIC; /* ABSOLUTE ADDRESS FIELD */
/* references to glob structure */
dcl
pass byte public at(.glob.pass),
cip addr public at(.glob.cip),
csegtype byte public at(.glob.csegtype),
csegvalue addr public at(.glob.csegvalue),
csegspec byte public at(.glob.csegspec),
escip addr public at(.glob.escip),
cscip addr public at(.glob.cscip),
sscip addr public at(.glob.sscip),
dscip addr public at(.glob.dscip),
curcseg addr public at(.glob.curcseg),
curdseg addr public at(.glob.curdseg),
cursseg addr public at(.glob.cursseg),
cureseg addr public at(.glob.cureseg),
cspec byte public at(.glob.cspec),
dspec byte public at(.glob.dspec),
sspec byte public at(.glob.sspec),
espec byte public at(.glob.espec),
print$on byte public at(.glob.print$on),
printswitchoff byte public at(.glob.printswitchoff),
IFLIST BYTE PUBLIC AT (.GLOB.IFLIST),
maxcol byte public at(.glob.maxcol);
/* io error stpublic atus */
dcl
errors addr public, /* counts no of errors */
/* scanner variables: */
token struc( /* actual token scannes */
type byte, /* token type, legal values :
reg - register
pseudo - pseudo code
string - text string
spec - special character
number - number
operator - aritmetic operator
ident - identifier */
descr byte, /* token description, legal values :
nil - no specification
byte - 8 bit type
word - 16 bit type
dword - 32 bit type */
value addr) public, /* token value */
nextch byte public, /* next input character (lookahead) */
acclen byte public, /* accumulator length */
accum(80) byte public, /* actual token scanned */
accumsave(80) byte public, /* used to save accumulator */
acclensave byte public,
eofset byte public, /* true if end-of-file found */
/* Mischellaneous variables: */
intel$hex$on byte public, /* true if INTEL hex ouput format */
noerror byte public, /* errorflag in codemacro decoding */
errorprinted byte public, /* true if an error is printed */
firstmacroptr address public, /* pointer at first codemacro */
macroptr address public, /* current pointer within macros */
fullsymbtab byte public, /* true if symboltable is full */
include$on byte public, /* true if input from INCLUDE file */
IFLEVEL BYTE PUBLIC, /* IF-ENDIF NESTING LEVEL */
currentsymbol symbolstruc /* current scanned symbol */
public,
symbtabadr address public, /* pointer at symbol in table */
nooper byte public, /* no of instruction operands */
operands(4) operandstruc /* instruction operands,max 4 */
public,
codemacroptr address public, /* pointer to found codemacro */
help(5) byte public, /* scratch area for ascii numbers */
helpstop byte,
i byte public, /* scratch variable */
default$drive byte public, /* default disk drive */
include$default byte public, /* default disk for include files */
codemacro$flag byte public; /* true if building a codemacro */
globalinit: procedure public; /* initiate some global varaiables */
stoptitle,sourcestop,helpstop=0;
pagesize=66;
fullsymbtab,intel$hex$on=false;
CALL FILL (0, SIZE (TITLE), .TITLE);
codemacro$flag=false;
end globalinit;
end$module global;


View File

@@ -0,0 +1,7 @@
$nolist
instruction: proc external;
end instruction;
$list


View File

@@ -0,0 +1,162 @@
$title ('INSTRUCTION MODULE')
instruc:
do;
/*
This is the module to decode and produce code-
output of a single instruction, possibly preceded
by a number of PREFIX-instructions.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:cmacd.lit)
$include (:f1:equals.lit)
$include (:f1:ermod.lit)
$include (:f1:subr1.ext)
$include (:f1:expr.ext)
$include (:f1:symb.ext)
$include (:f1:scan.ext)
$include (:f1:ermod.ext)
$include (:f1:cmsubr.ext)
$include (:f1:instr.x86)
$eject
dcl /* global variables */
bytevar based macroptr byte, /* byte within codemacro */
comtab(12) byte data /* legal codemacro commands */
(mdbn,mdbf,mdwn,mdwf,mddf,mrelb,mrelw,mmodrm1,mmodrm2,msegfix,
mnosegfix,mdbit);
$eject
/* generate instruction output code */
makecode: proc byte;
if (noerror:=searchformatch) then$do
/* matching operands, comput code */
do while (bytevar <> mendm) and noerror;
do case commandtype(bytevar,length(comtab),.comtab);
call mDBNrout;
call mDBFrout;
call mDWNrout;
call mDWFrout; /* typed during earthquake */
call mDDFrout;
call mRELBrout;
call mRELWrout;
call mMODRM1rout;
call mMODRM2rout;
call mSEGFIXrout;
call mNOSEGFIXrout;
call mDBITrout;
do; end; /* dummy, should not happen */
end$case;
end$while;
end$if;
if noerror then call emit; else call emitdummies;
return noerror;
end makecode;
/* scan all PREFIX instructions */
prefixscan: proc byte;
/* compute address of first codemacro */
findmacroaddr: proc;
dcl macrop based codemacroptr address;
firstmacroptr=macrop;
end findmacroaddr;
/* test if instruction is of PREFIX type */
prefixinstr: proc byte;
dcl ptr address,flag based ptr byte;
ptr=firstmacroptr+2;
return ((flag and prefix$on) <> 0);
end prefixinstr;
call findmacroaddr; /* compute pointer to first macro */
do while prefixinstr;
if makecode then; /* generate output code,always succed */
call clearcmindex;
if findcodemacro(acclen,.accum(0),.codemacroptr) then$do
call scan;
call findmacroaddr;
else$do
call errmsg(missinstr); /* missing instruction */
call skip$rest$of$line;
return false;
end$if;
end$while;
return true;
end prefixscan;
/* get all instruction operands */
getoperands: proc byte;
dcl moreoperands byte,pt address,oper based pt operandstruc,
exitvalue byte;
exitvalue=true;
nooper=0; /* clear no of operands */
moreoperands=not emptyline;
do while moreoperands;
moreoperands=false;
pt=.operands(nooper);
if not operand then$do
if oper.stype <> udefsymb then call errmsg(illioper);
exitvalue=false;
if skip$until(',') then moreoperands=true;
else$do
if specialtoken(',') then$do
call scan; /* skip "," */
if nooper < 3 then moreoperands=true;
end$if;
end$if;
nooper=nooper+1;
end$while;
return exitvalue;
end getoperands;
/* test if operands contain enough type information */
enough$type$info: proc byte;
dcl pt address,oper based pt operandstruc,(i,flag) byte;
flag=true;
i=0ffh;
do while (i:=i+1) < nooper;
pt=.operands(i);
if oper.stype=variable then$do
if (oper.sflag and typebit) = 0 then flag=false;
end$if;
end$while;
if flag then return true;
i=0ffh; /* one of operands lacks type info,check others */
do while (i:=i+1) < nooper;
pt=.operands(i);
if (oper.sflag and typebit) <> 0 then return true;
if (oper.stype=number) and (wrdtest(oper.offset)) then return true;
end$while;
return false;
end enough$type$info;
/* Module entry point: */
instruction: proc public; /* decode line in pass 1 and pass 2 */
call clearcmindex; /* clear buffer for output codes */
if prefixscan then$do
if getoperands then$do
if enough$type$info then$do
if makecode then$do
if not emptyline then$do
call errmsg(end$of$line$err);
end$if;
else$do
call errmsg(opmismatch);
end$if;
else$do
call errmsg(misstypeinfo);
call emitdummies;
end$if;
else$do
if makecode then; /* try to make code with bad operands */
end$if;
end$if;
call skip$rest$of$line;
end instruction;
end$module instruc;


View File

@@ -0,0 +1,18 @@
$nolist
dcl
acclen byte external, /* accumulator length */
accum(80) byte external, /* actual token scanned */
/* Mischellaneous variables: */
noerror byte external, /* errorflag in codemacro decoding */
firstmacroptr address external, /* pointer at first codemacro */
macroptr address external, /* current pointer within macros */
nooper byte external, /* no of instruction operands */
operands(4) operandstruc /* instruction operands,max 4 */
external,
codemacroptr address external; /* pointer to found codemacro */
$list


View File

@@ -0,0 +1,113 @@
$nolist
/* Template for all BDOS calls */
/*
modified 3/26/81 R. Silberstein
modified 9/14/81 R. Silberstein
*/
mon1: procedure(func,info) external;
declare func byte,
info address;
end mon1;
mon2: procedure(func,info) byte external;
declare func byte,
info address;
end mon2;
declare fcb(1) byte external;
declare fcb16(1) byte external;
declare tbuff(1) byte external;
declare endbuf address external;
/**************************************
* *
* B D O S Externals *
* *
**************************************/
system$reset:
procedure external;
end system$reset;
read$console:
procedure byte external;
end read$console;
write$console:
procedure (char) external;
declare char byte;
end write$console;
write$list:
procedure (char) external;
declare char byte;
end write$list;
constat:
procedure byte external;
end constat;
VERSION: PROCEDURE ADDRESS EXTERNAL;
END VERSION;
select$disk:
procedure (disk$number) external;
declare disk$number byte;
end select$disk;
open$file:
procedure (fcb$address) byte external;
declare fcb$address address;
end open$file;
OPEN$RO$FILE: PROCEDURE (FCB$ADDRESS) BYTE EXTERNAL;
DECLARE FCB$ADDRESS ADDRESS;
END OPEN$RO$FILE;
close$file:
procedure (fcb$address) byte external;
declare fcb$address address;
end close$file;
delete$file:
procedure (fcb$address) external;
declare fcb$address address;
end delete$file;
read$record:
procedure (fcb$address) byte external;
declare fcb$address address;
end read$record;
write$record:
procedure (fcb$address) byte external;
declare fcb$address address;
end write$record;
create$file:
procedure (fcb$address) byte external;
declare fcb$address address;
end create$file;
interrogate$disk:
procedure byte external;
end interrogate$disk;
set$DMA$address:
procedure (DMA$address) external;
declare DMA$address address;
end set$DMA$address;
crlf: procedure external;
end crlf;
$list


View File

@@ -0,0 +1,118 @@
$title ('INTERFACE TO CP/M I/O')
io:
do;
/*
Template for all BDOS calls
*/
/*
modified 3/26/81 R. Silberstein
modified 6/16/81 R. Silberstein
modified 9/14/81 R. Silberstein
*/
declare tbuff (80h) byte external;
mon1: procedure (func,info) external;
declare func byte;
declare info address;
end mon1;
mon2: procedure (func,info) byte external;
declare func byte;
declare info address;
end mon2;
/**************************************
* *
* B D O S Externals *
* *
**************************************/
system$reset: procedure public;
call mon1 (0,0);
end system$reset;
read$console: procedure byte public;
return mon2 (1,0);
end read$console;
write$console: procedure (char) public;
declare char byte;
call mon1 (2,char);
end write$console;
write$list: procedure (char) public;
declare char byte;
call mon1 (5,char);
end write$list;
constat: procedure byte public;
return mon2 (11,0);
end constat;
VERSION: PROCEDURE ADDRESS PUBLIC;
RETURN MON2 (12, 0);
END VERSION;
select$disk: procedure (disk$number) public;
declare disk$number byte;
call mon1 (14,disk$number);
end select$disk;
set$DMA$address: procedure (DMA$address) public;
declare DMA$address address;
call mon1 (26,DMA$address);
end set$DMA$address;
open$file: procedure (fcb$address) byte public;
declare fcb$address address;
CALL SET$DMA$ADDRESS (.TBUFF); /* FOR 1.4 SYSTEMS */
return mon2 (15,fcb$address);
end open$file;
OPEN$RO$FILE: PROCEDURE (FCB$ADDRESS) BYTE PUBLIC;
DECLARE FCB$ADDRESS ADDRESS, FCB BASED FCB$ADDRESS (32) BYTE;
FCB (6) = FCB (6) OR 80H;
RETURN OPEN$FILE (FCB$ADDRESS);
END OPEN$RO$FILE;
close$file: procedure (fcb$address) byte public;
declare fcb$address address;
return mon2 (16,fcb$address);
end close$file;
delete$file: procedure (fcb$address) public;
declare fcb$address address;
CALL mon1 (19,fcb$address);
end delete$file;
read$record: procedure (fcb$address) byte public;
declare fcb$address address;
return mon2 (20,fcb$address);
end read$record;
write$record: procedure (fcb$address) byte public;
declare fcb$address address;
return mon2 (21,fcb$address);
end write$record;
create$file: procedure (fcb$address) byte public;
declare fcb$address address;
return mon2 (22,fcb$address);
end create$file;
interrogate$disk: procedure byte public;
return mon2 (25,0);
end interrogate$disk;
crlf: procedure public;
call write$console (0dh);
call write$console (0ah);
end crlf;
end io;


View File

@@ -0,0 +1,35 @@
$nolist
$eject
/* PL/M language text macros: */
declare
lit literally 'literally',
dcl lit 'declare',
init lit 'initial',
true lit '0ffh',
false lit '0',
addr lit 'address',
struc lit 'structure',
proc lit 'procedure',
reent lit 'reentrant',
then$do lit 'then do;',
else$do lit 'end; else do;',
end$if lit 'end',
forever lit 'while true',
end$forever lit 'end',
end$while lit 'end',
end$case lit 'end',
end$do lit 'end',
end$module lit 'end',
end$proc lit 'end',
cr lit '0dh',
lf lit '0ah',
tab lit '09h',
formfeed lit '0ch',
end$of$file lit '1ah',
space lit '20h';
$list


View File

@@ -0,0 +1,186 @@
$title ('ASM86 MAIN PROGRAM')
mainp:
do;
/*
This is the main program of the CP/M 8086
assembler. This module activates the i/o
modules and goes through the source text
in 3 passes. The module then for each source
line calls the external subroutine DECODELINE
to perform assembly of each line;
*/
/*
modified 3/25/81 R. Silberstein
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/7/81 R. Silberstein
modified 4/20/81 R. Silberstein
modified 6/16/81 R. Silberstein
modified 7/24/81 R. Silberstein
modified 7/27/81 R. Silberstein
modified 8/21/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:equals.lit)
$include (:f1:dev.lit)
$include (:f1:ermod.lit)
$include (:f1:subr2.ext)
$include (:f1:io.ext)
$include (:f1:files.ext)
$include (:f1:outp.ext)
$include (:f1:scan.ext)
$include (:f1:print.ext)
$include (:f1:symb.ext)
$include (:f1:ermod.ext)
$include (:f1:mglob.ext)
$include (:f1:text.ext)
$include (:f1:dline.ext)
DECLARE ASM86 LABEL PUBLIC;
closefiles: procedure;
call close$source;
call close$print;
call close$symbol;
call close$hex;
end closefiles;
open$output$files: procedure;
CALL OPENPRINT;
CALL OPENHEX;
CALL OPENSYMBOL;
end open$output$files;
userbreak: proc byte; /* test if keyboard break from user */
if not constat then return false; /* test console status */
if readconsole then; /* skip first break key */
do forever;
call outtext(.usbreaktext); /* USER BREAK. OK (Y/N)? */
i=upper(readconsole);
call crlf;
if i = yes then return true;
if i = no then return false;
end$forever;
end userbreak;
varinit: proc;
CALL FILL (0, .PRINT$ON-.CIP, .CIP);
errors=0;
printswitchoff,includeon=false;
IFLEVEL = 0;
IFLIST = TRUE;
csegtype=rcs;
end varinit;
pass0init: proc; /* initialize pass 0 */
simform=false;
maxcol=119;
if printdevice=console then maxcol=79;
call symbinit; /* initialize symbol table */
print$on=false;
call varinit;
end pass0init;
pass1init: proc; /* initialize for pass 1 */
call varinit;
end pass1init;
pass2init: proc; /* initialize for pass 2 (last pass) */
print$on=true;
call varinit;
call emitinit;
end pass2init;
pass0terminate: proc; /* terminate pass 0 */
call outtext(.pass0text); /* End of pass 0 */
end pass0terminate;
pass1terminate: proc; /* terminate pass 1 */
print$on=false; /* dummy */
call outtext(.pass1text); /* End of pass 1 */
end pass1terminate;
pass2terminate: proc; /* terminate pass 2 (last pass) */
DECLARE USEFACT BYTE;
USEFACT = (FREEPT-.MEMORY) / ((ENDOFSYMBTAB-.MEMORY) / 100 + 1);
errorprinted=false;
call emitterminate; /* terminate hex output module */
call symbterminate; /* print symbols */
if printdevice <> console then call printterminate (USEFACT);
CALL CLOSEFILES;
call outtext(.endtext); /* END OF ASSEMBLY... */
call decout(errors,.help(0)); /* print no of errors */
call outtext(.help(2));
CALL OUTTEXT (.USEFACTOR);
CALL DECOUT (USEFACT, .HELP(0));
CALL OUTTEXT (.HELP(3));
CALL WRITECONSOLE (25H); /* % */
CALL CRLF;
end pass2terminate;
include$close: proc (flag);
declare flag byte;
if eofset and include$on then$do
call close$include;
include$on,eofset=false;
if flag then$do
call scan; /* skip EOF */
call scan; /* prepare for next source line */
end$if;
end$if;
end include$close;
ASM86:
call globalinit; /* initialize some globals */
call outtext(.asm86text); /* CP/M 8086 ASSEMBLER.... */
if not filesetup then$do
call outtext(.parerrtext); /* PARAMETER ERROR */
CALL SYSTEMRESET;
end$if;
CALL OPENSOURCE;
CALL OPENOUTPUTFILES;
pass=0ffh;
do while (pass:=pass+1) < 3;
do case pass;
call pass0init; /* pass 0 */
call pass1init; /* pass 1 */
call pass2init; /* pass 2 */
end$case;
call scaninit;
call scan;
do while not eofset;
if userbreak then$do
eofset=true;
pass=3;
else$do
errorprinted=false;
call decodeline;
call includeclose(false); /* close include file if necessary */
call scan;
call includeclose(true); /* close include file if necessary */
end$if;
end$while;
do case pass;
call pass0terminate; /* pass 0 */
call pass1terminate; /* pass 1 */
call pass2terminate; /* pass 2 */
do; end; /* do nothing if userbreak */
end$case;
end$while;
call system$reset;
end$module mainp;


View File

@@ -0,0 +1,46 @@
$nolist
/*
modified 3/28/81 R. Silberstein
*/
dcl
pass byte external, /* current pass no, 1,2,3 */
/* address counters */
cip addr external, /* current instruction pointer */
csegtype byte external, /* current segment type, code,data,
stack or extra data */
/* print output parameters */
print$on byte external, /* on/off flag */
printswitchoff byte external, /* set/reset by NOLIST/LIST */
IFLIST BYTE EXTERNAL, /* SET/RESET BY IFLIST/NOIFLIST */
maxcol byte external, /* pagewidth */
printdevice byte external, /* printfile device */
simform byte external, /* true if formfeed simulation */
/* io error status */
errors addr external, /* counts no of errors */
eofset byte external, /* true if end-of-file found */
/* Mischellaneous variables: */
errorprinted byte external, /* true if an error is printed */
fullsymbtab byte external, /* full if symboltable is full */
include$on byte external, /* true if INCLUDEfile input */
IFLEVEL BYTE EXTERNAL, /* IF-ENDIF NESTING LEVEL */
help(5) byte external, /* ascii number scratch area */
i byte external; /* scratch variable */
globalinit: procedure external; /* initiate some globals */
end globalinit;
$list


View File

@@ -0,0 +1,67 @@
$nolist
/*
modified 6/16/81 R. Silberstein
*/
dcl
push byte external,
repz byte external,
aaa byte external,
movs byte external,
pushf byte external,
MOVSB BYTE EXTERNAL,
adc byte external,
add byte external,
CMPSW BYTE EXTERNAL,
ja byte external,
dec byte external,
loopne byte external,
repnz byte external,
jae byte external,
jg byte external,
clc byte external,
iand byte external,
loopz byte external,
aas byte external,
jl byte external,
in byte external,
cli byte external,
jo byte external,
inc byte external,
lahf byte external,
icall byte external,
jne byte external,
cwd byte external,
jnbe byte external,
cmp byte external,
ior byte external,
callf byte external,
div byte external,
les byte external,
sar byte external,
jmp byte external,
hlt byte external,
lock byte external,
xchg byte external,
ret byte external,
idiv byte external,
jmpf byte external,
mul byte external,
pop byte external,
sti byte external,
inot byte external,
mov byte external,
cmps byte external,
iret byte external,
popf byte external,
imul byte external,
out byte external,
xlat byte external,
jmps byte external,
loope byte external;
$list


View File

@@ -0,0 +1,15 @@
$nolist
/* Convenient literals to compress source: */
declare
h literally 'structure(n address,l byte,p address',
opcod2 literally 'h,a(2) byte)',
opcod3 literally 'h,a(3) byte)',
opcod4 literally 'h,a(4) byte)',
opcod5 literally 'h,a(5) byte)',
opcod6 literally 'h,a(6) byte)';
$list


View File

@@ -0,0 +1,65 @@
$title ('INSTRUCTION MNEMONICS MODULE - PART 1')
mnem1:
do;
/*
modified 4/10/81 R. Silberstein
modified 6/16/81 R. Silberstein
*/
/***************** INSTRUCTION MNEMONICS *****************/
/*
This is all the instruction mnemonics for
the assembler. The mnemonics are grouped
according to the 6-bit hash value of the
mnemonics - values range from 0 to 0FH.
For each instruction, there is a pointer to
its codemacro definition.
*/
$include (:f1:mnem.lit)
$include (:f1:cmlink.ext)
/********* MNEMONICS TABLE ********/
declare
/*
* HASH VALUE (HEX) *
---------------------
*/
test opcod4 data (0,4,.test10,'TEST'), /* 0 */
push opcod4 public data (.test,4,.push3,'PUSH'),
SCASW OPCOD5 DATA (0,5,.SCASW1,'SCASW'), /* 1 */
repz opcod4 public data (.SCASW,4,.repe1,'REPZ'),
/* 2 */
aaa opcod3 public data (0,3,.aaa1,'AAA'), /* 3 */
/* 4 */
movs opcod4 public data (0,4,.movs2,'MOVS'), /* 5 */
daa opcod3 data (0,3,.daa1,'DAA'), /* 6 */
aad opcod3 data (.daa,3,.aad1,'AAD'),
pushf opcod5 public data (.aad,5,.pushf1,'PUSHF'),
MOVSB OPCOD5 PUBLIC DATA (0,5,.MOVSB1,'MOVSB'), /* 7 */
adc opcod3 public data (0,3,.adc11,'ADC'), /* 8 */
stos opcod4 data (0,4,.stos2,'STOS'), /* 9 */
LODSW OPCOD5 DATA (.STOS,5,.LODSW1,'LODSW'),
add opcod3 public data (.LODSW,3,.add11,'ADD'),
CMPSW OPCOD5 PUBLIC DATA (0,5,.CMPSW1,'CMPSW'), /* 0a */
STOSB OPCOD5 DATA (0,5,.STOSB1,'STOSB'), /* 0b */
ja opcod2 public data (.STOSB,2,.ja1,'JA'),
jb opcod2 data (0,2,.jb1,'JB'), /* 0c */
dec opcod3 public data (.jb,3,.dec3,'DEC'),
JC OPCOD2 DATA (0,2,.JB1,'JC'), /* 0D */
loopne opcod6 public data (.JC,6,.loopne1,'LOOPNE'),
/* 0e */
aam opcod3 data (0,3,.aam1,'AAM'), /* 0f */
je opcod2 data (.aam,2,.je1,'JE'),
repnz opcod5 public data (.je,5,.repne1,'REPNZ');
end mnem1;


View File

@@ -0,0 +1,74 @@
$title ('INSTRUCTION MNEMONICS MODULE - PART 2')
mnem2:
do;
/*
modified 4/10/81 R. Silberstein
modified 6/16/81 R. Silberstein
modified 7/24/81 R. Silberstein
*/
/***************** INSTRUCTION MNEMONICS *****************/
/*
This is all the instruction mnemonics for
the assembler. The mnemonics are grouped
according to the 6-bit hash value of the
mnemonics - values range from 10H to 1FH.
For each instruction, there is a pointer to
its codemacro definition.
*/
$include (:f1:mnem.lit)
$include (:f1:cmlink.ext)
/********* MNEMONICS TABLE ********/
declare
/*
* HASH VALUE (HEX) *
---------------------
*/
jae opcod3 public data (0,3,.jae1,'JAE'), /* 10 */
jbe opcod3 data (0,3,.jbe1,'JBE'), /* 11 */
jg opcod2 public data (.jbe,2,.jg1,'JG'),
lea opcod3 data (0,3,.lea1,'LEA'), /* 12 */
clc opcod3 public data (.lea,3,.clc1,'CLC'),
cmc opcod3 data (0,3,.cmc1,'CMC'), /* 13 */
cld opcod3 data (.cmc,3,.cld1,'CLD'),
iand opcod3 public data (.cld,3,.and10,'AND'),
loopz opcod5 public data (0,5,.loope1,'LOOPZ'), /* 14 */
aas opcod3 public data (0,3,.aas1,'AAS'), /* 15 */
jge opcod3 data (0,3,.jge1,'JGE'), /* 16 */
jl opcod2 public data (.jge,2,.jl1,'JL'),
sbb opcod3 data (0,3,.sbb11,'SBB'), /* 17 */
in opcod2 public data (.sbb,2,.in4,'IN'),
das opcod3 data (0,3,.das1,'DAS'), /* 18 */
cli opcod3 public data (.das,3,.cli1,'CLI'),
jna opcod3 data (0,3,.jbe1,'JNA'), /* 19 */
jo opcod2 public data (.jna,2,.jo1,'JO'),
jnb opcod3 data (0,3,.jae1,'JNB'), /* 1a */
jp opcod2 data (.jnb,2,.jp1,'JP'),
neg opcod3 data (.jp,3,.neg2,'NEG'),
inc opcod3 public data (.neg,3,.inc3,'INC'),
JNC OPCOD3 DATA (0,3,.JAE1,'JNC'), /* 1B */
esc opcod3 data (.JNC,3,.esc3,'ESC'),
jle opcod3 data (.esc,3,.jle1,'JLE'),
lahf opcod4 public data (.jle,4,.lahf1,'LAHF'),
cbw opcod3 data (0,3,.cbw1,'CBW'), /* 1c */
MOVSW OPCOD5 DATA (.CBW,5,.MOVSW1,'MOVSW'),
icall opcod4 public data (.MOVSW,4,.call3,'CALL'),
js opcod2 data (0,2,.js1,'JS'), /* 1d */
jne opcod3 public data (.js,3,.jne1,'JNE'),
jnae opcod4 data (0,4,.jb1,'JNAE'), /* 1e */
cwd opcod3 public data (.jnae,3,.cwd1,'CWD'),
jpe opcod3 data (0,3,.jp1,'JPE'), /* 1f */
jng opcod3 data (.jpe,3,.jle1,'JNG'),
jnbe opcod4 public data (.jng,4,.ja1,'JNBE');
end mnem2;


View File

@@ -0,0 +1,79 @@
$title ('INSTRUCTION MNEMONICS MODULE - PART 3')
mnem3:
do;
/*
modified 6/16/81 R. Silberstein
*/
/***************** INSTRUCTION MNEMONICS *****************/
/*
This is all the instruction mnemonics for
the assembler. The mnemonics are grouped
according to the 6-bit hash value of the
mnemonics - values range from 20H to 2FH.
For each instruction, there is a pointer to
its codemacro definition.
*/
$include (:f1:mnem.lit)
$include (:f1:cmlink.ext)
/********* MNEMONICS TABLE ********/
declare
/*
* HASH VALUE (HEX) *
---------------------
*/
isal opcod3 data (0,3,.sal4,'SAL'), /* 20 */
STOSW OPCOD5 DATA (.ISAL,5,.STOSW1,'STOSW'),
cmp opcod3 public data (.STOSW,3,.cmp11,'CMP'),
rcl opcod3 data (0,3,.rcl4,'RCL'), /* 21 */
ior opcod2 public data (.rcl,2,.or10,'OR'),
loopnz opcod6 data (0,6,.loopne1,'LOOPNZ'), /* 22 */
sahf opcod4 data (.loopnz,4,.sahf1,'SAHF'),
callf opcod5 public data (.sahf,5,.callf2,'CALLF'),
lds opcod3 data (0,3,.lds1,'LDS'), /* 23 */
div opcod3 public data (.lds,3,.div2,'DIV'),
jnge opcod4 data (0,4,.jl1,'JNGE'), /* 24 */
jnl opcod3 data (.jnge,3,.jge1,'JNL'),
jz opcod2 data (.jnl,2,.je1,'JZ'),
les opcod3 public data (.jz,3,.les1,'LES'),
/* 25 */
sar opcod3 public data (0,3,.sar4,'SAR'), /* 26 */
jno opcod3 data (0,3,.jno1,'JNO'), /* 27 */
rcr opcod3 data (.jno,3,.rcr4,'RCR'),
rep opcod3 data (.rcr,3,.rep1,'REP'),
ishl opcod3 data (.rep,3,.sal4,'SHL'),
jmp opcod3 public data (.ishl,3,.jmp2,'JMP'),
jnp opcod3 data (0,3,.jnp1,'JNP'), /* 28 */
hlt opcod3 public data (.jnp,3,.hlt1,'HLT'),
jnle opcod4 data (0,4,.jg1,'JNLE'), /* 29 */
jpo opcod3 data (.jnle,3,.jnp1,'JPO'),
lock opcod4 public data (.jpo,4,.lock1,'LOCK'),
scas opcod4 data (0,4,.scas2,'SCAS'), /* 2a */
stc opcod3 data (.scas,3,.stc1,'STC'),
sub opcod3 data (.stc,3,.sub11,'SUB'),
xchg opcod4 public data (.sub,4,.xchg6,'XCHG'),
jns opcod3 data (0,3,.jns1,'JNS'), /* 2b */
std opcod3 data (.jns,3,.std1,'STD'),
int opcod3 data (.std,3,.int2,'INT'),
ret opcod3 public data (.int,3,.ret3,'RET'),
repe opcod4 data (0,4,.repe1,'REPE'), /* 2c */
SCASB OPCOD5 DATA (.REPE,5,.SCASB1,'SCASB'),
idiv opcod4 public data (.SCASB,4,.idiv2,'IDIV'),
nop opcod3 data (0,3,.nop1,'NOP'), /* 2d */
rol opcod3 data (.nop,3,.rol4,'ROL'),
ishr opcod3 data (.rol,3,.shr4,'SHR'),
jmpf opcod4 public data (.ishr,4,.jmpf2,'JMPF'),
mul opcod3 public data (0,3,.mul2,'MUL'), /* 2e */
pop opcod3 public data (0,3,.pop4,'POP'); /* 2f */
end mnem3;


View File

@@ -0,0 +1,67 @@
$title ('INSTRUCTION MNEMONICS MODULE - PART 4')
mnem4:
do;
/*
modified 6/16/81 R. Silberstein
*/
/***************** INSTRUCTION MNEMONICS *****************/
/*
This is all the instruction mnemonics for
the assembler. The mnemonics are grouped
according to the 6-bit hash value of the
mnemonics - values range from 30H to 3FH.
For each instruction, there is a pointer to
its codemacro definition.
*/
$include (:f1:mnem.lit)
$include (:f1:cmlink.ext)
/********* MNEMONICS TABLE ********/
declare
/*
* HASH VALUE (HEX) *
---------------------
*/
sti opcod3 public data (0,3,.sti1,'STI'), /* 30 */
retf opcod4 data (0,4,.retf3,'RETF'), /* 31 */
inot opcod3 public data (.retf,3,.not2,'NOT'),
lods opcod4 data (0,4,.lods2,'LODS'), /* 32 */
jnz opcod3 data (.lods,3,.jne1,'JNZ'),
mov opcod3 public data (.jnz,3,.mov17,'MOV'),
ror opcod3 data (0,3,.ror4,'ROR'), /* 33 */
cmps opcod4 public data (.ror,4,.cmps2,'CMPS'),
LODSB OPCOD5 DATA (0,5,.LODSB1,'LODSB'), /* 34 */
iret opcod4 public data (.lodsb,4,.iret1,'IRET'),
wait opcod4 data (0,4,.wait1,'WAIT'), /* 35 */
CMPSB OPCOD5 DATA (.WAIT,5,.CMPSB1,'CMPSB'),
popf opcod4 public data (.CMPSB,4,.popf1,'POPF'),
/* 36 */
imul opcod4 public data (0,4,.imul2,'IMUL'), /* 37 */
out opcod3 public data (0,3,.out4,'OUT'), /* 38 */
retn opcod4 data (0,4,.ret3,'RETN'), /* 39 */
ixor opcod3 data (.retn,3,.xor10,'XOR'),
xlat opcod4 public data (.ixor,4,.xlat1,'XLAT'),
repne opcod5 data (0,5,.repne1,'REPNE'), /* 3a */
into opcod4 data (.repne,4,.into1,'INTO'),
loop opcod4 data (.into,4,.loop1,'LOOP'),
jmps opcod4 public data (.loop,4,.jmps1,'JMPS'),
/* 3b */
/* 3c */
/* 3d */
/* 3e */
jcxz opcod4 data (0,4,.jcxz1,'JCXZ'), /* 3f */
loope opcod5 public data (.jcxz,5,.loope1,'LOOPE');
/**************** END OF MNEMONIC TABLE ****************/
end mnem4;


View File

@@ -0,0 +1,14 @@
$nolist
emitinit: proc external;
end emitinit;
emitterminate: proc external;
end emitterminate;
emitcodebyte: proc(ch,typ) external;
dcl (ch,typ) byte;
end emitcodebyte;
$list


View File

@@ -0,0 +1,31 @@
$nolist
/* Output hex-record types: */
dcl
eoftype lit '01h', /* Common to both hex formats */
starttype lit '03h',
INTELdata lit '00h', /* INTEL hex format */
INTELsegment lit '02h',
DRcodedata lit '81h', /* Digital Research hex format */
DRdatadata lit '82h',
DRstackdata lit '83h',
DRextradata lit '84h',
DRcodesegm lit '85h',
DRdatasegm lit '86h',
DRstacksegm lit '87h',
DRextrasegm lit '88h',
CSdata lit '04h', /* Data types used inside assembler */
DSdata lit '05h',
SSdata lit '06h',
ESdata lit '07h',
CSvalue lit '08h',
DSvalue lit '09h',
SSvalue lit '0ah',
ESvalue lit '0bh';
$list


View File

@@ -0,0 +1,227 @@
$title ('HEX OUTPUT MODULE')
hexout:
do;
/*
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/9/81 R. Silberstein
*/
/*
This is the module to produce the (hex-)output
from the assembler. The interface to other modules
goes through the subroutine
EMITCODEBYTE (outputbyte,segmenttype).
This routine outputs one byte of generated code of
a specified segment type (code,data,stack,extra).
The subroutine also updates the value of the current
instruction pointer of the current segment (CIP),
and prints the output code on the print line.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:outp.lit)
$include (:f1:subr2.ext)
$include (:f1:files.ext)
$include (:f1:global.ext)
dcl
empty lit '0ffh', /* buffer empty value */
recordlimit lit '30', /* max no of bytes pr record */
loccip addr, /* local copy of instruction pointer */
startfound byte, /* true if start record sent */
gtyp byte, /* incomming byte type */
gbyt byte, /* incomming byte */
curtyp byte, /* current byte type */
sum byte, /* used to compute check sum */
buffer (35) byte, /* record buffer (RECORDLIMIT+5) */
recordlg byte at (.buffer(0)),
recordtype byte at (.buffer(3)),
offsetaddr addr at (.buffer(1)),
bufpt byte, /* buffer index */
/* Record type conversion table */
/* ( to be changed later ??? ) */
rectyp$I$tab(12) byte data
(0ffh,eoftype,0ffh,starttype,INTELdata,INTELdata,
INTELdata,INTELdata,INTELsegment,INTELsegment,INTELsegment,
INTELsegment),
rectyp$D$tab(12) byte data
(0ffh,eoftype,0ffh,starttype,DRcodedata,DRdatadata,
DRstackdata,DRextradata,DRcodesegm,DRdatasegm,DRstacksegm,
DRextrasegm);
/*********** subroutines **********/
rectyptab: procedure(n) byte;
declare n byte;
if intel$hex$on then$do
return rectyp$I$tab(n);
else$do
return rectyp$D$tab(n);
end$if;
end rectyptab;
switch$high$low: procedure(p);
declare p address, ch based p byte, (s1,s2) byte;
s1=ch;
p=p+1;
s2=ch;
ch=s1;
p=p-1;
ch=s2;
end switch$high$low;
writebyt: proc (ch);
dcl ch byte;
call outhexbyte(ch);
end writebyt;
writerecord: proc; /* write current recor to file */
call switch$high$low(.offsetaddr);
recordlg=bufpt-4;
sum=0; /* compute check sum */
i=0ffh;
do while (i:=i+1) < bufpt;
sum=sum+buffer(i);
end$while;
buffer(bufpt)=-sum; /* check sum */
call writebyt(':');
do i=0 to bufpt; /* print hexbytes to file */
call hex1out(buffer(i),.help(0));
call writebyt(help(0));
call writebyt(help(1));
end$do;
call writebyt(cr);
call writebyt(lf);
end writerecord;
enternewbyt: proc(b); /* enter a new byte into buffer */
dcl b byte;
if bufpt > recordlimit then$do /* test if record full */
call writerecord;
offsetaddr=cip;
bufpt=4;
end$if;
buffer(bufpt)=b;
bufpt=bufpt+1;
end enternewbyt;
enterinput: proc;
call enternewbyt(gbyt);
end enterinput;
eofrecord: proc; /* write end-of-file record to file */
if curtyp<>empty then call writerecord;
recordtype=rectyptab(eoftype);
offsetaddr=0;
bufpt=4;
call writerecord;
end eofrecord;
startrecord: proc; /* write a start record to file */
dcl seglow byte at (.csegvalue),seghigh byte at (.csegvalue+1),
offslow byte at (.cip),offshigh byte at (.cip+1);
if pass=2 then$do
startfound=true;
if curtyp <> empty then call writerecord;
bufpt=4;
offsetaddr=0;
recordtype=rectyptab(starttype);
if csegspec then$do
call enternewbyt(seghigh);
call enternewbyt(seglow);
else$do
call enternewbyt(0);
call enternewbyt(0);
end$if;
call enternewbyt(offshigh);
call enternewbyt(offslow);
call writerecord;
curtyp=empty;
end$if;
end startrecord;
segmbyte: proc; /* write a segment value byte to file */
if pass = 2 then$do
if curtyp <> gtyp then$do
if curtyp <> empty then call writerecord;
curtyp=gtyp;
recordtype=rectyptab(gtyp);
offsetaddr=0;
bufpt=4;
call enterinput;
else$do
call enterinput;
call writerecord;
curtyp=empty;
end$if;
end$if;
end segmbyte;
databyte: proc; /* write a data byte to file */
if pass=2 then$do
if (curtyp <> gtyp) or (loccip <> cip) then$do
if curtyp<>empty then call writerecord;
curtyp=gtyp;
recordtype=rectyptab(gtyp);
offsetaddr=cip;
bufpt=4;
end$if;
call enterinput;
call hex1out(gbyt,.prefix(prefixptr)); /* output to listing */
prefixptr=prefixptr+2;
end$if;
cip=cip+1; /* update instruction pointer */
loccip=cip;
end databyte;
emitinit: proc public;
startfound=false;
curtyp=empty;
end emitinit;
emitterminate: proc public;
call eofrecord; /* write EOF record */
end emitterminate;
emitcodebyte: proc (b,typ) public;
dcl (b,typ) byte;
gbyt=b; /* move to global variables */
gtyp=typ;
do case typ-CSdata;
do; /* CS data */
if not startfound then$do
call startrecord;
end$if;
call databyte;
end;
call databyte; /* DS data */
call databyte; /* SS data */
call databyte; /* ES data */
call segmbyte; /* CS value */
call segmbyte; /* DS value */
call segmbyte; /* SS value */
call segmbyte; /* ES value */
end$case;
end emitcodebyte;
end$module hexout;


View File

@@ -0,0 +1,9 @@
$nolist
pfind: proc (n,s,a) byte external;
dcl
n byte,
(s,a) address;
end pfind;
$list


View File

@@ -0,0 +1,298 @@
$title ('Predefined symbols')
predef:
do;
/*
modified 7/24/81 R. Silberstein
*/
/************** Module for predefined symbols ************/
/*
This module contains the tables and subroutines
for the PREDEFINED symbols of the ASM86 assembler.
The subroutine
PFIND (nochar,stringaddr,attributeaddr) byte
defines the interface to the other modules.
The routine tests if a given symbol is a predefined
symbol. If so the address of the symbol attributes
is returned.
The format of the symbol attributes is :
byte
**********************
0 * symbol type *
**********************
1 * symbol description *
**********************
2 * *
3 * symbol value *
**********************
/* Include language macros */
/* and general assembler */
/* definitions (literals). */
$include(:f1:macro.lit)
$include(:f1:equals.lit)
/* Predefined numbers: */
dcl
nbyte lit '1',
nword lit '2',
ndword lit '4';
$eject
/*
Here are the predefined symbols of
the assembler.
The symbols are grouped according to
the symbol lenghts. Moreover, each group
is sorted alphabeticly so that binary
search algorithm could be used.
*/
dcl
tok0(*) byte data(0), /* symbollength > 1 only */
tok1(*) byte data(0),
tok2(*) byte data(34,'AHALAXBHBLBPBXCHCLCSCXDBDDDHDIDL',
'DSDWDXEQESGEGTIFLELTNEORRBRSRWSISPSS'),
tok3(*) byte data(11,'ANDENDEQUMODNOTORGPTRSEGSHLSHRXOR'),
tok4(*) byte data(13,'BYTECSEGDBITDSEGENDMESEGLASTLISTRELBRELW',
'SSEGTYPEWORD'),
tok5(*) byte data(6,'DWORDEJECTENDIFMODRMSHORTTITLE'),
tok6(*) byte data(5,'IFLISTLENGTHNOLISTOFFSETSEGFIX'),
tok7(*) byte data(2,'INCLUDESIMFORM'),
tok8(*) byte data(3,'NOIFLISTNOSEGFIXPAGESIZE'),
tok9(*) byte data(2,'CODEMACROPAGEWIDTH');
/* Pointer table: */
dcl
tokpointer(*) address data(.tok0,.tok1,.tok2,.tok3,.tok4,
.tok5,.tok6,.tok7,.tok8,.tok9);
$eject
/*
This is the attribute table for
the predefined symbols.
*/
dcl
value0 byte,
value1 byte,
value2(34) struc (type byte,descr byte,value addr) data(
reg,byt,rah, reg,byt,ral, /* registers AH and AL */
reg,wrd,rax, reg,byt,rbh, /* registers AX and BH */
reg,byt,rbl, reg,wrd,rbp, /* registers BL and BP */
reg,wrd,rbx, reg,byt,rch, /* registers BX and CH */
reg,byt,rcl, reg,dwrd,rcs, /* registers CL and CS */
reg,wrd,rcx, /* register CX */
pseudo,nil,pdb, pseudo,nil,pdd, /* pseudos DB and DD */
reg,byt,rdh, reg,wrd,rdi, /* registers DH and DI */
reg,byt,rdl, reg,dwrd,rds, /* registers DL and DS */
pseudo,nil,pdw, /* pseudo DW */
reg,wrd,rdx, /* register DX */
operator,nil,oeq, /* operator EQ */
reg,dwrd,res, /* register ES */
operator,nil,oge, /* operator GE */
operator,nil,ogt, /* operator GT */
pseudo,nil,pif, /* pseudo IF */
operator,nil,ole, /* operator LE */
operator,nil,olt, /* operator LT */
operator,nil,one, /* operator NE */
operator,nil,oor, /* operator OR */
pseudo,nil,prb, /* pseudo RB */
pseudo,nil,prs, /* pseudo RS */
pseudo,nil,prw, /* pseudo RW */
reg,wrd,rsi, reg,wrd,rsp, /* registers SI and SP */
reg,dwrd,rss), /* register SS */
value3(11) struc (type byte,descr byte,value addr) data(
operator,nil,oand, /* operator AND */
pseudo,nil,pend,pseudo,nil,pequ,/* pseudos END and EQU */
operator,nil,omod, /* operator MOD */
operator,nil,onot, /* operator NOT */
pseudo,nil,porg, /* pseudo ORG */
operator,nil,optr, /* operator PTR */
operator,nil,oseg, /* operator SEG */
operator,nil,oshl, /* operator SHL */
operator,nil,oshr, /* operator SHR */
operator,nil,oxor), /* operator XOR */
value4(13) struc (type byte,descr byte,value addr) data(
number,byt,nbyte, /* 8 bit number BYTE (1) */
pseudo,nil,pcseg, /* pseudo CSEG */
pseudo,nil,pdbit, /* pseudo DBIT */
pseudo,nil,pdseg, /* pseudo DSEG */
pseudo,nil,pendm, /* pseudo ENDM */
pseudo,nil,peseg, /* pseudo ESEG */
operator,nil,olast, /* operator LAST */
pseudo,nil,plist, /* pseudo LIST */
pseudo,nil,prelb, /* pseudo RELB */
pseudo,nil,prelw, /* pseudo RELW */
pseudo,nil,psseg, /* pseudo SSEG */
operator,nil,otype, /* operator TYPE */
number,wrd,nword), /* 16 bit number WORD (2) */
value5(6) struc (type byte,descr byte,value addr) data(
number,dwrd,ndword, /* 32 bit number DWORD (4) */
pseudo,nil,peject, /* pseudo EJECT */
pseudo,nil,pendif, /* pseudo ENDIF */
pseudo,nil,pmodrm, /* pseudo MODRM */
operator,nil,oshort, /* operator SHORT */
pseudo,nil,ptitle), /* pseudo TITLE */
value6(5) struc (type byte,descr byte,value addr) data(
PSEUDO,NIL,PIFLIST, /* PSEUDO IFLIST */
operator,nil,olength, /* operator LENGTH */
pseudo,nil,pnolist, /* pseudo NOLIST */
operator,nil,ooffset, /* operator OFFSET */
pseudo,nil,psegfix), /* pseudo SEGFIX */
value7(2) struc (type byte,descr byte,value addr) data(
pseudo,nil,pinclude, /* pseudo INCLUDE */
pseudo,nil,psimform), /* pseudo SIMFORM */
value8(3) struc (type byte,descr byte,value addr) data(
PSEUDO,NIL,PNOIFLIST, /* PSEUDO NOIFLIST */
pseudo,nil,pnosegfix, /* pseudo NOSEGFIX */
pseudo,nil,ppagesize), /* pseudo PAGESIZE */
value9(2) struc (type byte,descr byte,value addr) data(
pseudo,nil,pcodemacro, /* pseudo CODEMACRO */
pseudo,nil,ppagewidth); /* pseudo PAGEWIDTH */
/* Pointer table: */
dcl
valuepointer(*) address data(.value0,.value1,.value2,.value3,.value4,
.value5,.value6,.value7,.value8,.value9);
$eject
/* Global variables and subroutines */
dcl
nochar byte,
stringaddr address,
attributeaddr address,
source based stringaddr (1) byte,
dest based attributeaddr (1)byte,
value address, /* pointer to attributes */
valuebyte based value (1) byte,
tok address, /* pointer to table strings */
tokenbyte based tok byte,
t$lookahead address, /* table string pointer */
look based t$lookahead (1) byte,
v$lookahead address, /* attribute table pointer */
noleft byte, /* no of tablestrings left */
half byte, /* noleft/2 */
i byte, /* counter */
attribute$length lit '4', /* no of bytes pr attribute */
equal lit '0', /* results of stringcompares */
greater lit '1',
less lit '2';
/* Routine to compare tablestring with given symbolstring */
compare: proc byte;
i=0ffh;
do while (i:=i+1) < nochar;
if source(i) > look(i) then
return greater;
if source(i) < look(i) then
return less;
end$while;
return equal;
end compare;
/* Recursive routine to perform binary tablesearch */
binsearch: proc byte reent;
if noleft = 0 then$do
return false;
else$do
half=noleft/2;
t$lookahead=tok+half*nochar;
v$lookahead=value+half*attributelength;
do case compare;
/* equal */
do;
value=v$lookahead; /* match found,pick up attributes */
do i=0 to attributelength-1;
dest(i)=valuebyte(i);
end$do;
return true;
end;
/* greater */
do;
tok=t$lookahead+nochar; /* test last half of table */
value=v$lookahead+attributelength;
noleft=noleft-half-1;
return binsearch;
end;
/* less */
do;
noleft=half; /* test first half of table */
return binsearch;
end;
end$case;
end$if;
end binsearch;
/*
Interface routine PFIND :
********** pfind (nochar,stringaddr,attibuteaddr) byte *********
Routine to test if a given symbol is a predefined
symbol.
entry: nochar = no of character in symbol
stringaddr = address of symbol string
attributeaddr = address to put the symbol-
attributes (if found)
exit: The routine returs TRUE if symbol found,
otherwise FALSE.
*/
pfind: proc (n,s,a) byte public;
dcl
n byte,
(s,a) address;
nochar=n; /* pick up parameters */
stringaddr=s;
attributeaddr=a;
if nochar < 10 then$do
value=valuepointer(nochar);
tok=tokpointer(nochar);
noleft=tokenbyte;
tok=tok+1;
return binsearch;
else$do
return false;
end$if;
end pfind;
/***************** end of module ***********************/
end$module predef;


View File

@@ -0,0 +1,33 @@
$nolist
/*
modified 7/27/81 R. Silberstein
*/
printsinglebyte: proc(ch) external;
dcl ch byte;
end printsinglebyte;
printcrlf: proc external;
end printcrlf;
printnewpage: proc external;
end printnewpage;
printsourceline: proc external;
end printsourceline;
printinit: proc external;
end printinit;
printterminate: proc (USEFACT) external;
DECLARE USEFACT BYTE;
end printterminate;
eject: proc external;
end eject;
$list


View File

@@ -0,0 +1,218 @@
$title ('PRINT MODULE')
print:
do;
/*
modified 3/26/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/7/81 R. Silberstein
modified 4/9/81 R. Silberstein
modified 4/16/81 R. Silberstein
modified 4/20/81 R. Silberstein
modified 5/5/81 R. Silberstein
modified 7/24/81 R. Silberstein
modified 7/27/81 R. Silberstein
modified 8/19/81 R. Silberstein
modified 9/2/81 R. Silberstein
modified 9/19/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$INCLUDE (:F1:DEV.LIT)
$include (:f1:files.ext)
$include (:f1:subr2.ext)
$include (:f1:global.ext)
$include (:f1:text.ext)
dcl
pageno byte, /* current page no */
lineno byte, /* current line no */
col byte, /* column counter */
field1start lit '6', /* start of hexoutput print */
FIELD15START LIT '19', /* START OF ABSOLUTE ADDRESS FIELD */
field2start lit '24'; /* start of source output print */
printbyt: proc(ch);
dcl ch byte;
if not asciichar(ch) then ch='#';
if ch <> lf then col=col+1;
if ch = cr then col=0;
call outprintbyte(ch);
end printbyt;
advance: proc(n); /* advance to column "n" */
dcl n byte;
do while n > col;
call printbyt(space);
end$while;
end advance;
printtext: proc(s);
dcl s address,ch based s byte;
DO WHILE CH <> 0;
CALL PRINTBYT (CH);
S = S + 1;
END;
end printtext;
printheader: proc;
COL = 0;
pageno=pageno+1;
call printtext(.initials);
call printtext(.sourcename);
call printtext(.(' ',0));
call printtext(.title);
call advance(maxcol-11);
call printtext(.pagetext);
call decout(pageno,.help(0));
call printtext(.help(1));
call printtext(.(cr,lf,cr,lf,cr,lf,0));
lineno=4;
end printheader;
/* Public routine to perform page eject */
eject: proc public;
if simform then$do
do while (lineno:=lineno+1) <= pagesize;
call printbyt(cr);
call printbyt(lf);
end$while;
else$do
call outprintbyte(formfeed);
end$if;
lineno=0;
end eject;
printnewpage: proc public;
IF LINENO > 4 THEN$DO
call eject;
call printheader;
END$IF;
end printnewpage;
incrementline: proc;
lineno = lineno + 1;
if lineno >= pagesize - 10 then call printnewpage;
end incrementline;
/* Print single byte,update column counter,
expand tabs (each 8.th column) */
print$single$byte: proc(ch) public;
dcl ch byte;
if ch=tab then$do
ch=8-((col-field2start) mod 8);
do while (ch:=ch-1) <> 0ffh;
call printbyt(space);
end$while;
else$do
call printbyt(ch);
if ch = lf then call incrementline;
end$if;
end print$single$byte;
print$crlf: proc public;
call print$single$byte(cr);
call print$single$byte(lf);
end print$crlf;
/* Print a field given by last column of field,source-
array containing ascii bytes,index of this array, and
index of last byte of source array. Before entry, the
current column position must be start of this field. */
print$field: proc (sourceindex,s,lastindex,stopcol);
dcl (sourceindex,s,lastindex) address,
stopcol byte,
source based s (1) byte,
k based sourceindex byte,
last based lastindex byte;
do while col < stopcol and k < last;
call print$single$byte(source(k));
k=k+1;
end$while;
end print$field;
print$sl: proc;
dcl (i,j) byte;
DECLARE K BYTE;
IF (PRINTDEVICE = NULL) AND NOT ERRORPRINTED THEN RETURN; /* NO NEED TO WASTE TIME HERE */
if include$on then$do
prefix(0)='=';
if prefixptr=0 then prefixptr=1;
end$if;
i,j,col=0;
/* print first field of line prefix */
call printfield(.i,.prefix(0),.prefixptr,field1start);
/* Print rest of prefix and source.
If line overflow, print rest on
following lines. */
if prefixptr-i+sourceptr > 0 then$do
do while (prefixptr-i) + (sourceptr-j) >0;
call advance(field1start);
call printfield(
.i,.prefix(0),.prefixptr,((field15start-1)/3)*3);
IF ABSADDR (0) <> SPACE THEN$DO
CALL ADVANCE (FIELD15START);
DO K = 0 TO 3;
CALL PRINTSINGLEBYTE (ABSADDR (K));
END;
END$IF;
if sourceptr-j >0 then$do
call advance(field2start);
call printfield(.j,.sourcebuf(0),.sourceptr,maxcol-1);
end$if;
call printcrlf;
end$while;
else$do
call printcrlf;
end$if;
end print$sl;
/* Public routine to print prefix and source line on printfile. */
print$source$line: proc public;
IF PRINT$ON OR ERRORPRINTED THEN CALL PRINT$SL;
CALL FILL (SPACE, PREFIXPTR, .PREFIX);
CALL FILL (SPACE, LENGTH (ABSADDR), .ABSADDR);
prefixptr,sourceptr=0;
end print$source$line;
/* Public routine to initiate print module */
printinit: proc public;
if print$on then$do
pageno=0;
LINENO = 0FFH;
CALL PRINTNEWPAGE;
end$if;
end printinit;
/* Public routine to print module information on printfile */
printterminate: proc (USEFACT) public;
DECLARE USEFACT BYTE;
if print$on then$do
CALL PRINTCRLF;
CALL PRINTCRLF;
call printtext(.endtext); /* END OF ASSEMBLY. NO OF ERRORS: */
call decout(errors,.help(0));
call printtext(.help(2));
CALL PRINTTEXT (.USEFACTOR);
CALL DECOUT (USEFACT, .HELP (0));
CALL PRINTTEXT (.HELP (3));
CALL PRINTTEXT (.(25H,CR,LF,0)); /* % */
end$if;
end printterminate;
end$module print;


View File

@@ -0,0 +1,44 @@
$nolist
/*
modified 4/9/81 R. Silberstein
*/
LISTCIP: PROCEDURE EXTERNAL;
END LISTCIP;
DBrout: proc external;
end DBrout;
DWrout: proc external;
end DWrout;
DDrout: proc external;
end DDrout;
RSrout: proc (typ) external;
dcl typ byte;
end RSrout;
CSEGrout: proc external;
end CSEGrout;
DSEGrout: proc external;
end DSEGrout;
SSEGrout: proc external;
end SSEGrout;
ESEGrout: proc external;
end ESEGrout;
ORGrout: proc external;
end ORGrout;
EQUrout: proc external;
end EQUrout;
$list


View File

@@ -0,0 +1,355 @@
$title ('PSEUDO INSTRUCTION MODULE-1')
pseudom:
do;
/*
modified 4/9/81 R. Silberstein
modified 4/15/81 R. Silberstein
modified 5/7/81 R. Silberstein
modified 7/24/81 R. Silberstein
modified 8/26/81 R. Silberstein
modified 8/19/81 R. Silberstein
*/
/*
This is the module to perform the decoding of
all legal pseudo instructions of the assembler.
There is one subroutine for each corresponding
pseudoinstruction.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:equals.lit)
$include (:f1:pseud1.x86)
$include (:f1:outp.lit)
$include (:f1:subr2.ext)
$include (:f1:print.ext)
$include (:f1:scan.ext)
$include (:f1:symb.ext)
$include (:f1:expr.ext)
$include (:f1:ermod.ext)
$include (:f1:outp.ext)
$include (:f1:global.ext)
$eject
/*************** COMMON SUBROUTINES *************/
/* routine to test if rest of line is either a comment or empty -
if not, print error message - skip rest of line */
test$emptyline: proc;
if not emptyline then call errmsg(end$of$line$err);
call skip$rest$of$line;
end test$emptyline;
/* list current address in front of printline */
listcip: proc PUBLIC;
if (prefixptr=0) and (pass <> 0) then$do
call hex2out(cip,.prefix(1));
prefixptr=6;
end$if;
end list$cip;
/* common routine for ORG and RS (reserve storage pseudo) */
orgrs: proc (disp,typ);
dcl disp addr,typ byte,oper operandstruc at (.operands(0));
if noforwardexpr(.oper) then$do /* evaluate operand */
if oper.stype=number then$do
currentsymbol.length=oper.offset;
cip=disp+oper.offset*typ; /* compute new instruction pointer */
call test$emptyline;
return;
end$if;
end$if;
/* error in expression */
call errmsg(pseudooperr);
call skip$rest$of$line;
end orgrs;
/* perform handling for CSEG,DSEG,SSEG,ESEG routines */
segmentrout: proc (p1,p2,p3,segr);
dcl segr byte,(p1,p2,p3) address,
currentseg based p1 addr,
segspecified based p2 byte,
cipsave based p3 addr,
oper operandstruc at (.operands(0)),
low byte at (.csegvalue),high byte at (.csegvalue+1);
emit: proc;
dcl datatab(4) byte data (ESvalue,CSvalue,SSvalue,DSvalue);
call emitcodebyte(high,datatab(segr));
call emitcodebyte(low,datatab(segr));
call hex2out(csegvalue,.prefix(3)); /* print value on print line */
prefixptr=7;
end emit;
do case csegtype; /* save current segment attributes */
do; cureseg=csegvalue; espec=csegspec; escip=cip; end; /* ES */
do; curcseg=csegvalue; cspec=csegspec; cscip=cip; end; /* CS */
do; cursseg=csegvalue; sspec=csegspec; sscip=cip; end; /* SS */
do; curdseg=csegvalue; dspec=csegspec; dscip=cip; end; /* DS */
end$case;
if emptyline then$do /* allow no parameter */
call skip$rest$of$line;
csegvalue=0;
csegtype=segr;
csegspec=false; /* no segment value specified */
cip=0;
return;
end$if;
if specialtoken('$') then$do /* allow "$" */
csegtype=segr; /* pick up previous values */
csegspec=segspecified;
csegvalue=currentseg;
cip=cipsave;
if csegspec then call emit;
call scan; /* skip $ */
call test$emptyline;
return;
end$if;
if expression(.oper) then$do /* operand must be expression */
if oper.stype=number then$do
csegvalue=oper.offset; /* pick up segment value */
csegtype=segr;
csegspec=true; /* value is specified */
cip=0;
call emit;
call test$emptyline;
return;
end$if;
end$if;
/* must be illegal operand */
call skip$rest$of$line;
call errmsg(pseudooperr);
end segmentrout;
/* common routine for DB,DW and DD */
DB$DW$DD$common: proc(n);
dcl(n,continue) byte,lg addr;
DECLARE EP BYTE;
item: proc(n); /* find one element of element list */
dcl (n,i,errorprinted) byte,
oper operandstruc at (.operands(0)),
low byte at (.oper.offset),
high byte at (.oper.offset+1),
seglow byte at (.oper.segment),
seghigh byte at (.oper.segment+1);
emit: proc (outputbyte);
dcl outputbyte byte,
datatab(4) byte data (ESdata,CSdata,SSdata,DSdata);
call emitcodebyte(outputbyte,datatab(csegtype));
end emit;
locexpr: proc byte;
if expression(.oper) then$do
i=oper.stype;
if (i=number) or (i=variable) or (i=lab) then return true;
end$if;
return false;
end locexpr;
DBhandle: proc;
if (token.type=string) and (acclen > 1) then$do
lg=lg+acclen-1;
i=0ffh;
do while (i:=i+1) < acclen;
call emit(accum(i));
end$while;
oper.stype=number; /* dummy */
call scan; /* skip string */
else$do
if locexpr then$do
call emit(low);
else$do
call emit(0);
call errmsg(illexprelem);
end$if;
end$if;
end DBhandle;
DWhandle: proc;
if locexpr then$do
call emit(low);
call emit(high);
else$do
call emit(0);
call emit(0);
call errmsg(illexprelem);
end$if;
end DWhandle;
DDhandle: proc;
if locexpr then$do
if oper.stype <> number then$do
if (oper.sflag and segmbit) <> 0 then$do
call emit(low);
call emit(high);
call emit(seglow);
call emit(seghigh);
return;
else$do
call errmsg(misssegminfo);
end$if;
end$if;
end$if;
do i=0 to 3; call emit(0); end$do; /* dummy */
call errmsg(illexprelem);
end DDhandle;
/* ITEM main program */
lg=lg+1;
do case n;
call DBhandle;
call DWhandle;
call DDhandle;
end$case;
if specialtoken(',') then$do
call scan;
continue=true;
else$do
if emptyline then$do
call skip$rest$of$line;
else$do
CALL ERRMSG (ENDOFLINEERR);
CALL SKIPRESTOFLINE;
end$if;
end$if;
end item;
/* DB$DW$DD$common main program */
CALL LISTCIP;
EP = FALSE;
lg=0;
continue=true;
do while continue;
errorprinted=false;
continue=false;
call item(n);
EP = EP OR ERRORPRINTED;
end$while;
currentsymbol.length=lg;
ERRORPRINTED = EP; /* SO SOURCE LINE IS ECHOED IF ERROR */
end DB$DW$DD$common;
$eject
/***************** PSEUDO SUBROUTINES **************/
DBrout: proc public;
call DB$DW$DD$common(0);
end DBrout;
DWrout: proc public;
call DB$DW$DD$common(1);
end DWrout;
DDrout: proc public;
call DB$DW$DD$common(2);
end DDrout;
RSrout: proc (typ) public;
dcl typ byte;
call listcip; /* list current address on printline */
call orgrs(cip,typ); /* cip = cip + typ * expression */
end RSrout;
CSEGrout: proc public;
call segmentrout(.curcseg,.cspec,.cscip,rcs);
end CSEGrout;
DSEGrout: proc public;
call segmentrout(.curdseg,.dspec,.dscip,rds);
end DSEGrout;
SSEGrout: proc public;
call segmentrout(.cursseg,.sspec,.sscip,rss);
end SSEGrout;
ESEGrout: proc public;
call segmentrout(.cureseg,.espec,.escip,res);
end ESEGrout;
ORGrout: proc public;
call orgrs(0,byt); /* cip = 0 + expression */
end ORGrout;
EQUrout: proc public;
dcl oper operandstruc at (.operands(0)),
macdefpt based codemacroptr address;
codempossible: proc byte;
return (nextch=cr or nextch=';');
end codempossible;
do case pass;
do; /* pass 0 */
if codempossible and
findcodemacro(acclen,.accum(0),.codemacroptr) then$do
currentsymbol.stype=code;
call enterattributes(symbtabadr,.currentsymbol);
if not newmacro(acclensave,.accumsave,macdefpt) then
fullsymbtab=true;
else$do
nooper=0; /* find normal operand expression */
IF NOFORWARDOPER THEN$DO
call enterattributes(symbtabadr,.operands(0));
call skip$rest$of$line;
else$do
currentsymbol.stype=udefsymb;
call enterattributes(symbtabadr,.currentsymbol);
call skip$rest$of$line;
end$if;
end$if;
end;
do; /* pass 1 */
if currentsymbol.stype <> code then$do /* update symbol value */
nooper=0;
IF NOFORWARDOPER THEN$DO
call enterattributes(symbtabadr,.operands(0));
end$if;
end$if;
call skip$rest$of$line;
end;
do; /* pass 2 - scan to produce possible errormessages */
if currentsymbol.stype=code then$do
call scan;
else$do
nooper=0;
IF NOT NOFORWARDOPER OR (CURRENTSYMBOL.STYPE = ERROR) THEN$DO
call errmsg(pseudooperr);
call skip$rest$of$line; /* only one error message */
else$do
prefixptr=7;
call hex2out(oper.offset,.prefix(3));
end$if;
end$if;
call test$emptyline;
end;
end$case;
end EQUrout;
end$module pseudom;


View File

@@ -0,0 +1,16 @@
$nolist
/*
modified 4/24/81 R. Silberstein
*/
dcl
end$of$line$err lit '6', /* garabage at end of line */
pseudooperr lit '11', /* illegal pseudo operand */
illexprelem lit '20', /* illegal expression element */
misssegminfo lit '23'; /* missing segment info in operand */
$list


View File

@@ -0,0 +1,49 @@
$nolist
/*
modified 7/24/81 R. Silberstein
*/
IFrout: proc external;
end IFrout;
ENDIFrout: proc external;
end ENDIFrout;
INCLUDErout: proc external;
end INCLUDErout;
ENDrout: proc external;
end ENDrout;
PAGESIZErout: proc external;
end PAGESIZErout;
PAGEWIDTHrout: proc external;
end PAGEWIDTHrout;
TITLErout: proc external;
end TITLErout;
EJECTrout: proc external;
end EJECTrout;
SIMFORMrout: proc external;
end SIMFORMrout;
LISTrout: proc external;
end LISTrout;
NOLISTrout: proc external;
end NOLISTrout;
IFLISTROUT: PROC EXTERNAL;
END IFLISTROUT;
NOIFLISTROUT: PROC EXTERNAL;
END NOIFLISTROUT;
$list


View File

@@ -0,0 +1,290 @@
$title ('PSEUDO INSTRUCTION MODULE-2')
pseudom:
do;
/*
modified 3/28/81 R. Silberstein
modified 4/1/81 R. Silberstein
modified 4/9/81 R. Silberstein
modified 4/15/81 R. Silberstein
modified 7/24/81 R. Silberstein
modified 9/2/81 R. Silberstein
*/
/*
This is the module to perform the decoding of
all legal pseudo instructions of the assembler.
There is one subroutine for each corresponding
pseudoinstruction.
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:equals.lit)
$include (:f1:ermod.lit)
$include (:f1:files.ext)
$include (:f1:subr1.ext)
$include (:f1:subr2.ext)
$include (:f1:scan.ext)
$include (:f1:print.ext)
$include (:f1:expr.ext)
$include (:f1:ermod.ext)
$include (:f1:pseud2.x86)
$eject
/*************** COMMON SUBROUTINES *************/
/* routine to test if rest of line is either a comment or empty -
if not, print error message - skip rest of line */
test$emptyline: proc;
if not emptyline then call errmsg(end$of$line$err);
call skip$rest$of$line;
end test$emptyline;
/* perform handling for PAGEWIDTH- and PAGESIZE-routine */
sizewidth: proc(p);
dcl oper operandstruc at (.operands(0)),p address,dest based p byte;
if pass=0 then$do
call skip$rest$of$line; /* do nothing in pass 0 */
else$do
if expression(.oper) then$do
if oper.stype = number then$do
dest=oper.offset;
call test$emptyline;
return;
end$if;
end$if;
call errmsg(pseudooperr);
call skip$rest$of$line;
end$if;
end sizewidth;
$eject
/***************** PSEUDO SUBROUTINES **************/
IFrout: proc public;
DECLARE IFNESTMAX LIT '5'; /* MAX LEVEL OF IF NEXTING */
dcl oper operandstruc at (.operands(0)),bool byte;
IFerr: proc;
call errmsg(ifparerr);
call skip$rest$of$line;
end IFerr;
skip$until$ENDIF: proc;
dcl pseudotype byte at (.token.value);
DECLARE LOCIFLEVEL BYTE;
DECLARE TEMP BYTE;
LOCIFLEVEL = IFLEVEL + 1;
IF PRINTON AND NOT IFLIST THEN$DO
CALL PRINTSOURCELINE;
PRINTON = FALSE;
TEMP = TRUE;
ELSE$DO
TEMP = FALSE;
END$IF;
do while not eofset; /* (forever) */
call scan;
IF TOKEN.TYPE = PSEUDO THEN$DO
IF PSEUDOTYPE = PENDIF THEN$DO
LOCIFLEVEL = LOCIFLEVEL - 1;
IF LOCIFLEVEL = 0 THEN$DO
CALL SCAN;
CALL TESTEMPTYLINE;
IF TEMP THEN PRINTON = TRUE;
RETURN;
END$IF;
ELSE$DO
IF PSEUDOTYPE = PIF THEN$DO
LOCIFLEVEL = LOCIFLEVEL + 1;
END$IF;
END$IF;
END$IF;
call skip$rest$of$line;
end$while;
end skip$until$ENDIF;
IF IFLEVEL = IFNESTMAX THEN$DO
call errmsg(nestediferr);
call skip$rest$of$line;
else$do
if not noforwardexpr(.oper) then$do
call IFerr;
else$do
if oper.stype <> number then$do
call IFerr;
else$do
bool=oper.offset;
if bool <> 0 then$do
IFLEVEL = IFLEVEL + 1;
call test$emptyline;
else$do
call skip$rest$of$line;
call skip$until$ENDIF;
end$if;
end$if;
end$if;
end$if;
end IFrout;
ENDIFrout: proc public;
IF IFLEVEL > 0 THEN$DO
IFLEVEL = IFLEVEL - 1;
call test$emptyline;
else$do
call errmsg(missiferr);
call skip$rest$of$line;
end$if;
end ENDIFrout;
INCLUDErout: proc public;
dcl (disk,i,errflag) byte,filname(11) byte,filtype(3) byte at (.filname (8));
syntaxerr: proc;
call errmsg(filesynterr);
errflag=true;
end syntaxerr;
accum$not$alpha: proc byte;
i=0ffh;
do while (i:=i+1) < acclen;
if not alphanumeric(accum(i)) then return true;
end$while;
return false;
end accum$not$alpha;
if include$on then$do
call errmsg(nestedincludeerr);
call skip$rest$of$line;
return;
end$if;
errflag=false;
disk=include$default; /* default disk is current one */
CALL FILL (SPACE, SIZE (FILNAME), .FILNAME);
if (acclen=1) and (nextch=':') and (letter(accum(0))) then$do
/* disk name found */
disk=accum(0)-'A';
call scan; /* skip : */
call scan; /* get filename */
end$if;
/* test syntax of filename */
if (acclen > 8) or accum$not$alpha then$do
call syntaxerr; /* illegal filename */
else$do
call copy(acclen,.accum(0),.filname); /* pick up filename */
call scan; /* skip filename */
/* test if filetype - if so, pick it up */
if specialtoken('.') then$do
call scan; /* skip . */
if (acclen > 3) or accum$not$alpha then$do
call syntaxerr;
else$do
call copy(acclen,.accum(0),.filtype(0));
call scan;
end$if;
ELSE$DO
CALL COPY (3, .('A86'), .FILTYPE); /* DEFAULT FILE TYPE */
end$if;
end$if;
if errflag then$do
call skip$rest$of$line;
else$do
/* try to open include file */
call i$file$setup(disk,.filname,.filtype);
CALL OPEN$INCLUDE;
call test$emptyline;
include$on=true;
end$if;
end INCLUDErout;
ENDrout: proc public;
call test$emptyline;
eofset=true;
end ENDrout;
PAGESIZErout: proc public;
call sizewidth(.pagesize);
end PAGESIZErout;
PAGEWIDTHrout: proc public;
call sizewidth(.maxcol);
end PAGEWIDTHrout;
TITLErout: proc public;
do case pass;
do; /* pass 0 */
if token.type=string then$do
call fill(0,length(title),.title(0));
if acclen > length(title) then acclen=length(title);
call copy(acclen,.accum(0),.title(0));
end$if;
call skip$rest$of$line;
end;
do; /* do nothing in pass 1 */
call skip$rest$of$line;
end;
do; /* pass 2 */
if token.type=string then$do
call scan;
call test$emptyline;
else$do
call errmsg(pseudooperr);
call skip$rest$of$line;
end$if;
end;
end$case;
end TITLErout;
EJECTrout: proc public;
if print$on then call printnewpage;
call test$emptyline;
end EJECTrout;
SIMFORMrout: proc public;
simform=true;
call test$emptyline;
end SIMFORMrout;
LISTrout: proc public;
call test$emptyline;
if printswitchoff then$do
printswitchoff=false;
print$on=true;
sourceptr=0;
end$if;
end LISTrout;
NOLISTrout: proc public;
if print$on then$do
call test$emptyline;
call printsourceline;
printswitchoff=true;
print$on=false;
else$do
call test$emptyline;
end$if;
end NOLISTrout;
IFLISTROUT: PROC PUBLIC;
CALL TESTEMPTYLINE;
IFLIST = TRUE;
END IFLISTROUT;
NOIFLISTROUT: PROC PUBLIC;
CALL TESTEMPTYLINE;
IFLIST = FALSE;
END NOIFLISTROUT;
end$module pseudom;


View File

@@ -0,0 +1,57 @@
$nolist
/*
modified 7/24/81 R. Silberstein
*/
dcl
pass byte external, /* current pass no, 1,2,3 */
/* print output parameters */
print$on byte external, /* on/off flag */
printswitchoff byte external, /* set/reset by NOLIST/LIST */
IFLIST BYTE EXTERNAL, /* SET/RESET BY IFLIST/NOIFLIST */
maxcol byte external, /* pagewidth */
title (30) byte external, /* user specified program title */
pagesize byte external, /* page size */
simform byte external, /* true if formfeed simulation */
sourceptr byte external, /* source buffer pointer */
/* scanner variables: */
token struc( /* actual token scanned */
type byte, /* token type, legal values :
reg - register
pseudo - pseudo code
string - text string
spec - special character
number - number
operator - aritmetic operator
ident - identifier */
descr byte, /* token description, legal values:
nil - no specification
byte - 8 bit type
word - 16 bit type
dword - 32 bit type */
value addr) external, /* token value */
nextch byte external, /* next input character */
acclen byte external, /* accumulator length */
accum(80) byte external, /* actual token scanned */
eofset byte external, /* true if end-of-file found */
/* Mischellaneous variables: */
include$on byte external, /* true if INCLUDEfile input */
IFLEVEL BYTE EXTERNAL, /* IF-ENDIF NESTING LEVEL */
operands(4) operandstruc /* instruction operands,max 4 */
external,
include$default byte external; /* default drive for include file */
$list


View File

@@ -0,0 +1,24 @@
$nolist
scaninit: proc external;
end scaninit;
scan: proc external;
end scan;
skip$rest$of$line: proc external;
end skip$rest$of$line;
specialtoken: proc (tok) byte external;
dcl tok byte;
end specialtoken;
skip$until: proc (tok) byte external;
dcl tok byte;
end skip$until;
emptyline: proc byte external;
end emptyline;
$list


View File

@@ -0,0 +1,323 @@
$title ('SCANNER MODULE')
scanm:
do;
/*
modified 3/26/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/10/81 R. Silberstein
modified 9/2/81 R. Silberstein
*/
$include (:f1:macro.lit)
$include (:f1:struc.lit)
$include (:f1:equals.lit)
$include (:f1:files.ext)
$include (:f1:predef.ext)
$include (:f1:subr2.ext)
$include (:f1:print.ext)
$include (:f1:global.ext)
/* Variables : */
dcl
eoffound byte, /* true if end-of-file is found */
lowercase byte, /* false if stringinput, otherwise true */
crfound byte, /* true if previous input was CR */
printready byte, /* true if output line to be printed */
stacksave addr; /* save of stack pointer */
/* Routine to perform unnormal exit from module */
exit: proc;
stackptr=stacksave; /* restore input stack */
end exit;
/* Put printcharacter into printfile output buffer */
putprintchar: proc(ch);
dcl ch byte;
sourcebuf(sourceptr)=ch;
if sourceptr < last(sourcebuf) then$do
sourceptr=sourceptr+1;
end$if;
end putprintchar;
/* Read single character from input file. Put characters
except CR-LF to printbuffer. Convert to uppercase letters */
read$input: proc byte;
dcl ch byte;
if eoffound then call exit; /* unnormal exit */
/* read byte from file */
if include$on then ch=inincludebyte; else ch=insourcebyte;
if ch=end$of$file then$do /* test for end-of-file */
eoffound=true;
else$do
if crfound and ch=lf then$do /* ignore LF after CR */
ch=space;
else$do;
if ch=cr then$do /* test for CR */
crfound=true;
else$do;
crfound=false;
call putprintchar(ch);
if ch=lf then ch=space; /* interpret LF within line as space */
end$if;
end$if;
end$if;
if not lowercase then$do /* convert to uppercase */
ch=upper(ch);
end$if;
return ch;
end read$input;
/* skip blanks and tab's in input */
skip$blanks: proc;
do while nextch=space or nextch=tab;
nextch=read$input;
end$while;
end skip$blanks;
/* Put character into accumulator */
putaccum: proc(ch);
dcl ch byte;
accum(acclen)=ch;
if acclen < last(accum) then$do
acclen=acclen+1;
end$if;
end put$accum;
/* Routine to scan remainder of token until a non-
alphanumeric character is found. Skip blanks
behind token */
get$remainder: proc(numb);
dcl (cont,numb) byte;
cont=true;
do while cont;
do while alphanumeric(nextch:=read$input);
call putaccum(nextch);
end$while;
cont=false;
if nextch = '@' or nextch = '_' then$do
cont=true;
if numb then call putaccum(nextch);
end$if;
end$while;
call skipblanks;
end get$remainder;
/* Routine to scan a text string. Called from SCAN */
stringr: proc;
dcl cont byte;
lowercase=true;
acclen=0;
cont=true;
do while cont;
nextch=readinput;
do while nextch <> '''' and nextch <> cr;
call putaccum(nextch);
nextch=read$input;
end$while;
if nextch='''' then$do
if (nextch:=readinput) = '''' then$do /* interpret '' as ' */
call putaccum(nextch);
else$do
lowercase=false;
call skipblanks;
token.type=string;
cont=false;
end$if;
else$do
lowercase=false;
token.type=error;
cont=false;
end$if;
end$while;
end stringr;
/* Routine to scan a number. Called from SCAN. Test syntax
of number, compute binary value. */
numbr: proc;
dcl
nobase byte, /* number system, 2,8,10 or 16 */
maxlgth byte, /* max legal no of digits */
(i,j) byte, /* counters */
ch byte,
value addr, /* 16 bit binary value */
errorflag byte; /* syntax error flag */
errorflag=false;
call getremainder(true); /* get rest of token */
ch=accum(acclen-1); /* pick up last character of token */
j=acclen-2;
/* B (binary) */
IF CH = 'B' THEN
do; nobase=2; maxlgth=16; end;
/* O or Q (octal) */
ELSE IF CH = 'O' OR CH = 'Q' THEN
do; nobase=8; maxlgth=6; end;
/* H (hexadecimal) */
ELSE IF CH = 'H' THEN
do; nobase=16; maxlgth=4; end;
/* D (decimal) */
ELSE IF CH = 'D' THEN
do; nobase=10; maxlgth=5; end;
/* no subscript, default=decimal */
ELSE
do; nobase=10; maxlgth=5; j=j+1; end;
i=0ffh; /* skip leading zeros */
do while accum(i:=i+1) = '0'; end;
if j < maxlgth+i then$do
value=0; /* syntax check number, compute binary value */
do while i <= j;
ch=accum(i);
ch=ch-'0';
if ch > 9 then ch=ch-7;
if ch >= nobase then$do
errorflag=true;
end$if;
value=value*nobase+ch;
i=i+1;
end$while;
else$do
errorflag=true;
end$if;
if errorflag then$do
token.type=error;
else$do
token.type=number;
token.descr=0;
token.value=value;
end$if;
end numbr;
/* Routine to scan an identifier. Lookup identifier in table
for predefined symbols */
identr: proc;
call get$remainder(false); /* get rest of token into accumulator */
/* look up identifier */
if not pfind(acclen,.accum(0),.token) then$do
token.type=ident;
end$if;
end identr;
/* PUBLIC subroutines : */
scaninit: proc public;
eofset,eoffound,crfound,lowercase,printready=false;
CALL FILL (SPACE, SIZE (PREFIX), .PREFIX);
CALL FILL (SPACE, LENGTH (ABSADDR), .ABSADDR);
sourceptr,prefixptr=0;
call printinit; /* initiate print module */
call rewindsource;
nextch=space;
end scaninit;
scan: proc public;
stacksave=stackptr;
if printready then$do
call print$source$line;
print$ready=false;
end$if;
call skipblanks;
if eoffound then$do
token.type=spec;
if crfound then$do
eoffound=false;
eofset=true;
else$do
printready=true; /* terminate line before EOF */
crfound=true;
accum(0)=cr;
end$if;
else$do
acclen=1;
accum(0)=nextch;
/* identifier */
IF LETTER (NEXTCH) THEN call identr;
/* number */
ELSE IF DIGIT (NEXTCH) THEN call numbr;
/* string */
ELSE IF NEXTCH = '''' THEN call stringr;
/* special letter */
ELSE
do;
token.type=spec;
if nextch='!' then accum(0) = cr;
IF NEXTCH = ';' THEN$DO
DO WHILE ACCUM (0) <> CR;
ACCUM (0) = READINPUT;
END$WHILE;
END$IF;
nextch=space;
if crfound then$do
print$ready=true;
else$do
call skipblanks;
end$if;
end;
end$if;
end scan;
skip$rest$of$line: proc public;
do while accum(0) <> cr;
call scan;
end$while;
end skip$rest$of$line;
specialtoken: proc(tok) byte public;
dcl tok byte;
if (token.type=spec) and (accum(0)=tok) then return true;
return false;
end specialtoken;
skip$until: proc(tok) byte public;
dcl tok byte;
do forever;
if token.type=spec then$do
if accum(0)=tok then$do
call scan;
return true;
end$if;
if accum(0)=cr then return false;
end$if;
call scan;
end$forever;
end skip$until;
emptyline: proc byte public;
return specialtoken(cr);
end emptyline;
end$module scanm;


View File

@@ -0,0 +1,80 @@
$nolist
/*
modified 3/27/81 R. Silberstein
modified 3/28/81 R. Silberstein
modified 4/13/81 R. Silberstein
*/
/* This file contains all structure definitions used */
dcl
file$o$structure lit 'struc(
disk byte,
fcbblock(33) byte,
bufptr addr,
buffer(512) byte)',
file$i$structure lit 'struc(
disk byte,
fcbblock(33) byte,
bufptr addr,
buffer(1024) byte)',
symbolstruc lit 'struc(
length addr,
stype byte,
sflag byte,
segment addr,
offset addr,
baseindex byte)',
operandstruc lit 'symbolstruc',
symbolhead lit 'struc(
next addr,
slength byte,
length addr,
stype byte,
sflag byte,
segment addr,
offset addr,
baseindex byte)',
codemacrohead lit 'struc(
next addr,
slength byte,
defptr addr)',
/* define bits of SFLAG of structures above */
type$bit lit '7h', /* bit 0-2 */
segtypebit lit '18h', /* bit 3-4 */
segmbit lit '20h', /* bit 5 */
iregbit lit '40h', /* bit 6 */
bregbit lit '80h', /* bit 7 */
/* left-shift counters */
typecount lit '0',
segtypecount lit '3',
segmcount lit '5',
iregcount lit '6',
bregcount lit '7',
/* define bits of BASEINDEX byte of structures above */
indexregbit lit '01h', /* bit 0 */
baseregbit lit '02h', /* bit 1 */
nooverridebit lit '40h', /* bit 6 */
/* left shift counters */
indexregcount lit '0',
baseregcount lit '1',
noovercount lit '6';
$list


View File

@@ -0,0 +1,17 @@
$nolist
typecalc: proc(val) byte external;
dcl val addr;
end typecalc;
wrdtest: proc(n) byte external;
dcl n addr;
end wrdtest;
copy: procedure(n,s,d) external;
dcl n byte,
(s,d) addr;
end copy;
$list


View File

@@ -0,0 +1,47 @@
$title ('SUBROUTINE MODULE - PART 1')
subr1:
do;
$include (:f1:macro.lit)
/*
modified 3/26/81 R. Silberstein
*/
/* compute if number is in range (-128,127) */
/* exit 1 if in range, 2 otherwise */
typecalc: procedure(val) byte public;
declare val address,
lowb byte at (.val),
highb byte at (.val+1);
lowb=lowb and 80h;
if highb=0 then
if lowb=0 then return 1;
if highb=0ffh then
if lowb <> 0 then return 1;
return 2;
end typecalc;
/* test if number is a "word" (>255 and <-256) */
wrdtest: procedure(n) byte public;
declare n address;
return ((n < 0ff00h) and (n > 0ffh));
end wrdtest;
copy: procedure(n,s,d) public;
declare n byte,
(s,d) address,
sch based s byte,
dch based d byte;
DO WHILE (N := N - 1) <> 0FFH;
DCH = SCH;
D = D + 1;
S = S + 1;
END;
end copy;
end subr1;


View File

@@ -0,0 +1,60 @@
$nolist
/*
modified 3/26/81 R. Silberstein
modified 3/28/81 R. Silberstein
*/
outtext: procedure (t) external;
dcl t addr;
end outtext;
FILEABORT: PROCEDURE (FCBADR, TEXTADR) EXTERNAL;
DECLARE (FCBADR, TEXTADR) ADDRESS;
END FILEABORT;
fill: procedure(ch,n,pt) external;
dcl (ch,n) byte,pt addr;
end fill;
digit: procedure(ch) byte external;
dcl ch byte;
end digit;
letter: procedure(ch) byte external;
dcl ch byte;
end letter;
alphanumeric: proc(ch) byte external;
dcl ch byte;
end alphanumeric;
asciichar: proc(ch) byte external;
dcl ch byte;
end asciichar;
upper: procedure(ch) byte external;
dcl ch byte;
end upper;
equal: procedure(n,s,d) byte external;
dcl n byte,
(s,d) addr;
end equal;
hex1out: proc(n,d) external;
dcl n byte,d addr;
end hex1out;
hex2out: proc(n,d) external;
dcl n addr,d addr;
end hex2out;
decout: proc(n,d) external;
dcl n addr,d addr;
end decout;
$list


View File

@@ -0,0 +1,148 @@
$title ('SUBROUTINE MODULE - PART 2')
subr2:
do;
$include(:f1:macro.lit)
$INCLUDE (:F1:STRUC.LIT)
$include(:f1:io.ext)
/*
modified 3/26/81 R. Silberstein
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
*/
outtext: procedure (t) public;
dcl t addr,
ch based t byte;
do while ch <> 0;
call write$console(ch);
t=t+1;
end$while;
end outtext;
OUTFILENAME: PROCEDURE (PTR);
DECLARE PTR ADDRESS, X BASED PTR FILEOSTRUCTURE, I BYTE;
CALL WRITE$CONSOLE (X.DISK + 'A');
CALL WRITE$CONSOLE (':');
DO I = 1 TO 8;
IF (X.FCBBLOCK (I) AND 7FH) = SPACE THEN I = 8;
ELSE CALL WRITE$CONSOLE (X.FCBBLOCK (I) AND 7FH);
END;
CALL WRITE$CONSOLE ('.');
DO I = 9 TO 11;
CALL WRITE$CONSOLE (X.FCBBLOCK (I) AND 7FH);
END;
CALL SYSTEMRESET;
END OUTFILENAME;
FILEABORT: PROCEDURE (PTR, TEXTADR) PUBLIC;
DECLARE (PTR, TEXTADR) ADDRESS;
CALL OUTTEXT (TEXTADR);
CALL WRITE$CONSOLE (':');
CALL WRITE$CONSOLE (SPACE);
CALL OUTFILENAME (PTR);
END FILEABORT;
fill: procedure (ch,n,pt) public;
dcl (ch,n) byte,pt address,buffer based pt byte;
DO WHILE (N := N - 1) <> 0FFH;
buffer=ch;
pt = pt + 1;
end$while;
end fill;
digit: procedure(ch) byte public;
dcl ch byte;
IF CH < '0' THEN RETURN FALSE;
return (ch <= '9');
end digit;
letter: procedure(ch) byte public;
dcl ch byte;
IF CH < 'A' THEN RETURN FALSE;
return (ch <= 'Z');
end letter;
alphanumeric: proc(ch) byte public;
dcl ch byte;
if letter(ch) then return true;
return digit(ch);
end alphanumeric;
asciichar: proc (ch) byte public;
dcl ch byte;
if ch=cr then return true;
IF CH = LF THEN RETURN TRUE;
IF CH < SPACE THEN RETURN FALSE;
return (ch <= 7eh);
end asciichar;
upper: procedure(ch) byte public;
dcl ch byte;
if ch >= 61h THEN IF ch <= 7eh then ch=ch-20h;
return ch;
end upper;
equal: procedure(n,s,d) byte public;
dcl n byte,
(s,d) address,
sch based s byte,
dch based d byte;
DO WHILE (N := N - 1) <> 0FFH;
IF SCH <> DCH THEN RETURN FALSE;
S = S + 1;
D = D + 1;
END$WHILE;
return true;
end equal;
hex1out: procedure(n,d) public;
dcl n byte,d addr,
dest based d (1) byte;
hexdigit: procedure(digit) byte;
dcl digit byte;
digit=digit+'0';
if digit > '9' then digit=digit+7;
return digit;
end hexdigit;
dest(0)=hexdigit(SHR (N, 4));
dest(1)=hexdigit(n and 0fh);
end hex1out;
hex2out: proc (n,d) public;
dcl n addr,
d addr;
call hex1out(HIGH (N),d);
call hex1out(LOW (N),d+2);
end hex2out;
decout: proc (n,d) public;
dcl
n addr,
d address,
dest based d (1) byte,
(i,space$or$zero,digit) byte,
divis(5) addr data (10000,1000,100,10,1);
space$or$zero=space;
do i=0 to 4;
if i=4 then space$or$zero='0';
digit=n/divis(i);
n=n mod divis(i);
if digit=0 then$do
dest(i)=space$or$zero;
else$do
dest(i)=digit+'0';
space$or$zero='0';
end$if;
end$do;
end decout;
end subr2;


View File

@@ -0,0 +1,51 @@
$nolist
/*
modified 7/24/81 R. Silberstein
*/
dcl freept addr external;
DCL END$OF$SYMBTAB ADDR EXTERNAL;
symbterminate: proc external;
end symbterminate;
symbinit: proc external;
end symbinit;
newsymbol: proc(lg,stradr,result) byte external;
dcl lg byte,(stradr,result) addr;
end newsymbol;
newmacro: proc(lg,stradr,macdefpt) byte external;
dcl lg byte,(stradr,macdefpt) addr;
end newmacro;
findsymbol: proc(lg,stradr,result) byte external;
dcl lg byte,(stradr,result) addr;
end findsymbol;
getattributes: proc(symbadr,dest) external;
dcl (symbadr,dest) addr;
end getattributes;
enterattributes: proc(symbadr,source) external;
dcl (symbadr,source) addr;
end enterattributes;
findcodemacro: proc(lg,stradr,result) byte external;
dcl lg byte,(stradr,result) addr;
end findcodemacro;
new$cm$body: PROC(lg,ptr) byte external;
dcl lg byte,ptr addr;
end$proc new$cm$body;
new$cm$name: PROC(lg,asciiptr,returnptr) byte external;
dcl lg byte,(asciiptr,returnptr) addr;
end$proc new$cm$name;
$list


View File

@@ -0,0 +1,337 @@
$title ('SYMBOL TABLE MODULE')
symb:
do;
/*
modified 3/25/81 R. Silberstein
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/15/81 R. Silberstein
modified 4/16/81 R. Silberstein
modified 4/20/81 R. Silberstein
modified 6/16/81 R. Silberstein
modified 7/24/81 R. Silberstein
*/
/*
This is the module to perform all symbol table
handling. There are 2 different kinds of symbols,
codemacro mnemonics and user defined symbols.
The codemacro symbols are entered into the
symbol table through the hash vector "CODEMACROENTRY",
whereas the user symbols uses the hash vector
"SYMBENTRY". Each symbol enters the symbol table through
hash vector element "i", where i is the hash function of
the symbol. The function is defined as:
H(S) = (C1 + C2 +.... + Ci + ..+ Cn) mod 64
where Ci is the ascii code of the i'th symbolcharacter.
*/
$include (:f1:macro.lit)
$include (:f1:equals.lit)
$include (:f1:struc.lit)
$INCLUDE (:F1:DEV.LIT)
$include (:f1:mnem.ext)
$include (:f1:subr1.ext)
$include (:f1:subr2.ext)
$include (:f1:files.ext)
$INCLUDE (:F1:TEXT.EXT)
$INCLUDE (:F1:IO.EXT)
DECLARE SYMBOLDEVICE BYTE EXTERNAL;
$eject
/* Global variables: */
dcl
codemacroentry (64) addr /* opcode mnemonic entry */
data(
.push,.repz,0,.aaa,0,.movs,.pushf,.MOVSB,
.adc,.add,.CMPSW,.ja,.dec,.loopne,0,.repnz,
.jae,.jg,.clc,.iand,.loopz,.aas,.jl,.in,
.cli,.jo,.inc,.lahf,.icall,.jne,.cwd,.jnbe,
.cmp,.ior,.callf,.div,.les,0,.sar,.jmp,
.hlt,.lock,.xchg,.ret,.idiv,.jmpf,.mul,.pop,
.sti,.inot,.mov,.cmps,.iret,.popf,0,.imul,
.out,.xlat,.jmps,0,0,0,0,.loope),
symbentry (64) addr, /* user symbol entry */
symbtab(1) byte at (.memory), /* symbol table */
freept addr public, /* adr. of next free symb. tab byte */
end$of$symbtab addr PUBLIC, /* last symbol table byte */
symbolheadlg byte, /* length of head for each symbol */
attributelg byte, /* length of symbol attributes */
codemacheadlg byte, /* length of codemacrohead */
overflowlimit addr, /* used to test overflow */
col byte; /* current column position */
DECLARE
ALPHAROOT ADDRESS, /* ROOT OF ALPHABETIZED SYMBOL LIST */
ALPHASYMPTR ADDRESS, /* POINTER TO CURRENT SYMBOL IN ALPHA LIST */
ALPHASYM BASED ALPHASYMPTR SYMBOLHEAD, /* SYMBOL TEMPLATE */
SORTSYMPTR ADDRESS, /* POINTER TO SYMBOL BEING INSERTED */
SORTSYM BASED SORTSYMPTR SYMBOLHEAD; /* SYMBOL TEMPLATE */
$eject
/****************** SUBROUTINES ******************/
outbyt: proc (ch); /* print one byte to symbol file */
dcl ch byte;
if ch=cr then$do /* update column position */
col=0;
else$do
if ch <> lf then col=col+1;
end$if;
call outsymbolbyte(ch);
end outbyt;
hash: proc (lg,pt) byte;
dcl (lg,i,h) byte,pt addr,asc based pt (1) byte;
i=0ffh; h=0;
do while (i:=i+1) < lg;
h=h+asc(i);
end$while;
return h and 3fh;
end hash;
/* search for either a user symbol or a codemacro */
search: proc(lg,pt1,pt2,pt3,headlg) byte;
dcl (lg,headlg) byte,(pt1,pt2,pt3) addr,
ascii based pt1(1) byte,symbptr based pt2 addr,
entrytab based pt3 (64) addr,
currentpt addr,next based currentpt addr,
symbhead based currentpt symbolhead;
currentpt=entrytab(hash(lg,.ascii(0)));
do while currentpt <> 0;
if lg = symbhead.slength then$do
if equal(lg,currentpt+headlg,.ascii(0)) then$do
symbptr=currentpt+3;
return true;
end$if;
end$if;
currentpt=next;
end$while;
return false;
end search;
/* enter either new symbol or new codemacro */
new: proc(lg,pt1,pt2,headlg,pt3) byte;
dcl (lg,headlg) byte,(pt1,pt2,pt3) addr,
ascii based pt1 (1) byte,entrytab based pt2 (64) addr,
symptr based pt3 addr,
current addr,currentcontent based current addr,
symb based freept symbolhead;
if freept > overflowlimit - (lg+headlg) then$DO
CALL OUTTEXT (.SYMBFULLERRTEXT);
CALL SYSTEM$RESET;
END$IF;
current=.entrytab(hash(lg,.ascii(0)));
SYMB.NEXT = CURRENTCONTENT;
currentcontent=freept;
symptr=freept+3;
symb.slength=lg;
call copy(lg,.ascii(0),freept+headlg);
freept=freept+headlg+lg;
return true;
end new;
newsymbol: proc (lg,asciiptr,returnpt) byte public;
dcl lg byte,(asciiptr,returnpt) addr;
return new(lg,asciiptr,.symbentry,symbolheadlg,returnpt);
end newsymbol;
newmacro: proc (lg,asciiptr,codmacdefpt) byte public;
dcl lg byte,(asciiptr,codmacdefpt,retpt) addr,
cmaddr based retpt addr;
if new(lg,asciiptr,.codemacroentry,codemacheadlg,.retpt) then$do
cmaddr=codmacdefpt;
return true;
end$if;
return false;
end newmacro;
findsymbol: proc(lg,stradr,result) byte public;
dcl lg byte,(stradr,result) addr;
return search(lg,stradr,result,.symbentry(0),symbolheadlg);
end findsymbol;
getattributes: proc(symbadr,dest) public;
dcl (symbadr,dest) addr,symb based symbadr symbolstruc;
call copy(attributelg,.symb.length,dest);
end getattributes;
enterattributes: proc(symbadr,source) public;
dcl (symbadr,source) addr,symb based symbadr symbolstruc;
call copy(attributelg,source,.symb.length);
end enterattributes;
findcodemacro: proc(lg,stradr,result) byte public;
dcl lg byte,(stradr,result) addr;
return search(lg,stradr,result,.codemacroentry(0),codemacheadlg);
end findcodemacro;
new$cm$body: PROC (lg,ptr) byte public;
dcl lg byte,ptr addr;
if freept > overflowlimit-lg then return false;
call copy (lg,ptr,freept);
freept=freept+lg;
return true;
end$proc new$cm$body;
new$cm$name: PROC (lg,asciiptr,returnptr) byte public;
dcl lg byte,(asciiptr,returnptr) addr;
return new(lg,asciiptr,.codemacroentry,5,returnptr);
end$proc new$cm$name;
SORTSYMBOLS: PROCEDURE;
DECLARE
CURRENT ADDRESS,
CURRENTCONTENT BASED CURRENT ADDRESS,
NEXT ADDRESS,
I BYTE;
ALPHALOCFOUND: PROCEDURE BYTE;
DECLARE
SORTNAMEPTR ADDRESS,
SORTNAME BASED SORTNAMEPTR (1) BYTE,
ALPHANAMEPTR ADDRESS,
ALPHANAME BASED ALPHANAMEPTR (1) BYTE,
I BYTE;
SORTNAMEPTR = SORTSYMPTR + SYMBOLHEADLG;
ALPHANAMEPTR = ALPHASYMPTR + SYMBOLHEADLG;
DO I = 1 TO SORTSYM.SLENGTH;
IF I > ALPHASYM.SLENGTH THEN RETURN FALSE;
IF SORTNAME (I-1) > ALPHANAME (I-1) THEN RETURN FALSE;
IF SORTNAME (I-1) < ALPHANAME (I-1) THEN RETURN TRUE;
END;
RETURN TRUE;
END ALPHALOCFOUND;
FIXCHAIN: PROCEDURE;
SORTSYM.NEXT = ALPHASYMPTR;
CURRENTCONTENT = .SORTSYM;
END FIXCHAIN;
INSERTALPHA: PROCEDURE;
CURRENT, ALPHASYMPTR = .ALPHAROOT;
DO WHILE (ALPHASYMPTR := ALPHASYM.NEXT) <> 0;
IF ALPHALOCFOUND THEN$DO
CALL FIXCHAIN;
RETURN;
END$IF;
CURRENT = ALPHASYMPTR;
END$WHILE;
CALL FIXCHAIN;
END INSERTALPHA;
ALPHAROOT = 0;
DO I = 0 TO LAST (SYMBENTRY);
SORTSYMPTR = SYMBENTRY (I);
DO WHILE SORTSYMPTR <> 0;
NEXT = SORTSYM.NEXT;
CALL INSERTALPHA;
SORTSYMPTR = NEXT;
END$WHILE;
END;
END SORTSYMBOLS;
outcrlf: proc;
call outbyt(cr);
call outbyt(lf);
end outcrlf;
printsymbols: proc(typ); /* print all symbols to file */
dcl (typ,i) byte;
advancetonext: proc; /* advance to next column (16,32,48,64) */
dcl (x,y) byte;
x=col/16;
y=16-(col mod 16);
if x >= 4 then$do
call outcrlf;
else$do
IF SYMBOL$DEVICE = PRINTER THEN$DO
DO WHILE (Y := Y - 1) <> 255;
CALL OUTBYT (SPACE);
END$WHILE;
ELSE$DO
col=col+y;
call outsymbolbyte(tab);
if y > 8 then call outsymbolbyte(tab);
END$IF;
end$if;
end advancetonext;
OUTBYTES: proc(lg,p);
dcl lg byte,p addr,asc based p byte;
DO WHILE (LG := LG - 1) <> 0FFH;
call outbyt(asc);
P = P + 1;
end$while;
end OUTBYTES;
printsymb: proc(p); /* print single symbol */
dcl p addr,x based p symbolhead,
a addr,ascii based a (1) byte,help(4) byte;
a=p+symbolheadlg;
if X.STYPE=typ then$do
if col+x.slength+5 > 79 then call outcrlf;
call hex2out(x.offset,.help(0));
CALL OUTBYTES (4, .HELP);
call outbyt(space);
CALL OUTBYTES (X.SLENGTH, .ASCII);
call advancetonext;
end$if;
end printsymb;
/* print symbols main program */
col=0;
CALL OUTBYTES (4, .('0000')); /* print header */
call outbyt(space);
if typ=lab then call OUTBYTES(6,.('LABELS'));
if typ=variable then call OUTBYTES(9,.('VARIABLES'));
if typ=number then call OUTBYTES(7,.('NUMBERS'));
call outcrlf;
ALPHASYMPTR = ALPHAROOT;
DO WHILE ALPHASYMPTR <> 0;
CALL PRINTSYMB (ALPHASYMPTR);
ALPHASYMPTR = ALPHASYM.NEXT;
END;
if col <> 0 then call outcrlf;
end printsymbols;
symbterminate: proc public; /* print symbol table */
IF SYMBOLDEVICE = NULL THEN RETURN; /* no need to sort, etc. */
CALL SORTSYMBOLS;
CALL OUTSYMBOLBYTE (FORMFEED);
call printsymbols(variable); /* variables */
CALL OUTCRLF;
call printsymbols(number); /* numbers */
CALL OUTCRLF;
call printsymbols(lab); /* labels */
end symbterminate;
symbinit: proc public;
dcl i byte;
dcl symb symbolhead at (.i),codm codemacrohead at (.i);
end$of$symbtab=(endbuf/256)*256-1;
freept=.symbtab(0);
CALL FILL (0, SIZE (SYMBENTRY), .SYMBENTRY);
symbolheadlg=.symb.baseindex-.symb.next+1;
attributelg=symbolheadlg-3;
codemacheadlg=.codm.defptr-.codm.next+2;
overflowlimit=end$of$symbtab-symbolheadlg;
end symbinit;
end$module symb;


View File

@@ -0,0 +1,6 @@
$nolist
declare endbuf address external;
$list


View File

@@ -0,0 +1,33 @@
$nolist
/*
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 7/24/81 R. Silberstein
*/
/* Text strings: */
dcl
yes byte external,
no byte external,
initials(1) byte external,
pagetext(1) byte external,
endtext(1) byte external,
USEFACTOR (1) BYTE EXTERNAL,
asm86text(1) byte external,
parerrtext(1) byte external,
openerrtext(1) byte external,
DISKREADERRTEXT (1) BYTE EXTERNAL,
DISKWRITEERRTXT (1) BYTE EXTERNAL,
MAKEERRTEXT (1) BYTE EXTERNAL,
CLOSEERRTEXT (1) BYTE EXTERNAL,
SYMBFULLERRTEXT (1) BYTE EXTERNAL,
usbreaktext(1) byte external,
pass0text (1) byte external,
pass1text (1) byte external;
$list


View File

@@ -0,0 +1,44 @@
$title ('TEXT MODULE')
text:
do;
$include (:f1:macro.lit)
/*
modified 3/28/81 R. Silberstein
modified 3/30/81 R. Silberstein
modified 4/8/81 R. Silberstein
modified 4/15/81 R. Silberstein
modified 7/24/81 R. Silberstein
*/
/* Bytes to define "yes" and "no": */
dcl yes byte public data ('Y'),
no byte public data ('N');
/* Text strings: */
dcl
initials(*) byte public data('CP/M ASM86 1.1 SOURCE: ',0),
pagetext(*) byte public data(' PAGE',0),
endtext(*) byte public data('END OF ASSEMBLY. ',
'NUMBER OF ERRORS: ',0),
USEFACTOR (*) BYTE PUBLIC DATA ('. USE FACTOR: ',0),
asm86text(*) byte public data(cr,lf,'CP/M 8086 ASSEMBLER VER 1.1',
cr,lf,0),
parerrtext(*) byte public data(cr,lf,'PARAMETER ERROR',cr,lf,0),
openerrtext(*) byte public data(cr,lf,'NO FILE',0),
DISKREADERRTEXT (*) BYTE PUBLIC DATA (CR,LF,'DISK READ ERROR',0),
DISKWRITEERRTXT (*) BYTE PUBLIC DATA (CR,LF,'DISK FULL',0),
MAKEERRTEXT (*) BYTE PUBLIC DATA (CR,LF,'DIRECTORY FULL',0),
CLOSEERRTEXT (*) BYTE PUBLIC DATA (CR,LF,'CANNOT CLOSE',0),
SYMBFULLERRTEXT (*) BYTE PUBLIC DATA (CR,LF,'SYMBOL TABLE OVERFLOW',0),
usbreaktext(*) byte public data(cr,' USER BREAK. OK(Y/N)? ',0),
pass0text (*) byte public data('END OF PASS 1',cr,lf,0),
pass1text (*) byte public data('END OF PASS 2',cr,lf,0);
end$module text;


View File

@@ -0,0 +1,92 @@
;****************************************************************
;* *
;* BOOT SECTOR FOR IBM PC *
;* *
;****************************************************************
min_mem equ 160 ;minimum memory in K
load_track_segment equ 2600H ;at 152K mark
;Check for at least 160K being present in the IBM PC.
;Use last 8K of 160K minimum memory for loader.
;Since track is 4K we have 4K extra past the Loader for
;disk buffer space and other unitialized storage
;used by the Loader.
;Note: that wherever it is decided to place the loader, the IBM PC
;cannot read over a 64K page boundary.
;the command:
;GENCMD BOOT 8080
;is used for this module
bw_video_ram equ 0b000h ;where to print an
color_video_ram equ 0b800h ;error message
cseg load_track_segment + 20H ;add 20H to get to sector 2
loader: ;where the Loader starts
cseg 0
org 0 ;The IBM ROM sets up
;SS=30H and SP is 80H: stack is in
;the interrupt vectors.
int 12H ;get memory size
cmp ax,min_mem
jnb get_track_0
jmps mem_error
get_track_0:
xor bx,bx ;set up call to ROM diskette read
mov ax,load_track_segment
mov es,ax ;ES:BX transfer location
mov ax,0208h ;AH=2=read,AL=8=sectors to read
mov cx,0001h ;CH=0=track,CL=1=sector
mov dx,0000h ;DH=0=head #,DL=0=drive #
int 13H ;call ROM diskette entry
jnc track_ok
jmps track_error
track_ok:
jmpf loader
mem_error:
mov cx,length mem_msg
mov si,offset mem_msg
jmps prt_msg
track_error:
mov cx,length trk_msg
mov si,offset trk_msg
;jmps prt_msg
prt_msg:
mov ax,bw_video_ram
int 11H ;get equipment information
and al,00110000b ;get video bits
cmp al,30H
je do_msg
mov ax,color_video_ram
do_msg:
mov es,ax
mov ax,cs
mov ds,ax
xor di,di
mov ah,07H ;normal display attribute
prt_loop:
lodsb
stosw
loop prt_loop
cli
hlt
last_code_offset equ offset $
dseg
org last_code_offset
mem_msg db 'Not enough memory present for loader'
trk_msg db 'Can''t read boot track'
org 512 - 1 ;force even sector size
db 0


View File

@@ -0,0 +1,212 @@
title 'Clock process'
;*****************************************************
;*
;* CLOCK RSP
;*
;* The clock process will update the CCP/M-86 Time of
;* Day structure each time it returns from waiting for
;* the 'Second' System Flag (Flag 2). When the minute
;* is updated, the 'minute' flag is set (Flag 3).
;*
;*****************************************************
; ccpm functions
ccpmint equ 224 ; ccpm entry interrupt
dev_flagwait equ 132 ; flagwait
dev_flagset equ 133 ; flagset
rlr equ 68H ; Ready List Root
xiosentry equ 28H ; offset of double word pointer in
; the system data segment of XIOS entry
io_statline equ 8 ; update XIOS status line
tod_offset equ 07Eh
sec_flag equ 2
min_flag equ 3
; TOD format
tod_day equ word ptr 0
tod_hour equ byte ptr 2
tod_min equ byte ptr 3
tod_sec equ byte ptr 4
; PD fields
p_uda equ 10h ; offset of UDA segment in PD
pdlen equ 48 ; length of process descriptor
ps_run equ 0 ; PD run status
pf_keep equ 2 ; PD nokill flag
; RSP format
rsp_top equ 0 ; rsp offset
rsp_pd equ 010h ; PD offset
rsp_uda equ 040h ; UDA offset
rsp_bottom equ 140h ; end rsp header
;*****************************************************
;*
;* CLOCK CODE SEGMENT
;*
;*****************************************************
cseg
org 0
ccpm: int ccpmint ! ret
clock: ; Clock process starts here
mov ds,sysdat
mov si,.rlr ! mov es,p_uda[si] ; ES is never saved.
; Note if other ccpm system calls
; are added to this program, ES
; may be changed.
mov bx,tod_offset
; Loop forever
clockloop:
; BX -> TOD structure in SYSDAT
; Wait for Seconds Flag
mov cx,dev_flagwait ! mov dx,sec_flag
push bx
call ccpm
; Call XIOS status line update.
; ES=UDA, DS=system data segment
mov ax,io_statline
xor cx,cx ! mov dx,cx
callf dword ptr .xiosentry
pop bx
; increment seconds
clc
mov al,tod_sec[bx]
inc al ! daa ! mov tod_sec[bx],al
; check for minute mark
cmp al,60h ! jae update_min
jmp clock_loop
update_min:
; set minute flag
mov tod_sec[bx],0
; mov cx,dev_flagset ! mov dx,min_flag
; push bx ! call ccpm ! pop bx
; increment minute field of TOD
clc ! mov al,tod_min[bx]
inc al ! daa ! mov tod_min[bx],al
; check if hour
cmp al,60h ! jae update_hour
jmp clock_loop
update_hour:
;update hour field
mov tod_min[bx],0
clc ! mov al,tod_hour[bx]
inc al ! daa ! mov tod_hour[bx],al
; check for day
cmp al,24h ! jae update_day
jmp clock_loop
update_day:
; update Day field
mov tod_hour[bx],0
inc tod_day[bx]
jmp clock_loop ; loop forever
;*****************************************************
;*
;* Data Segment
;*
;*****************************************************
dseg
org 0
sysdat dw 0,0,0
dw 0,0,0
dw 0,0
org rsp_pd
dw 0,0 ; link,thread
db ps_run ; status
db 190 ; priority
dw pf_keep ; flags
db 'CLOCK ' ; name
dw offset uda/10h ; uda seg
db 0,0,0,0 ; dsk,usr,ldsk,luser
dw 0 ; mem partitions
dw 0,0 ; dvract,wait
db 0,0 ; org,net
dw 0 ; parent
db 0,0,0,0 ; cns,abort,cin,cout
db 0,0,0,0 ; lst,sf3,sf4,sf5
dw 0,0,0,0 ; reserved,pret,scratch
org rsp_uda
uda dw 0,0,0,0 ;0-7 note: no default DMA
dw 0,0,0,0 ;8-fh
dw 0,0,0,0 ;10-17
dw 0,0,0,0 ;18-1f
dw 0,0,0,0 ;20-27
dw 0,0,0,0 ;28-2f
dw 0,0,offset stack_top,0 ;30-37
dw 0,0,0,0 ;38-3f
dw 0,0,0,0 ;40-47
dw 0,0,0,0 ;48-4f
dw 0,0,0,0 ;50-57
dw 0,0,0,0 ;58-5f
db 1 ;60 INSYS <> 0
;don't switch from
;from UDA stack
;on entry to SUP
db 0
dw 0cccch,0cccch,0cccch ;62-67
dw 0cccch,0cccch,0cccch,0cccch ;68-6F
dw 0cccch,0cccch,0cccch,0cccch ;70
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;80
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;90
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;A0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;B0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;C0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;D0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;E0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;F0
dw 0cccch
stack_top dw offset clock ; code starting point
dw 0 ; code seg - set by GENSYS
dw 0 ; init. flags - set by GENSYS
; UDA is 100H bytes long
end


View File

@@ -0,0 +1,192 @@
;
; ECHO - Resident System Process
; Print Command tail to console
;
;
; DEFINITIONS
;
ccpmint equ 224 ;ccpm entry interrupt
c_writebuf equ 9 ;print string
c_detach equ 147 ;detach console
c_setnum equ 148 ;set default console
q_make equ 134 ;create queue
q_open equ 135 ;open queue
q_read equ 137 ;read queue
q_write equ 139 ;write queue
p_priority equ 145 ;set priority
pdlen equ 48 ;length of Process
; Descriptor
p_cns equ byte ptr 020h ;default cns
p_disk equ byte ptr 012h ;default disk
p_user equ byte ptr 013h ;default user
p_list equ byte ptr 024h ;default list
ps_run equ 0 ;PD run status
pf_keep equ 2 ;PD nokill flag
rsp_top equ 0 ;rsp offset
rsp_pd equ 010h ;PD offset
rsp_uda equ 040h ;UDA offset
rsp_bottom equ 140h ;end rsp header
qf_rsp equ 08h ;queue RSP flag
;
; CODE SEGMENT
;
CSEG
org 0
ccpm: int ccpmint
ret
main: ;create ECHO queue
mov cl,q_make ! mov dx,offset qd
call ccpm
;open ECHO queue
mov cl,q_open ! mov dx,offset qpb
call ccpm
;set priority to normal
mov cl,p_priority ! mov dx,200
call ccpm
;ES points to SYSDAT
mov es,sdatseg
loop: ;forever
;read cmdtail from queue
mov cl,q_read ! mov dx,offset qpb
call ccpm
;set default values from PD
mov bx,pdadr
; mov dl,es:p_disk[bx] ;p_disk=0-15
; inc dl ! mov disk,dl ;make disk=1-16
; mov dl,es:p_user[bx]
; mov user,dl
; mov dl,es:p_list[bx]
; mov list,dl
mov dl,es:p_cns[bx]
mov console,dl
;set default console
; mov dl,console
mov cl,c_setnum ! call ccpm
;scan cmdtail and look for '$' or 0.
;when found, replace w/ cr,lf,'$'
lea bx,cmdtail ! mov al,'$' ! mov ah,0
mov dx,bx ! add dx,131
nextchar:
cmp bx,dx ! ja endcmd
cmp [bx],al ! je endcmd
cmp [bx],ah ! je endcmd
inc bx ! jmps nextchar
endcmd:
mov byte ptr [bx],13
mov byte ptr 1[bx],10
mov byte ptr 2[bx],'$'
;write command tail
lea dx,cmdtail ! mov cl,c_writebuf
call ccpm
;detach console
mov dl,console
mov cl,c_detach ! call ccpm
;done, get next command
jmps loop
;
; DATA SEGMENT
;
DSEG
org rsp_top
sdatseg dw 0,0,0
dw 0,0,0
dw 0,0
org rsp_pd
pd dw 0,0 ; link,thread
db ps_run ; status
db 190 ; priority
dw pf_keep ; flags
db 'ECHO ' ; name
dw offset uda/10h ; uda seg
db 0,0 ; disk,user
db 0,0 ; load dsk,usr
dw 0 ; mem
dw 0,0 ; dvract,wait
db 0,0
dw 0
db 0 ; console
db 0,0,0
db 0 ; list
db 0,0,0
dw 0,0,0,0
org rsp_uda
uda dw 0,offset dma,0,0 ;0
dw 0,0,0,0
dw 0,0,0,0 ;10h
dw 0,0,0,0
dw 0,0,0,0 ;20h
dw 0,0,0,0
dw 0,0,offset stack_tos,0 ;30h
dw 0,0,0,0
dw 0,0,0,0 ;40h
dw 0,0,0,0
dw 0,0,0,0 ;50h
dw 0,0,0,0
dw 0,0,0,0 ;60h
org rsp_bottom
qbuf rb 131 ;Queue buffer
qd dw 0 ;link
db 0,0 ;net,org
dw qf_rsp ;flags
db 'ECHO ' ;name
dw 131 ;msglen
dw 1 ;nmsgs
dw 0,0 ;dq,nq
dw 0,0 ;msgcnt,msgout
dw offset qbuf ;buffer addr.
dma rb 128
stack dw 0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch
stack_tos dw offset main ; start offset
dw 0 ; start seg
dw 0 ; init flags
pdadr rw 1 ; QPB Buffer
cmdtail rb 129 ; starts here
db 13,10,'$'
qpb db 0,0 ;must be zero
dw 0 ;queue ID
dw 1 ;nmsgs
dw offset pdadr ;buffer addr.
db 'ECHO ' ;name to open
console db 0
;disk db 0
;user db 0
;list db 0
end


View File

@@ -0,0 +1,90 @@
:0400000300000000F9
:1B000081E90500E92E0000008CC88ED88EC08ED0BC84088C0EAC07FF1EAA0796
:1B001B81C706AA07030933C01E8ED8C706800303008C0E82031FE9D208FC8C6C
:1B003681D80E1F8C06F707A3C3088BDC36F7470400027401FB1E07565755E8CB
:1B0051810E005D5F5E8E06F7078E1EC3088BC3CF80F90E7506BEC700E96400F1
:1B006C8180F90F7506BECA00E9590080F9147506BECD00E94E0080F91A741347
:1B00878180F920741380F92C741F80F933742CBBFFFFC38916C508C38AC23C06
:1B00A281FF75058A1EC007C3240FA2C007C38AC233DB0AC074083C817304A242
:1B00BD81C307C34BC38916C708C3A00601AA0601D40603A1BF07A3C908B9070B
:1B00D8810033C0BFAE07F3AA8916C108803EC3070174082EF6840200027508F2
:1B00F381E861008B1EB007C38936F207A1C508A3F4072E8AA40200E86E00C6C7
:1B010E8106F607FFA0C307A2B407508B36F2078B16C108E833008A1EB0070A94
:1B012981DB74098A3EC307582AF8EB0D8106C508800058FEC875D533DB891EED
:1B014481B007A1F407A3C508C606F60700E84B00E99FFFE8EE01892684082E99
:1B015F81FF940000803EB207007406A0AE07A28608803EAF07FF7503E8250003
:1B017A81C3B121F606F607FF751AC606AF07FF880EF90732ED8B36C108BF86C8
:1B019581081E8E1EC308F3A41FC3F606F607FF75F88A0EF90732EDBE86088BC5
:1B01B0813EC108068E06C308F3A407C3B001A2B007C306FF1EAA07FC07C38BF4
:1B01CB8116EA078A2EEC078A1EC407B701863EB50753FF36BB07FF36BD07FFF9
:1B01E68136ED07FF36EF07FF1EAA0783C40AFC1E07C3B501EB07C606C407FFE7
:1B020181B504B1FF890EB0078B268408E953FF32ED8BF28BFBF3A4C38AC8B0B4
:1B021C8109E8A2FF0BDB743083C3088BF3BFC807B90A00F3A48B36C807BFD255
:1B02378107B91100F3A48A0EE107D326D207A0D8070AC07402B001FEC8A2E5B4
:1B02528107F9C3B00AE870FF0AC074F6E997FFA1EA0733D28A16EC07F736D260
:1B026D81070306DF07A3BB078A0EE107D3EA8916BD07C38A0ED4078A2EE8071D
:1B028881D2EDF6D980C107A0E707D2E002C5C3BB960803D9803EE507007405E2
:1B02A3818A1F32FFC303D98B1FC3E8D0FFA2E4078AC832EDE8DDFF891EEA07C8
:1B02BE810BDBC38A0ED407A1EA0732FF8ADCD3E0D3E393A0E8072206D507A22E
:1B02D981B6070AD8891EEA078826EC07C3A0A608A2E807803E9508007508E84F
:1B02F481A3008AC8E8A101A095083C817202B080A2E607A0D60722069208A2E1
:1B030F81E707C3B0010206E807A2A608803E9508807306A0E607A29508C38A3C
:1B032A811EF10732FF031EC607C3A1CB08B102D3E8A3EA07C606EC0700B40353
:1B034581E8A503A1C708A3ED07A1C508A3EF07C3BBCB08833FFFC3C706CB0809
:1B036081FFFFC38B16D9078B1ECB0843891ECB082BD372E8A0CB082403B105DE
:1B037B81D2E0A2F1070AC07503E8ADFFC3518A2ED607F6D522CD22C52AC1246B
:1B0396811F59C3BBA608BA0110FECE4B803F0075060AF675F4FECA8816E40751
:1B03B181803EE507FF8AC67402D0E8B1072A0ED407D2E88A26D6073AE072D318
:1B03CC81BB92088A0FF6D480E41F22E10AC4C3BB8608891EC107880ECD08C3E0
:1B03E781B10FE8EFFFE86DFFE871FFE860FF74178B16C107E82BFF8A0ECD087E
:1B04028132ED8A0724EF3A07740BEBE1B0FF8AE8FEC5E9A7FD0AC974328BF2A8
:1B041D81AC247F80FD0D741D80FD0C740F80FD0E7502243F2A07247F7513EB21
:1B04388109518A0FE849FF5975084243FEC5FEC9EBCDE9A2FF32C0A2B0078A09
:1B045381E8FEC5C3BB8608E807007517B009E97602B90B3F438AC52A0722C514
:1B046E817406FEC975F30AC0C3E86DFF74FA534B4B8A2750E8A4FE8BD3BB86E7
:1B04898108B120E881FDE807FF8AC8585B88074B4B882732EDBE95088A072A9C
:1B04A481C1740B8AC57304B0800A048804C3380475FB32C088043806E4077462
:1B04BF81F1C60480C3A095083C817205247FA29508C3A09408A2E307BB920870
:1B04DA818A078AC8FEC1E8A5FE7503E93A00B01F22C18807750B83C302FE07B0
:1B04F5818A07243F7413E8E9FE740EE879FFE8E0FD32C0A2E807E9B0FCBB9215
:1B05108108A0E3078847028A07FEC8241F8807E99AFC880FE872FE8AC83A07C2
:1B052B817305FE0FE98AFCE88FFFE864FFEBC9E8A9FDA0E8073A06E607720E01
:1B0546813C807528E884FF803EB00700751EE856FD7419E865FDE81600720EBD
:1B0561817503E97F01E8DFFDE8F5FCE8E6FCE9A0FDE947FC8A2EB607A0B30735
:1B057C813C027207FEC8A2B307F9C3A0E2078AC822C5740A0AC9740332C0C30F
:1B0597810C01C38AF1F6D6A0B4073C0272EBBBE8078A2702C43C807202B0803A
:1B05B28151C6077F53508AD8A0D5078AD0FEC2F6D022E0A0E60722C63AC372C9
:1B05CD81028AC32AC43AC2724350E8A6FC8AE8A0E4073AC58AD0741E8AC8513F
:1B05E881B500E8AAFC5341E8A5FC5A423BDA74F5FEC95A8AC63AC172028AC1D2
:1B0603812AC28AE8FEC5A0D507FEC0F6E55986C13AC172028AC1595B882F5907
:1B061E818A36B4072AC53AC672028AC6F6D122C1740EA2B3078A0EE107D2E850
:1B063981A2B5070C01C38816C908A0C9083A06C4077505FEC07405C33C1072DA
:1B06548103E9A4FBA2E907A2C40733D2E8B6FB73F0C3E812FBB17FBB8D082027
:1B066F810F204F018067051FC606B207FFA08608A2AE07241FFEC83CFF7403A1
:1B068A81A2C908E8B3FFA0CA08A28608C3B5008BF38BFAF3A6C3E89CFFA0C962
:1B06A58108A2BF07C3E8B9FFC606940800E8A2FDE8BFFDE8030032C0C3E89437
:1B06C081FC74FABBA608803FFF7505A0930888075BB140C3E88FFFE960FE8A73
:1B06DB81C8A2B107E82CFDE924FBB401E80D00E925FC8C1EED078B1ECE07EB8D
:1B06F6810A8B1ED007C706ED0700008826B7078A0EE207A0EA0722C1A2B8075B
:1B071181F6D1200EEA078B1F891EB9078B470A833EED07007505A3ED0733C0C0
:1B072C81A3EF07E85200803FFF7405E85DFF74158B1EB907C607FFB002E84645
:1B07478100E83900E8C2FAC6050032C08A26B807D1E88B36EF0703F0A0B70764
:1B0762813C0375058936C607C3B940008B3EC508A1C7088B16ED071E068EDAD3
:1B077D818EC0F3A5071FC38B1EB907BAE907B104C350E8CFFA58FEC87803E804
:12079881BBFABEBB078B3EB90783C706B90200F3A5C3AA
:1B07AA820009000000000000000000010000000000000000000000000001FFA8
:1B07C68200000000000000000000000000000000000000000000000000000096
:1B07E18200000000000000000000000000000000000000000000000000CCCCE3
:1B07FC82CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDC
:1B081782CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC0
:1B083282CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA5
:1B084D82CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC8A
:1B086882CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC6F
:01088382CC26
:1B088682434F50595249474854284329313938332C4449474954414C205245D2
:1B08A1825345415243482830312F32362F383329585858582D303030302D3671
:1308BC8235343332310000000000000000000000000000A8
:00000001FF
CCCCCCCCCCCCCCCCCCCCCCCCCCDC
:1B081782CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC0
:1B083282CCCCCCCCCC

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,237 @@
;****************************************************************
;* *
;* TCOPY - Example program to write the system track *
;* for a Concurrent CP/M-86 Boot Disk on the *
;* IBM Personel Computer *
;* *
;****************************************************************
; This program is used to read a binary image file of
; track 0. This track is used to bootstrap Concurrent
; CP/M-86. The file TCOPY reads has no CMD header and
; must be the same size as the track we are going
; to write.
; This program is intended to serve as an example
; to be modified by the OEM for differently sized loaders,
; and differently sized system track(s).
; Note: TCOPY must be run under CP/M-86 and not Concurrent
; CP/M-86 since TCOPY performs direct BIOS calls.
; The command
; GENCMD TCOPY
; is used to generate the CMD form of this program.
title 'TCOPY - Copy Track 0'
;CP/M-86, CCP/M-86 function names
;console functions
c_read equ 1
c_writebuf equ 9
;file functions
f_open equ 15
f_readrand equ 33
f_setdma equ 26
f_setdmaseg equ 51
;drive functions
drv_get equ 25
;system functions
s_termcpm equ 0
s_dirbios equ 50
;direct Bios Parameter Block
bpb_func equ byte ptr 0
bpb_cx equ word ptr 1
bpb_dx equ word ptr 3
;ASCII linefeed and carriage return
lf equ 10
cr equ 13
;how many 128 byte records to read for a loader image
records_to_read equ 8 * 4
;8 = number of physical sectors per track
;4 = number of 128 sectors per
;physical sector
cseg ;use CCP stack
mov cl,c_writebuf ;display sign on message
mov dx,offset sign_on_msg
int 224
mov cl,drv_get ;get default drive number
int 224
test al,al ;must run on drive A:
jz drive_ok
mov dx,offset drive_msg
jmp error
drive_ok:
mov cl,f_open ;open the file given as
mov dx,offset fcb ;the 1st command parameter,
int 224 ;it is put at 05CH by
cmp al,0ffh ;the program load
jne file_ok
mov dx,offset open_msg
jmp error
file_ok:
mov current_dma,offset track0_buffer
mov r0,0 ;start with sector 0, assume
mov cx,records_to_read ;no CMD header in the file
file_read:
push cx ;keep the record count
mov cl,f_setdma
mov dx,current_dma
int 224
mov cl,f_readrand ;user r0,r1,r2 for random
mov dx,offset fcb ;reads
int 224
pop cx ;restore the record count
test al,al
jz read_ok
mov dx,offset read_msg
jmp error
read_ok:
add current_dma,128 ;set the DMA for the next sector
inc r0 ;add one to the random record field
loop file_read
; We have the Track 0 image in RAM
; Ask for destination diskette
next_diskette:
mov cl,c_writebuf
mov dx,offset new_disk_msg
int 224
mov cl,c_read ;wait for a keystroke
int 224
; Using CP/M-86 function 50, Direct bios call,
; write the track image in TRACK0_BUFFER to
; track 0, on drive A:.
call select_disk ;select A:
call set_track ;set track to 0
call set_dmaseg ;set DMA segment = DS
mov current_sector,0 ;sectors are relative to 0 in BIOS
mov current_dma,offset track0_buffer
mov cx,32 ;number of 128 byte sectors to write
next_sector:
push cx ;save sector count
call set_dmaoff
call set_sector
call write_sector
add current_dma,128 ;next area of memory to write
inc current_sector ;next sector number
pop cx ;restore sector count
loop next_sector
jmp track_ok
select_disk:
mov al,9 ;BIOS function number of seldsk
xor cx,cx ;always drive A:
mov dx,cx
jmps bios
set_track:
mov al,10 ;BIOS function number of settrk
xor cx,cx ;go to track 0
jmps bios
set_dmaseg:
mov al,17 ;BIOS function number of setdmab
mov cx,ds ;dma segment we want to use
jmps bios
set_dmaoff:
mov al,12 ;BIOS function number of setdma
mov cx,current_dma
jmps bios
set_sector:
mov al,11 ;BIOS function number of setsec
mov cx,current_sector
jmps bios
write_sector:
mov al,14 ;BIOS function number of write sector
jmps bios ;error checking can be added here
bios:
mov bx,offset bpb ;fill in BIOS Paramenter Block
mov bpb_func[bx],al
mov bpb_cx[bx],cx
mov bpb_dx[bx],dx
mov cl,s_dirbios
mov dx,bx
int 224
ret
track_ok:
mov cl,c_writebuf ;does the user want to write
mov dx,offset continue_msg ;to another diskette ?
int 224
mov cl,c_read ;get response
int 224
and al,05FH ;make upper case
cmp al,'Y'
jne done
jmp next_diskette
error:
push dx
call crlf
pop dx
mov cl,c_writebuf
int 224
done:
mov cx,s_termcpm
mov dx,cx
int 224
crlf:
mov dx,offset crlf_msg
mov cl,c_writebuf
int 224
ret
dseg
org 5ch
fcb rb 33
r0 dw 0
r3 db 0
org 100h
sign_on_msg db 'Example TCOPY for IBM PC', cr, lf
db 'Reads track image file and writes '
db 'it on track 0$'
new_disk_msg db cr,lf,'Put destination diskette in A:'
db cr,lf
db 'Strike any key when ready $'
continue_msg db cr,lf,'Write another Track 0 (Y/N) ? $'
crlf_msg db cr,lf,'$'
drive_msg db 'TCOPY runs only on drive A:$'
open_msg db 'Give file name containing track 0 '
db 'image, after TCOPY command$'
read_msg db 'File is not long enough$'
write_msg db 'Error writing on track 0$'
track0_buffer rb 1000H ;4K tracks
bpb rb 5 ;direct Bios Parameter Block
current_dma dw 0
current_sector dw 0


View File

@@ -0,0 +1,629 @@
;*****************************************************
;*
;* Terminal Message Processor
;*
;* The TMP determines the user interface to CCP/M.
;* Much of the interface is available though
;* system calls. This TMP takes advantage of
;* as much as possible for simplicity. The TMP
;* could, for instance, be easily modified to
;* force logins and have non-standard defaults.
;*
;* With a little more work, the TMP could do all
;* command parsing and File Loading instead of
;* using the CLI COMMAND FUNCTION.
;* Suggestions are given in the CCP/M-86 SYSTEM'S GUIDE.
;*
;*****************************************************
title 'Terminal Message Processor - CCP/M-86 2.0'
; Some common equates
true equ 0ffh
false equ 0
cr equ 13 ; carraige return
lf equ 10 ; linefeed
tab equ 9 ; tab char
; CCP/M-86 system functions used by the TMP
osint equ 224 ; interrupt number for CCP/M
; system calls
c_write equ 2 ; console functions
c_writebuf equ 9
c_readbuf equ 10
c_attachc equ 146
c_detachc equ 147
c_setnum equ 148
l_setnum equ 160 ; list device functions
l_getnum equ 164
f_open equ 15 ; file functions
f_close equ 16
f_read equ 20
f_setdma equ 26
f_parse equ 152
drv_set equ 14 ; drive functions
drv_get equ 25
drv_free equ 39
dir_usernum equ 32 ; directory functions
p_cli equ 150 ; process control functions
; Process descriptor flags
ps_run equ 00 ; on ready list root
pf_sys equ 001h ; system process
pf_keep equ 002h ; do not terminate
; Some locations in the system data segment
s_ccpmseg equ word ptr 40H ;begin CCPM segment
s_sysdisk equ byte ptr 04bh ;system disk
s_ncns equ byte ptr 47H ;sys. consoles
s_version equ word ptr 78h ;ofst ver. str in SUP
; Some RSP format equates
rsp_top equ 0
rsp_md equ 008h
rsp_pd equ 010h
rsp_uda equ 040h
rsp_bottom equ 140h
; Error codes returned by the CLI
e_no_memory equ 3 ; cant find memory
e_no_pd equ 12 ; no free pd's
e_q_full equ 15 ; full queue
e_illdisk equ 23 ; illegal disk #
e_badfname equ 24 ; illegal filename
e_badftype equ 25 ; illegal filetype
e_bad_load equ 28 ; bad ret. from BDOS load
e_bad_read equ 29 ; bad ret. from BDOS read
e_bad_open equ 30 ; bad ret. from BDOS open
e_nullcmd equ 31 ; null command sent
e_ill_lst equ 37 ; illegal list device
e_ill_passwd equ 38 ; illegal password
e_abort equ 40 ; aborted in CLI
;*****************************************************
;*
;* TMP Shared Code and Constant Area
;*
;*****************************************************
cseg
org 0
jmps tmp
db 'COPYRIGHT (c) 1983, DIGITAL RESEARCH 3/28/83. '
;===
tmp: ; PROGRAM MAIN - INITIALIZATION
;===
; Set default console # = TMP#
mov dl,defconsole ! call setconsolenum
; Set default disk = system drive
push ds ! mov ds,sysdatseg
mov dl,.s_sysdisk ! pop ds ;get system drive from
call setdisk ;system data segment
xor dl,dl ;all TMPs come up user 0
call setuser
call attach ;print version
push ds ! mov ds,sysdatseg
mov dx,.s_version
mov ds,.s_ccpmseg
call print_ds_string ! pop ds
call detach
push ds ! pop es
mov si,offset pd_ascii_num
mov di,offset startupnum
mov cx,3
rep movsb
mov dx,offset fcb
mov cl,f_open ;try to open the startup file
call ccpm ;on default drive which is
cmp al,0ffh ;the system drive
je nostartup
mov dx,offset clicb_cmd ;use the CLI buffer for this
mov cl,f_setdma ;one time one sector read
call ccpm
mov dx,offset fcb
mov cl,f_read
call ccpm
push ax
mov dx,offset fcb
mov cl,f_close
call ccpm
pop ax
test al,al
jnz nostartup
mov ax,ds
mov es,ax
mov al,cr
mov cx,128
mov di,offset clicb_cmd
repne scasb
jne nostartup ;didn't find a carriage return
inc di ;include cr lf in line
mov byte ptr [di],'$'
sub di,offset clicb_cmd
mov ax,di
sub ax, 2
mov read_blen, al
mov dx,offset supmsg
call printstring
mov dx,offset clicb_cmd
call print_ds_string
jmps startup
nostartup:
; THIS IS WHERE A LOGIN ROUTINE MIGHT
; BE IMPLEMENTED. THE DATA FILE THAT
; CONTAINS THE USER NAME AND PASSWORD
; MIGHT ALSO CONTAIN AN INITIAL DEFAULT
; DISK AND USER NUMBER FOR THAT USER.
;===========
nextcommand: ; LOOP FOREVER
;===========
; free drive
mov dx,0ffffh ! call drive_free
; attach console
call attach
; print CR,LF if we just sent command
cmp cmdsent,false ! je noclearline
mov cmdsent,false
call crlf
noclearline:
; set up and print user prompt
; get current default user # and disk
; this call should be made on every
; loop in case the last command
; has changed the default.
mov dl,cr ! call prchar
call getuser
test bl,bl ! jz nozero ;don't print user 0 prompt
mov dl,bl ! call prnum
nozero:
call getdisk
mov dl,'A' ! add dl,bl
call prchar
mov dx,offset prompt
call print_string
; Read Command from Console
mov dx,offset read_buf ! call conreadbuf
startup:
; echo newline
mov dl,lf ! call prchar
; make sure not a null command
lea bx,clicb_cmd
cmp read_blen,0 ! je gonextcmd
deblank:
cmp byte ptr [bx],' ' ! je zapblank
cmp byte ptr [bx],tab ! jne noblanks
zapblank:
inc bx ! dec read_blen ! jmps deblank
noblanks:
lea ax,clicb_cmd ! cmp ax,bx ! je chksemi
; remove leading blanks
push ds ! pop es ! xor ch,ch ! mov cl,read_blen
mov di,ax ! mov si,bx ! cld ! rep movsb
mov bx,ax
chksemi: ; see if line starts with semicolon
cmp byte ptr [bx],';' ! je gonextcmd
; see if disk change
; if 'X:' change def disk to X
cmp read_blen,2 ! jne clicall
cmp byte ptr 1[bx],':'
jne clicall
; change default disk
mov dl,[bx] ;get disk name
and dl,5fh ;Upper Case
sub dl,'A' ;disk number
; check bounds
cmp dl,0 ! jb baddrive
cmp dl,15 ! ja baddrive
; select default disk
call setdisk ! jmp gonextcmd
baddrive: mov dx,offset errstr ! call printstring
mov dx,offset drverr ! call printstring ! call crlf
gonextcmd: jmp nextcommand
;=======
clicall: ; SEND CLI COMMAND
;=======
; put null at end of input
mov bx,offset clicb_cmd
mov al,read_blen ! mov ah,0
add bx,ax ! mov byte ptr [bx],0
; copy command string for error
; reporting later and to check
; for built in commands...
mov cx,64
mov si,offset clicb_cmd
mov di,offset savebuf
push ds ! pop es
rep movsw
; parse front to see if
; built in command
mov si,offset fcb
mov di,offset savebuf
call parsefilename
jcxz goodparse
sub bx,bx ! mov bl,read_blen
add bx,offset savebuf
mov byte ptr [bx],'$'
jmp clierror
goodparse: mov parseret,bx
cmp bx,0 ! jne haveatail
mov bl,read_blen
add bx,offset savebuf
haveatail: mov byte ptr [bx],'$' ! inc bx
cmp fcb,0 ! je try_builtin
jmp not_builtin
; is it USER command?
try_builtin: mov si,offset fcb ! inc si
mov di,offset usercmd
push cs ! pop es
mov cx,4 ! repz cmpsw
jnz notuser
mov si,offset fcb
mov di,parseret
cmp di,0 ! je pruser
inc di
call parsefilename
cmp cx,0 ! jne pruser
mov si,offset fcb
inc si
mov dx,[si]
call a_to_b
cmp bl,15 ! ja usererr
mov dl,bl
call setuser
jmp pruser
usererr: mov dx,offset usererrmsg
call printstring
pruser: mov dx,offset usermsg
call printstring
call getuser
mov dl,bl ! call prnum
call crlf
jmp nextcommand
notuser:
mov si,offset fcb ! inc si
mov di,offset printercmd
push cs ! pop es
mov cx,4 ! repz cmpsw
jnz notprinter
mov si,offset fcb
mov di,parseret
cmp di,0 ! je prprinter
inc di
call parsefilename
cmp cx,0 ! jne prprinter
mov si,offset fcb
inc si
mov dx,[si]
call a_to_b
cmp bl,0ffh
je printererr
mov dl,bl
call setlist
jcxz prprinter
printererr: mov dx,offset printemsg
call printstring
prprinter: mov dx,offset printermsg
call printstring
call getlist
mov dl,bl ! call prnum
call crlf
jmp nextcommand
notprinter:
not_builtin:
; initialize Cli Control Block
mov clicb_net,0
; make cli call
mov cmdsent,true
lea dx,clicb ! mov cl,p_cli
call ccpm
cmp bx,0 ! jne clierror
jmp nextcommand
;========
clierror:
;========
; Cli call unsuccesful, analyze and display err msg
; input: CX = ERROR CODE
mov si,(offset clierrtab)-4
nexterr:
add si,4
cmp cs:word ptr [si],0ffffh ! je unknownerr
cmp cx,cs:[si] ! jne nexterr
unknownerr:
mov dx,cs:2[si]
; jmps showerr
showerr: ; Print Error String
;------- ; input: DX = address of Error
; string in CSEG
; if DX=0 then NULL COMMAND
cmp dx,0 ! jne perr
mov cmdsent,false ! jmp nextcommand
perr: push dx ! call crlf
mov dx,offset errstr ! call printstring
pop dx ! call printstring ! call crlf
mov dx,offset cmdstr ! call printstring
mov dx,offset savebuf ! call print_ds_string ! call crlf
jmp nextcommand
parsefilename: ; SI = fcb DI = string
mov cx,f_parse
mov bx,offset pcb
mov [bx],di ! mov 2[bx],si
mov dx,bx ! jmp ccpm
a_to_b: ;dl = 1st char, dh = 2nd char
cmp dh,' ' ! jne atob2char
mov dh,dl ! mov dl,'0'
atob2char: cmp dh,'0' ! jb atoberr
cmp dh,'9' ! ja atoberr
cmp dl,'0' ! jb atoberr
cmp dl,'9' ! ja atoberr
sub dh,'0' ! sub dl,'0'
mov ax,0 ! mov al,dl
push dx ! mov cl,10
mul cl ! pop dx
mov dl,dh ! mov dh,0
add ax,dx
mov bx,ax ! ret
atoberr: mov bl,0ffh ! ret
prnum: ; dl = num (0-15)
cmp dl,10 ! jb prnum_one
push dx
mov dl,'1' ! call prchar
pop dx ! sub dl,10
prnum_one: add dl,'0'
; jmp prchar
prchar: mov cl,c_write ! jmp ccpm
getuser: mov dl,0ffh
setuser: mov cl,dir_usernum ! jmp ccpm
crlf: mov dx,offset crlfstr
;jmps printstring
printstring: push ds ! mov ax,cs ! mov ds,ax
call print_ds_string ! pop ds ! ret
print_ds_string:mov cl,c_writebuf ! jmps ccpm
setconsolenum: mov cl,c_setnum ! jmps ccpm
setdisk: mov cl,drv_set ! jmps ccpm
getdisk: mov cl,drv_get ! jmps ccpm
setlist: mov cl,l_setnum ! jmps ccpm
getlist: mov cl,l_getnum ! jmps ccpm
attach: mov cl,c_attachc ! jmps ccpm
detach: mov cl,c_detachc ! jmps ccpm
con_readbuf: mov cl,c_readbuf ! jmps ccpm
drivefree: mov cl,drv_free !; jmps ccpm
;====
ccpm: ; INTERFACE ROUTINE FOR SYSTEM ENTRY POINTS
;====
int osint ! ret
;*****************************************************
;*
;* CONSTANTS (IN SHARED CODE SEGMENT)
;*
;*****************************************************
clierrtab dw e_nullcmd, 0 ;null command
dw e_no_memory, memerr ;No memory
dw e_no_pd, pderr ;No unused PD
dw e_badfname, fnameerr;Ill. command
dw e_illdisk, fnameerr;Ill. disk
dw e_ill_passwd, fnameerr;Ill. password
dw e_badftype, fnameerr;Ill. type
dw e_bad_load, loaderr ;
dw e_bad_read, loaderr ;
dw e_bad_open, openerr ;
dw e_q_full, qfullerr;
dw e_abort, aborterr;
; a few extra entries for future errors
dw 0ffffh, catcherr;
dw 0ffffh, catcherr;
dw 0ffffh, catcherr;
dw 0ffffh, catcherr;
prompt db '>$'
crlfstr db 13,10,'$'
errstr db 'CP/M Error: $'
memerr db 'Not Enough Memory$'
pderr db 'PD Table Full$'
fnameerr db 'Bad File Spec$'
catcherr rb 0 ;Unknown Errs give
loaderr db 'Load Error$' ; Load Error Msg
openerr db 'Can''t Find Command$'
qfullerr db 'RSP Command Que Full$'
aborterr db 'CLI Abort$'
drverr db 'Invalid Drive$'
cmdstr db 'Command = $'
usererrmsg db 13,10,'Invalid User Number,'
db ' IGNORED',13,10,'$'
usermsg db 13,10,'User Number = $'
printemsg db 13,10,'Invalid Printer Number,'
db ' IGNORED',13,10,'$'
printermsg db 13,10,'Printer Number = $'
usercmd db 'USER '
printercmd db 'PRINTER '
supmsg db 'Start up command: $'
;*****************************************************
;*
;* TMP Data Area - this area is copied once for
;* each system console. The 'defconsole'
;* field is unique for each copy
;* - Each Data Area is run by a common
;* shared code segment.
;*
;*****************************************************
DSEG
org rsp_top
sysdatseg dw 0
sdatvar dw s_ncns
defconsole db 0,0
dw 0,0,0,0,0
org rsp_pd
pd dw 0,0 ; link fields
db ps_run ; status
db 198 ; priority
dw pf_sys+pf_keep ; flags
db 'Tmp' ; Name
pd_ascii_num db ' ' ; Ascii number field set by GENSYS
dw offset uda/10h ; uda seg
db 0,0 ; disk,user
db 0,0 ; ldisk,luser
dw 0ffffh ; mem
dw 0,0 ; dvract,wait
db 0,0 ; org,net
dw 0 ; parent
db 0,0 ; cns,abort
db 0,0 ; cin,cout
db 0,0 ; lst,sf3
db 0,0 ; sf4,sf5
dw 0,0 ; reserved
dw 0,0 ; pret,scratch
org rsp_uda
uda dw 0,0,0,0 ;0-7 note: no default DMA
dw 0,0,0,0 ;8-fh
dw 0,0,0,0 ;10-17
dw 0,0,0,0 ;18-1f
dw 0,0,0,0 ;20-27
dw 0,0,0,0 ;28-2f
dw 0,0,offset stack_top,0 ;30-37
dw 0,0,0,0 ;38-3f
dw 0,0,0,0 ;40-47
dw 0,0,0,0 ;48-4f
dw 0,0,0,0 ;50-57
dw 0,0,0,0 ;58-5f
db 1 ;60 INSYS <> 0
;don't switch from
;from UDA stack
;on entry to SUP
db 0 ;61
dw 0,0 ;62-64
db 0 ;66
dw 0 ;67-68
db 0 ;69
dw 0cccch,0cccch,0cccch ;6A-6F
dw 0cccch,0cccch,0cccch,0cccch ;70
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;80
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;90
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;A0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;B0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;C0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;D0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;E0
dw 0cccch,0cccch,0cccch,0cccch
dw 0cccch,0cccch,0cccch,0cccch ;F0
dw 0cccch
stack_top dw offset tmp ; code starting point
dw 0 ; code seg - set by GENSYS
dw 0 ; init. flags - set by GENSYS
; UDA is 100H bytes long
maxcmdlen equ 128
; the Read Console Buffer and the
; Cli Control Block share the same memory
read_buf rb 0
read_maxcmd db 128
clicb rb 0
clicb_net rb 0
read_blen rb 1
clicb_cmd rb maxcmdlen + 1
cmdsent db false
parseret dw 0
pcb dw offset savebuf
dw offset fcb
fcb db 0, 'STARTUP '
startupnum db ' '
rb 20
db 0 ;current record
savebuf rb 128
db 0 ;ensure hex is formed
end


File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,135 @@
$title('tables for ddt86 assembler')
$date(6/15/81)
asmtab: do;
$nolist
$include(optab.lit)
$list
declare op$tab (*) byte public data (
aaa$in, 1, 037h, 0,
aad$in, 2, 0d5h, 0ah,
aam$in, 2, 0d4h, 0ah,
aas$in, 1, 03fh, 0,
adc$in, 9, 10h, 2,
add$in, 9, 0, 0,
and$in, 10, 20h, 4,
call$in, 11, 0, 0,
callf$in, 17, 0, 0,
cbw$in, 1, 098h, 0,
clc$in, 1, 0f8h, 0,
cld$in, 1, 0fch, 0,
cli$in, 1, 0fah, 0,
cmc$in, 1, 0f5h, 0,
cmp$in, 9, 38h, 7,
cmpsb$in, 1, 0a6h, 0,
cmpsw$in, 1, 0a7h, 0,
cwd$in, 1, 099h, 0,
daa$in, 1, 027h, 0,
das$in, 1, 02fh, 0,
dec$in, 7, 0, 0,
div$in, 5, 0f6h, 6,
esc$in, 13, 0d8h, 0,
hlt$in, 1, 0f4h, 0,
idiv$in, 5, 0f6h, 7,
imul$in, 5, 0f6h, 5,
in$in, 15, 0e4h, 0,
inc$in, 7, 1, 0,
int$in, 12, 0, 0,
into$in, 1, 0ceh, 0,
iret$in, 1, 0cfh, 0,
ja$in, 3, 077h, 0,
jae$in, 3, 073h, 0,
jb$in, 3, 072h, 0,
jbe$in, 3, 076h, 0,
jc$in, 3, 072h, 0,
jcxz$in, 3, 0e3h, 0,
je$in, 3, 074h, 0,
jg$in, 3, 07fh, 0,
jge$in, 3, 07dh, 0,
jl$in, 3, 07ch, 0,
jle$in, 3, 07eh, 0,
jmp$in, 11, 1, 0,
jmpf$in, 17, 1, 0,
jmps$in, 3, 0ebh, 0,
jna$in, 3, 076h, 0,
jnae$in, 3, 072h, 0,
jnb$in, 3, 073h, 0,
jnbe$in, 3, 077h, 0,
jnc$in, 3, 073h, 0,
jne$in, 3, 075h, 0,
jng$in, 3, 07eh, 0,
jnge$in, 3, 07ch, 0,
jnl$in, 3, 07dh, 0,
jnle$in, 3, 07fh, 0,
jno$in, 3, 071h, 0,
jnp$in, 3, 07bh, 0,
jns$in, 3, 079h, 0,
jnz$in, 3, 075h, 0,
jo$in, 3, 070h, 0,
jp$in, 3, 07ah, 0,
jpe$in, 3, 07ah, 0,
jpo$in, 3, 07bh, 0,
js$in, 3, 078h, 0,
jz$in, 3, 074h, 0,
lahf$in, 1, 09fh, 0,
lds$in, 6, 0c5h, 0,
lea$in, 6, 08dh, 0,
les$in, 6, 0c4h, 0,
lock$in, 0ffh, 0f0h, 0,
lodsb$in, 1, 0ach, 0,
lodsw$in, 1, 0adh, 0,
loop$in, 3, 0e2h, 0,
loope$in, 3, 0e1h, 0,
loopne$in, 3, 0e0h, 0,
loopnz$in, 3, 0e0h, 0,
loopz$in, 3, 0e1h, 0,
mov$in, 20, 0, 0,
movsb$in, 1, 0a4h, 0,
movsw$in, 1, 0a5h, 0,
mul$in, 5, 0f6h, 4,
neg$in, 5, 0f6h, 3,
nop$in, 1, 090h, 0,
not$in, 5, 0f6h, 2,
or$in, 10, 8, 1,
out$in, 16, 0e6h, 0,
pop$in, 21, 0, 0,
popf$in, 1, 09dh, 0,
push$in, 8, 1, 0,
pushf$in, 1, 09ch, 0,
rcl$in, 4, 0d0h, 2,
rcr$in, 4, 0d0h, 3,
rep$in, 0feh, 0f3h, 0,
repe$in, 0feh, 0f3h, 0,
repne$in, 0feh, 0f2h, 0,
repnz$in, 0feh, 0f2h, 0,
repz$in, 0feh, 0f3h, 0,
ret$in, 14, 0c2h, 0,
retf$in, 14, 0cah, 0,
rol$in, 4, 0d0h, 0,
ror$in, 4, 0d0h, 1,
sahf$in, 1, 09eh, 0,
sal$in, 4, 0d0h, 4,
sar$in, 4, 0d0h, 7,
sbb$in, 9, 18h, 3,
scasb$in, 1, 0aeh, 0,
scasw$in, 1, 0afh, 0,
shl$in, 4, 0d0h, 4,
shr$in, 4, 0d0h, 5,
stc$in, 1, 0f9h, 0,
std$in, 1, 0fdh, 0,
sti$in, 1, 0fbh, 0,
stosb$in, 1, 0aah, 0,
stosw$in, 1, 0abh, 0,
sub$in, 9, 28h, 5,
test$in, 18, 0, 0,
wait$in, 1, 09bh, 0,
xchg$in, 19, 0, 0,
xlat$in, 1, 0d7h, 0,
xor$in, 10, 30h, 6
);
end asm$tab;


File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
%TYPE-W-READERR, error reading DRB1:[CCPM86.DDT86]ASSLNK86.ASM;2
-RMS-F-IRC, illegal record encountered; STV = 1


File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
;
;create ddt86.cmd, on micro using ISIS interface
;
pli gentab $$d
link gentab
gentab op86.dat
;
is14
plm86 ins86.plm debug pagewidth(100) xref
plm86 dis86.plm debug pagewidth(100) xref
asm86 dislnk86.asm debug
link86 dislnk86.obj, dis86.obj, ins86.obj,plm86.lib to dis86.lnk
loc86 dis86.lnk to dis86.abs ad(sm(dats(0),code(0h))) od(sm(dats,code,const,data))
oh86 dis86.abs to dis86.h86
;
plm86 ass86.plm debug xref pagewidth(100)
plm86 asmtab.plm debug xref pagewidth(100)
asm86 asslnk86.asm debug
link86 asslnk86.obj, asmtab.obj, ass86.obj, po(dis86.abs), plm86.lib to ass86.lnk
loc86 ass86.lnk to ass86.abs ad(sm(dats(0),code(0h))) od(sm(dats,code,const,data))
oh86 ass86.abs to ass86.h86
;
cpm
asm86 ddt86 $$fi
pip ddt86.h86 = ddt86.h86, dis86.h86, ass86.h86
; the value for the minimum code group required comes from the start of
; the ??seg as listed in ass86.mp2
gencmd ddt86 8080 code[m366]


View File

@@ -0,0 +1,596 @@
$title('8086 disassembler')
$date(5/14/81)
$compact
$optimize(2)
disem86: do;
declare
cr literally '0dh',
lf literally '0ah',
true literally '1',
false literally '0';
$include(optab.dat)
declare
tab$ptrs (5) address public initial (.ops2, .ops3, .ops4, .ops5, .ops6);
declare
left$bracket byte data ('['),
right$bracket byte data (']');
declare
alt$table$base address,
alt$table based alt$table$base (16) byte,
alt$table$ptrs (8) address external;
declare
mod$bits byte,
reg$bits byte,
rm$bits byte,
byte1$reg$bits byte,
d$bit byte,
s$bit byte,
v$bit byte,
w$bit byte,
z$bit byte;
declare
mnemonic$index byte, /* index into opcodes */
instr$type byte,
table$ptr address,
table$char based table$ptr byte,
disem$ptr pointer,
disem$offset address at (.disem$ptr),
disem$end address,
disem$byte based disem$ptr (1) byte,
disem$word based disem$ptr (1) address,
b$or$w$flag byte,
error$flag byte;
declare instr$table (512) byte external;
declare
ax$reg literally '0',
cx$reg literally '1',
dx$reg literally '2',
bx$reg literally '3',
sp$reg literally '4',
bp$reg literally '5',
si$reg literally '6',
di$reg literally '7';
declare
al$reg literally '0',
cl$reg literally '1',
dl$reg literally '2',
bl$reg literally '3',
ah$reg literally '4',
ch$reg literally '5',
dh$reg literally '6',
bh$reg literally '7';
declare
es$reg literally '0',
cs$reg literally '1',
ss$reg literally '2',
ds$reg literally '3';
declare
reg16 (*) byte public initial ('AX', 'CX', 'DX', 'BX', 'SP', 'BP', 'SI', 'DI'),
reg8 (*) byte public initial ('AL', 'CL', 'DL', 'BL', 'AH', 'CH', 'DH', 'BH'),
segreg (*) byte public initial ('ES', 'CS', 'SS', 'DS');
conout: procedure (c) external;
declare c byte;
end conout;
comma: procedure;
call conout (',');
end comma;
printm: procedure (a) PUBLIC;
declare a address;
declare b based a byte;
do while b <> '$';
call conout (b);
a = a + 1;
end;
end printm;
print$nibble: procedure (b);
declare b byte;
if b > 9 then call conout (b - 10 + 'A');
else call conout (b + '0');
end print$nibble;
print$byte: procedure (b);
declare b byte;
call print$nibble (shr (b, 4));
call print$nibble (b and 0fh);
end print$byte;
print$word: procedure (a) public;
declare a address;
call print$byte (high (a));
call print$byte (low (a));
end print$word;
error: procedure;
call printm (.('??= $'));
call print$byte (disem$byte (0));
disem$offset = disem$offset + 1;
end error;
set$bits: procedure;
byte1$reg$bits = disem$byte (0) and 7;
mod$bits = shr (disem$byte (1), 6);
reg$bits = shr (disem$byte (1), 3) and 7;
rm$bits = disem$byte (1) and 7;
w$bit, z$bit = disem$byte (0) and 1;
d$bit, s$bit, v$bit = shr (disem$byte (0), 1) and 1;
end set$bits;
print$b$or$w: procedure;
if w$bit then call printm (.('WORD $'));
else call printm (.('BYTE $'));
end print$b$or$w;
print$reg: procedure (reg$add, reg);
declare reg$add address, reg byte;
table$ptr = reg$add + shl (reg, 1);
call conout (table$char);
table$ptr = table$ptr + 1;
call conout (table$char);
end print$reg;
print$reg8: procedure (reg);
declare reg byte;
call print$reg (.reg8, reg);
end print$reg8;
print$reg16: procedure (reg);
declare reg byte;
call print$reg (.reg16, reg);
end print$reg16;
print$reg$8$or$16: procedure (reg$num);
declare reg$num byte;
if w$bit then call print$reg$16 (reg$num);
else call print$reg$8 (reg$num);
end print$reg$8$or$16;
print$2$reg$16: procedure (r1, r2);
declare (r1, r2) byte;
call print$reg$16 (r1);
call conout ('+');
call print$reg$16 (r2);
end print$2$reg$16;
print$A$reg: procedure;
if w$bit then call print$reg$16 (ax$reg);
else call print$reg$8 (al$reg);
end print$A$reg;
print$seg$reg: procedure (reg);
declare reg byte;
call print$reg (.seg$reg, reg);
end print$seg$reg;
print$data$8: procedure;
call print$byte (disem$byte (0));
disem$offset = disem$offset + 1;
end print$data$8;
print$data$16: procedure;
call print$word (disem$word (0));
disem$offset = disem$offset + 2;
end print$data$16;
print$data$8$or$16: procedure;
if w$bit then call print$data$16;
else call print$data$8;
end print$data$8$or$16;
print$data$sw: procedure;
if rol (disem$byte (0), 1) then call print$word (0ff00h or disem$byte (0));
else call print$word (disem$byte (0));
disem$offset = disem$offset + 1;
end print$data$sw;
print$signed$8: procedure;
declare a address;
a = disem$byte (0);
if low (a) >= 80h then a = a or 0ff00h; /* sign extend to 16 bits */
call print$word (disem$offset + a + 1);
disem$offset = disem$offset + 1;
end print$signed$8;
print$signed$16: procedure;
call print$word (disem$offset + disem$word (0) + 2);
disem$offset = disem$offset + 2;
end print$signed$16;
print$direct$addr: procedure;
call conout (left$bracket);
call print$word (disem$word (0));
call conout (right$bracket);
disem$offset = disem$offset + 2;
end print$direct$addr;
print$mod$rm: procedure;
disem$offset = disem$offset + 1; /* point past mod/reg/rm byte */
if mod$bits = 3 then
do;
call print$reg$8$or$16 (rm$bits);
return;
end;
if b$or$w$flag then call print$b$or$w;
if rm$bits = 6 and mod$bits = 0 then
do;
call print$direct$addr;
return;
end;
if mod$bits = 1 then
do;
if (rm$bits <> 6) or (disem$byte (0) <> 0)
then call print$byte (disem$byte (0));
disem$offset = disem$offset + 1;
end;
else if mod$bits = 2 then
do;
call print$word (disem$word (0));
disem$offset = disem$offset + 2;
end;
call conout (left$bracket);
do case rm$bits;
call print$2$reg$16 (3, 6);
call print$2$reg$16 (3, 7);
call print$2$reg$16 (5, 6);
call print$2$reg$16 (5, 7);
call print$reg$16 (6);
call print$reg$16 (7);
call print$reg$16 (5);
call print$reg$16 (3);
end;
call conout (right$bracket);
end print$mod$rm;
print$mod$reg$rm: procedure;
if d$bit then
do;
call print$reg$8$or$16 (reg$bits);
call conout (',');
call print$mod$rm;
end;
else
do;
call print$mod$rm;
call conout (',');
call print$reg$8$or$16 (reg$bits);
end;
end print$mod$reg$rm;
print$mnemonic: procedure;
declare (len, i) byte;
len = 2;
do while mnemonic$index >= opn$in (len - 1);
len = len + 1;
end;
table$ptr = tab$ptrs (len - 2) + (mnemonic$index - opn$in (len - 2))
* len;
do i = 1 to 7;
if i <= len then
do;
call conout (table$char);
table$ptr = table$ptr + 1;
end;
else call conout (' ');
end;
disem$offset = disem$offset + 1;
end print$mnemonic;
type1: procedure;
call print$mnemonic;
end type1;
type2: procedure;
if disem$byte (1) = 0ah then
do;
call print$mnemonic;
disem$offset = disem$offset + 1;
end;
else error$flag = true;
end type2;
type3: procedure;
call print$mnemonic;
call print$reg$16 (byte1$reg$bits);
end type3;
type4: procedure;
declare temp byte;
temp = shr (disem$byte (0), 3) and 3;
call print$mnemonic;
call print$segreg (temp);
end type4;
type5: procedure;
call print$mnemonic;
call print$signed$8;
end type5;
type6: procedure;
call print$mnemonic;
call print$signed$16;
end type6;
type8: procedure; /* 7, 9 */
call print$mnemonic;
call print$mod$rm;
end type8;
type10: procedure;
call print$mnemonic;
call print$data$8;
end type10;
type11: procedure;
call print$mnemonic;
call print$data$16;
end type11;
type12: procedure;
call print$mnemonic;
call conout ('3');
end type12;
type13: procedure;
declare temp address;
call print$mnemonic;
temp = disem$word (0);
disem$offset = disem$offset + 2;
call print$data$16;
call conout (':');
call print$word (temp);
end type13;
type14: procedure; /* 15, 16, 17 */
call print$mnemonic;
call print$mod$reg$rm;
end type14;
type18: procedure; /* 19, 20, 21 */
call print$mnemonic;
if d$bit then
do;
call print$direct$addr;
call comma;
call print$A$reg;
end;
else
do;
call print$A$reg;
call comma;
call print$direct$addr;
end;
end type18;
type22: procedure;
call print$mnemonic;
if d$bit then
do;
call print$data$8;
call comma;
call print$A$reg;
end;
else
do;
call print$A$reg;
call comma;
call print$data$8;
end;
end type22;
type23: procedure; /* 24 */
call print$mnemonic;
call print$A$reg;
call comma;
call print$data$8$or$16;
end type23;
type25: procedure; /* 26 */
call print$mnemonic;
if d$bit then
do;
call print$reg$16 (dx$reg);
call comma;
call print$A$reg;
end;
else
do;
call print$A$reg;
call comma;
call print$reg$16 (dx$reg);
end;
end type25;
type27: procedure; /* 28, 29, 30 */
call print$mnemonic;
b$or$w$flag = true;
call print$mod$rm;
call comma;
if v$bit then call print$reg$8 (cl$reg);
else call conout ('1');
end type27;
type31: procedure; /* 32 */
call setbits;
reg$bits = byte1$reg$bits;
w$bit = shr (disem$byte (0), 3) and 1;
call print$mnemonic;
call print$reg$8$or$16 (reg$bits);
call comma;
call print$data$8$or$16;
end type31;
type33: procedure;
call print$mnemonic;
call print$reg$16 (ax$reg);
call comma;
call print$reg$16 (byte1$reg$bits);
end type33;
type34: procedure; /* 35 */
call print$mnemonic;
b$or$w$flag = true;
call print$mod$rm;
call comma;
call print$data$8$or$16;
end type34;
type36: procedure; /* 37 */
w$bit = true; /* force 16 bit reg, mem */
if reg$bits > 3 then
do;
error$flag = true;
return;
end;
call print$mnemonic;
if d$bit then
do;
call print$seg$reg (reg$bits);
call comma;
call print$mod$rm;
end;
else
do;
call print$mod$rm;
call comma;
call print$seg$reg (reg$bits);
end;
end type36;
type38: procedure;
call print$mnemonic;
call print$mod$rm;
call comma;
call print$data$8;
end type38;
type39: procedure;
if mod$bits = 3 then
do;
error$flag = true;
return;
end;
call print$mnemonic;
call print$reg$16 (reg$bits);
call comma;
call print$mod$rm;
end type39;
type40: procedure; /* 41 */
if mod$bits = 3 then
do;
error$flag = true;
return;
end;
call print$mnemonic;
b$or$w$flag = true;
call print$mod$rm;
call comma;
call print$data$8$or$16;
end type40;
type42: procedure;
call print$mnemonic;
call print$byte (shl (byte1$reg$bits, 3) or reg$bits);
call comma;
call print$mod$rm;
end type42;
type44: procedure;
call print$mnemonic;
b$or$w$flag = true;
call print$modrm;
call comma;
if s$bit = 1 and w$bit = 1 then call print$data$sw;
else call print$data$8$or$16;
end type44;
type45: procedure;
b$or$w$flag = true;
call type8;
end type45;
dis: procedure;
error$flag, b$or$w$flag = false;
call set$bits;
if instr$type = 26 then
do;
alt$table$base = alt$table$ptrs (mnemonic$index);
mnemonic$index = alt$table (reg$bits * 2);
instr$type = alt$table (reg$bits * 2 + 1);
end;
if instr$type > 28 then error$flag = true;
else
do case instr$type;
error$flag = true;
call type1;
call type2;
call type3;
call type4;
call type5;
call type6;
call type8;
call type10;
call type11;
call type12;
call type13;
call type14;
call type18;
call type22;
call type23;
call type25;
call type27;
call type31;
call type33;
call type34;
call type36;
call type38;
call type39;
call type40;
call type42;
;
call type44;
call type45;
end;
if error$flag then call error;
end dis;
disem: procedure (disloc) address public;
declare disloc pointer;
declare nprefix byte;
disem$ptr = disloc;
nprefix = 0;
do while true;
mnemonic$index = instr$table (disem$byte (0) * 2);
instr$type = instr$table (disem$byte (0) * 2 + 1);
if instr$type = 0ffh and nprefix < 3 then
do;
call print$mnemonic;
nprefix = nprefix + 1;
end;
else
do;
if instr$type = 0ffh then instr$type = 1;
call dis;
return disem$offset;
end;
end;
end disem;
end disem86;


View File

@@ -0,0 +1,3 @@
%TYPE-W-READERR, error reading DRB1:[CCPM86.DDT86]DISLNK86.ASM;2
-RMS-F-IRC, illegal record encountered; STV = 1


View File

@@ -0,0 +1,123 @@
gentab: proc options (main);
/* generate tables for 8086 disassembler 12/23/80 */
/* modified 5/14/81 */
declare
opcnt (2:6) fixed (7) static initial (0,0,0,0,0),
sum fixed (7),
len fixed (7),
line char (100) varying,
infile file,
outfile file,
litfile file,
opcode char (10) varying,
i fixed (7),
j fixed (15),
n fixed (7),
count fixed (15),
chars (200) char (6) varying;
open file (infile) input stream title ('OP86.DAT');
open file (outfile) print title ('OPTAB.DAT');
open file (litfile) print title ('OPTAB.LIT');
on endpage (outfile) begin; end;
on endpage (litfile) begin; end;
count = 0;
/* read op86.dat file into chars array */
get file (infile) list (opcode);
do while (opcode ^= '$');
count = count + 1;
chars (count) = opcode;
get file (infile) list (opcode);
end;
/* create ascii opcode tables, 1 for each character length */
do i = 2 to 6;
line = 'declare ops' || deblank (i) || ' (*) byte initial (';
n = 0;
do j = 1 to count;
if length (chars (j)) = i then
do;
if n > 0 then line = line || ', ';
if divide (n, 5, 7) * 5 = n then
do;
put file (outfile) skip list (line);
line = '^I';
end;
n = n + 1;
line = line || '''' || chars (j) || '''';
opcnt (i) = opcnt (i) + 1;
end;
end;
line = line || ');';
put file (outfile) skip list (line);
put file (outfile) skip;
end;
/* create array containing # of opcodes of each length */
line = 'declare nops (5) byte public initial (';
do i = 2 to 6;
line = line || deblank (opcnt (i));
if i < 6 then line = line || ', ';
end;
put file (outfile) skip list (line || ');');
put file (outfile) skip;
/* create array containing starting index for each opcode length */
line = 'declare opn$in (*) byte public initial (';
sum = 0;
do i = 2 to 6;
line = line || deblank (sum) || ', ';
sum = sum + opcnt (i);
end;
put file (outfile) skip list (line || '255);');
/* create literals for starting indexes for each opcode length */
sum = 0;
put file (litfile) skip list ('declare');
do i = 2 to 6;
put skip list (deblank (opcnt (i)), deblank (i) || '-character opcodes');
line = '^I' || 'op' || deblank (i) ||
'$in literally ''' || deblank (sum) || '''';
if i = 6 then line = line || ';';
else line = line || ',';
put file (litfile) skip list (line);
sum = sum + opcnt (i);
opcnt (i) = 0;
end;
/* create literals for position in opcode tables of each opcode */
put file (litfile) skip;
put file (litfile) skip list ('declare');
do j = 1 to count;
len = length (chars (j));
if index (chars (j), ':') > 0 then
chars (j) = substr (chars (j), 1, len-1);
line = '^I' || chars (j) || '$in literally '''
|| 'op' || deblank (len) || '$in + '
|| deblank (opcnt (len)) || '''';
if j = count then line = line || ';';
else line = line || ',';
put file (litfile) skip list (line);
opcnt (len) = opcnt (len) + 1;
end;
deblank: proc (i) returns (char (10) varying);
declare i fixed (7);
declare temp char (10) varying;
temp = char (i);
return (substr (temp, verify (temp, ' ')));
end deblank;
end gentab;


View File

@@ -0,0 +1,427 @@
$title('instruction table for 8086 disassembler')
$date(10/5/80)
instr86: do;
declare
qq$in literally '0',
alt1 literally '0',
alt2 literally '1',
alt3 literally '2',
alt4 literally '3',
alt5 literally '4',
alt6 literally '5',
alt7 literally '6',
alt8 literally '7';
$include(optab.lit)
declare
type$0 literally '0',
type$1 literally '1',
type$2 literally '2',
type$3 literally '3',
type$4 literally '4',
type$5 literally '5',
type$6 literally '6',
type$7 literally '7',
type$8 literally '7',
type$9 literally '7',
type$10 literally '8',
type$11 literally '9',
type$12 literally '10',
type$13 literally '11',
type$14 literally '12',
type$15 literally '12',
type$16 literally '12',
type$17 literally '12',
type$18 literally '13',
type$19 literally '13',
type$20 literally '13',
type$21 literally '13',
type$22 literally '14',
type$23 literally '15',
type$24 literally '15',
type$25 literally '16',
type$26 literally '16',
type$27 literally '17',
type$28 literally '17',
type$29 literally '17',
type$30 literally '17',
type$31 literally '18',
type$32 literally '18',
type$33 literally '19',
type$34 literally '20',
type$35 literally '20',
type$36 literally '21',
type$37 literally '21',
type$38 literally '22',
type$39 literally '23',
type$40 literally '24',
type$41 literally '24',
type$42 literally '25',
type$43 literally '26',
type$44 literally '27',
type$45 literally '28';
declare
prefix$type literally '0ffh';
declare alt$table$ptrs (8) address public data (
.alt$1$tab,
.alt$2$tab,
.alt$3$tab,
.alt$4$tab,
.alt$5$tab,
.alt$6$tab,
.alt$7$tab,
.alt$8$tab);
declare alt$1$tab (*) byte data (
add$in, type$44,
or$in, type$34,
adc$in, type$44,
sbb$in, type$44,
and$in, type$34,
sub$in, type$44,
xor$in, type$34,
cmp$in, type$44);
declare alt$2$tab (*) byte data (
add$in, type$44,
qq$in, type$0,
adc$in, type$44,
sbb$in, type$44,
qq$in, type$0,
sub$in, type$44,
qq$in, type$0,
cmp$in, type$44);
declare alt$3$tab (*) byte data (
add$in, type$38,
qq$in, type$0,
adc$in, type$38,
sbb$in, type$38,
qq$in, type$0,
sub$in, type$38,
qq$in, type$0,
cmp$in, type$38);
declare alt$4$tab (*) byte data (
rol$in, type$29,
ror$in, type$29,
rcl$in, type$29,
rcr$in, type$29,
shl$in, type$29,
shr$in, type$29,
qq$in, type$0,
sar$in, type$29);
declare alt$5$tab (*) byte data (
rol$in, type$27,
ror$in, type$27,
rcl$in, type$27,
rcr$in, type$27,
shl$in, type$27,
shr$in, type$27,
qq$in, type$0,
sar$in, type$27);
declare alt$6$tab (*) byte data (
test$in, type$34,
qq$in, type$0,
not$in, type$45,
neg$in, type$45,
mul$in, type$45,
imul$in, type$45,
div$in, type$45,
idiv$in, type$45);
declare alt$7$tab (*) byte data (
inc$in, type$45,
dec$in, type$45,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0);
declare alt$8$tab (*) byte data (
inc$in, type$45,
dec$in, type$45,
call$in, type$9,
callf$in, type$7,
jmp$in, type$9,
jmpf$in, type$7,
push$in, type$7,
qq$in, type$0);
/*
instruction table for 8086 disassembler
instruction is index into table
there are 2 bytes per instruction:
1. index into ascii opcode table
2. instruction type (how many operands of what type, etc.)
*/
declare instr$table (512) byte public data (
add$in, type$14, /* 0 */
add$in, type$15,
add$in, type$16,
add$in, type$17,
add$in, type$23,
add$in, type$24,
push$in, type$4,
pop$in, type$4,
or$in, type$14,
or$in, type$15,
or$in, type$16,
or$in, type$17,
or$in, type$23,
or$in, type$24,
push$in, type$4,
qq$in, type$0,
adc$in, type$14, /* 10 */
adc$in, type$15,
adc$in, type$16,
adc$in, type$17,
adc$in, type$23,
adc$in, type$24,
push$in, type$4,
pop$in, type$4,
sbb$in, type$14,
sbb$in, type$15,
sbb$in, type$16,
sbb$in, type$17,
sbb$in, type$23,
sbb$in, type$24,
push$in, type$4,
pop$in, type$4,
and$in, type$14, /* 20 */
and$in, type$15,
and$in, type$16,
and$in, type$17,
and$in, type$23,
and$in, type$24,
es$in, prefix$type,
daa$in, type$1,
sub$in, type$14,
sub$in, type$15,
sub$in, type$16,
sub$in, type$17,
sub$in, type$23,
sub$in, type$24,
cs$in, prefix$type,
das$in, type$1,
xor$in, type$14, /* 30 */
xor$in, type$15,
xor$in, type$16,
xor$in, type$17,
xor$in, type$23,
xor$in, type$24,
ss$in, prefix$type,
aaa$in, type$1,
cmp$in, type$14,
cmp$in, type$15,
cmp$in, type$16,
cmp$in, type$17,
cmp$in, type$23,
cmp$in, type$24,
ds$in, prefix$type,
aas$in, type$1,
inc$in, type$3, /* 40 */
inc$in, type$3,
inc$in, type$3,
inc$in, type$3,
inc$in, type$3,
inc$in, type$3,
inc$in, type$3,
inc$in, type$3,
dec$in, type$3,
dec$in, type$3,
dec$in, type$3,
dec$in, type$3,
dec$in, type$3,
dec$in, type$3,
dec$in, type$3,
dec$in, type$3,
push$in, type$3, /* 50 */
push$in, type$3,
push$in, type$3,
push$in, type$3,
push$in, type$3,
push$in, type$3,
push$in, type$3,
push$in, type$3,
pop$in, type$3,
pop$in, type$3,
pop$in, type$3,
pop$in, type$3,
pop$in, type$3,
pop$in, type$3,
pop$in, type$3,
pop$in, type$3,
qq$in, type$0, /* 60 */
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
qq$in, type$0,
jo$in, type$5, /* 70 */
jno$in, type$5,
jb$in, type$5,
jnb$in, type$5,
jz$in, type$5,
jnz$in, type$5,
jbe$in, type$5,
ja$in, type$5,
js$in, type$5,
jns$in, type$5,
jp$in, type$5,
jnp$in, type$5,
jl$in, type$5,
jnl$in, type$5,
jle$in, type$5,
jg$in, type$5,
alt1, type$43, /* 80 */
alt1, type$43,
alt2, type$43,
alt2, type$43,
test$in, type$14,
test$in, type$15,
xchg$in, type$16,
xchg$in, type$17,
mov$in, type$14,
mov$in, type$15,
mov$in, type$16,
mov$in, type$17,
mov$in, type$36,
lea$in, type$39,
mov$in, type$37,
pop$in, type$9,
nop$in, type$1, /* 90 */
xchg$in, type$33,
xchg$in, type$33,
xchg$in, type$33,
xchg$in, type$33,
xchg$in, type$33,
xchg$in, type$33,
xchg$in, type$33,
cbw$in, type$1,
cwd$in, type$1,
callf$in, type$13,
wait$in, type$1,
pushf$in, type$1,
popf$in, type$1,
sahf$in, type$1,
lahf$in, type$1,
mov$in, type$18, /* A0 */
mov$in, type$19,
mov$in, type$20,
mov$in, type$21,
movsb$in, type$1,
movsw$in, type$1,
cmpsb$in, type$1,
cmpsw$in, type$1,
test$in, type$23,
test$in, type$24,
stosb$in, type$1,
stosw$in, type$1,
lodsb$in, type$1,
lodsw$in, type$1,
scasb$in, type$1,
scasw$in, type$1,
mov$in, type$31, /* B0 */
mov$in, type$31,
mov$in, type$31,
mov$in, type$31,
mov$in, type$31,
mov$in, type$31,
mov$in, type$31,
mov$in, type$31,
mov$in, type$32,
mov$in, type$32,
mov$in, type$32,
mov$in, type$32,
mov$in, type$32,
mov$in, type$32,
mov$in, type$32,
mov$in, type$32,
qq$in, type$0, /* C0 */
qq$in, type$0,
ret$in, type$11,
ret$in, type$1,
les$in, type$39,
lds$in, type$39,
mov$in, type$40,
mov$in, type$41,
qq$in, type$0,
qq$in, type$0,
retf$in, type$11,
retf$in, type$1,
int$in, type$12,
int$in, type$10,
into$in, type$1,
iret$in, type$1,
alt4, type$43, /* D0 */
alt4, type$43,
alt5, type$43,
alt5, type$43,
aam$in, type$2,
aad$in, type$2,
qq$in, type$0,
xlat$in, type$1,
esc$in, type$42,
esc$in, type$42,
esc$in, type$42,
esc$in, type$42,
esc$in, type$42,
esc$in, type$42,
esc$in, type$42,
esc$in, type$42,
loopne$in, type$5, /* E0 */
loope$in, type$5,
loop$in, type$5,
jcxz$in, type$5,
in$in, type$22,
in$in, type$22,
out$in, type$22,
out$in, type$22,
call$in, type$6,
jmp$in, type$6,
jmpf$in, type$13,
jmps$in, type$5,
in$in, type$25,
in$in, type$26,
out$in, type$25,
out$in, type$26,
lock$in, prefix$type, /* F0 */
qq$in, type$0,
repne$in, prefix$type,
rep$in, prefix$type,
hlt$in, type$1,
cmc$in, type$1,
alt6, type$43,
alt6, type$43,
clc$in, type$1,
stc$in, type$1,
cli$in, type$1,
sti$in, type$1,
cld$in, type$1,
std$in, type$1,
alt7, type$43,
alt8, type$43);
end instr86;


View File

@@ -0,0 +1,126 @@
AAA
AAD
AAM
AAS
ADC
ADD
AND
CALL
CALLF
CBW
CLC
CLD
CLI
CMC
CMP
CMPSB
CMPSW
CS:
CWD
DAA
DAS
DEC
DIV
DS:
ES:
ESC
HLT
IDIV
IMUL
IN
INC
INT
INTO
IRET
JA
JAE
JB
JBE
JC
JCXZ
JE
JG
JGE
JL
JLE
JMP
JMPF
JMPS
JNA
JNAE
JNB
JNBE
JNC
JNE
JNG
JNGE
JNL
JNLE
JNO
JNP
JNS
JNZ
JO
JP
JPE
JPO
JS
JZ
LAHF
LDS
LEA
LES
LOCK
LODSB
LODSW
LOOP
LOOPE
LOOPNE
LOOPNZ
LOOPZ
MOV
MOVSB
MOVSW
MUL
NEG
NOP
NOT
OR
OUT
POP
POPF
PUSH
PUSHF
RCL
RCR
REP
REPE
REPNE
REPNZ
REPZ
RET
RETF
ROL
ROR
SAHF
SAL
SAR
SBB
SCASB
SCASW
SHL
SHR
SS:
STC
STD
STI
STOSB
STOSW
SUB
TEST
WAIT
XCHG
XLAT
XOR
$


View File

@@ -0,0 +1,3 @@
%TYPE-W-READERR, error reading DRB1:[CCPM86.DDT86]OPTAB.DAT;2
-RMS-F-IRC, illegal record encountered; STV = 1


Some files were not shown because too many files have changed in this diff Show More