Grammar For 386SWAT Command Line

// Command lines
APPKEY
BCx opt_addr        x = {<empty>, *, +, -}
BD opt_addr
BD addr Ln       n = {<empty>, 1, 2, 4}
BD addr Ln W    n = {<empty>, 1, 2, 4}
BDnx                    x = {*, +, -}   n = {<empty>, 0, 1, 2, 3}
BTF
BTF {ON|OFF}
CHAT
Dxy-                     x = {<empty>, b, d, g, i, t, t2, t3, v, w},
                            y = {<empty>, /n} where n is the data width
Dxy opt_addr         x = {<empty>, b, d, g, i, t, t2, t3, v, w},
                            y = {<empty>, /n} where n is the data width
Dxy addr P            x = {<empty>, b, d, g, i, t, t2, t3, v, w},
                            y = {<empty>, /n} where n is the data width
Dxy addr P exp      x = {<empty>, b, d, g, i, t, t2, t3, v, w},
                            y = {<empty>, /n} where n is the data width
DTE exp
E  addr
E  addr lvallist
EXIT
F  addr L lval lval
F  addr L lval lval P
F  addr L lval lval P exp
FS
G  opt_addr
GM opt_boolexp
H  addr
Ix lval         x = {<empty>, b, d, w}
IMR
INSERT gdtr idtr [cr3 [lapde]]
INSERT * idtr
IPF [/d] [/s] [/r] exp
IRR
ISR
LBR
LBR {ON|OFF}
LF filename
LI x                    x = {+, -}
LI dcon           x = {<empty>, +, -}
LS filename x      x = {<empty>, lval}
M  addr L lval addr
MACBASE addr
MDB exp
Ox lval lval           x = {<empty>, b, d, w}
PATHx dirlist        x = {<empty>, +}
PS lval             x = {<empty>, lval (<256)}
PTE addr
PTE exp
PTE addr P exp
PTE exp  P exp
QS addr
R  reg [=] exp
R  reg.str [=] exp
REMDBG
RC
RR
RS
Sx addr L exp atom x = {<empty>, 1}
Sx addr addr   atom x = {<empty>, 1}
S  addr addr ! instr
S  addr L exp ! instr
S  addr addr   # exp
S  addr L exp # exp
SBx         x = {+, -}
SB*x            x = {+, -}
SETCOM x        x = {<empty>, -}
SETCOM port bps     port = {1, 2, 3, 4}
SETCOM xn       x = {RTS, DTR}      n = {+, -}
SGH [/b|/s|/h|/o|/n]  [/c] exp
SIGINT lval
SPTE addr
SPTE exp
SPTE addr P exp
SPTE exp  P exp
TDB exp
TOGINT lvallist
TS
TS opt_sel opt_group x opt_seln opt_addr
                x = {<empty>, *, P, Vn = {<empty>, +, -}
Ux-          x = {<empty>, 16, 32}
Ux opt_addr        x = {<empty>, 16, 32}
Ux addr P           x = {<empty>, 16, 32}
Ux addr P exp     x = {<empty>, 16, 32}

VMSCOUNT xx
VMSINT {ON|OFF}
VMSINT=xx,xx,...

WKD FAULT [ON|OFF|SKIP]
WKD LOGERROR [ON|OFF]
WKD [ON|OFF]
WKD [QUIET|NOISY]
 
 
Lval list
lvallist lval
lval lvallist
 
 
Optional addresses
opt_addr <empty>
addr
 
Addresses
addr exp using default segment/selector as per specific command
ea
 
Optional boolean expression
opt_boolexp <empty>
exp
 
Expressions on values
exp ( exp )
mfn monadic functions
dfn dyadic functions
 
Monadic functions
mfn atom
[ ea extract word at effective address
{ ea extract dword ...
O.ea extract offset from effective address
S.ea extract segment/selector ...
L.ea extract linear address ...
P.ea extract physical address ...
+exp
-exp
~exp
 
Lefthand values
lval atom
( exp )
 
Effective address with segment/selector
ea seg : exp
sel | exp
.EA Effective Address #1 (or the only one)
.EA2 ...                        #2 
.GDT  GDT base address (using selector zero)
.IDT IDT ...
.LDT LDT ...
.TSS TSS ...
.CMAC address of next C MAC entry
.CODE current code display address
.CSIP address of current cs:[e]ip
.DATA current data display address
.DMAC segment of first DOS MAC entry
.NMAC segment of next  DOS MAC entry
.PMIxx Sel|Off of PM Interrupt xx
.RMIxx Seg:Off of RM interrupt xxh
.VM Sel|Off of current Windows VM structure
.VMIxx ...     VM ... 
.VMRET return cs|eip from Windows VM (|{.vmstk+50 or |{.vmstk+150
.VMSTK current ss|esp saved in Windows VM structure (same as |{.vm+40)
.IRET far word:dword return address on stack allowing a mode switch from PM to VM
.RETN near word or dword return address on stack
.RETND near dword return address on stack
.RETNS near word return address on stack 
.RETF far word:word or word:dword return address on stack 
.RETFD far word:dword return address on stack
.RETFS far word:word return address on stack
.XBDA Seg:Off of XBDA; same as ([40:0E):0
.XBDA2 Seg:Off of 2ndary XBDA; same as ((S..XBDA)+[.XBDA+B4):0
dotcmd ? exp dyadic functions on dot commands (.GDT, .IDT, etc.) where ? is a dyadic function
:[ ea extract word:word at effective address
:{ ea extract word:dword at effective address
|[ ea ... word|word ... 
|{ ea ... word|dword ...
|G ea ... ...    in GDT-format (using selector zero)
|I ea ... ...    in IDT-format (using IDT selector)
|L ea ... ...    in LDT-format (same as GDT-format)
|T ea ... ...    in TSS-format (using CS|EIP
symbol effective address of this symbol
 
Dyadic functions on dot commands
dotcmd ? exp 
 
S.dotcmd : O.dotcmd ? exp for VM addresses
S.dotcmd | O.dotcmd ? exp for PM addresses 
where ? is a dyadic function
 
Dyadic Functions
dfn atom
lval + exp addition
lval - exp subtraction
lval * exp multiplication
lval / exp division (with truncation towards zero)
lval & exp bitwise AND
lval ^ exp bitwise XOR
lval == exp is equal (eq)
lval != exp is not equal (ne) 
lval exp is less than (lt)
lval <= exp lt or eq
lval exp is greater than (gt)
lval >= exp gt or eq
lval && exp logical AND
lval || exp logical OR
Because we have usurped the | symbol as the selector separator, it is
not available for bitwise OR.  To do bitwise OR between A and B, use
      (A & ~B) ^ B
 
Precedence
Operators Type
- ~ Monadic
* / Dyadic
+ - Dyadic
symbols, .code, .data, etc. Address expression
: | Dyadic (address construction)
] [ { Monadic (extraction)
>> << Dyadic (bit shift)
< <= >= > Dyadic (relational)
== != Equality
& Dyadic (bitwise AND)
^ Dyadic (bitwise XOR)
&& Dyadic (logical AND)
|| Dyadic (logical OR)
 
Segment or Selector
seg lval
sel lval
 
Optional segment or selector
opt_sel <empty>
*
seg
sel
 
Optional Group ID
opt_group <empty>
*
con
 
Atoms
atom con
reg
.LBRFR
.LBRTO
.LEXFR
.LEXTO
 
Registers
reg GP AX, AL, AH, BX, ... 
EGP EAX, EBX, ECX, ...
CRn Control registers
DRn Debug registers
TRn Test registers
Misc IP, EIP, FL, EFL, TR, LDTR
 
Constants
con <32-bit hex values>
dcon <16-bit unsigned decimal values>
filename <DOS pathname>
dirlist <List of directory names separated by commas (,)>
 
Bits per second (BPS) values
bps 55
110
300
600
1200
2400
4800
9600
19200
38400
76800
115200
 

Examples

* To display the successive entries in the DOS memory allocation chain, display one such entry via a DB command.  Then type

    /D ((S..DATA)+1+[.DATA+3):0

  Continuing to press Enter displays the successive MAC entries.

* To display the successive entries in the C memory allocation chain, display one such entry (at the count word) via a DB command.  Then type

    /D .DATA + 2 + FFFE & [.DATA