;       SCCSID = @(#)debrcmd.asm        6.1 90/11/17
;      SCCSID = @(#)debrcmd.asm 13.6 90/05/23
PAGE    ,132
NAME    DEBRCMD
TITLE   DEBRCMD - debugger modified and display registers commands
.286p

;***    DEBRCMD.ASM - debugger modified and display registers commands
;
;       This file contains the routines to display and modify the
;       debuggee's registers and flags.
;
;  Defects:
;
;  155531   RJM 21 May 1996 Make .R use the correct default addressing mode


Extern  decodeop,       FAR

.xlist
        include debseg.inc
        include debmac.inc
        include debequ.inc
        include debinit.inc
        include debdesc.inc
        include debprt.inc


INCL_NOREFERS   equ 1
NULL    equ   0

        include tkexport.inc
        include kmode.inc
.list

DataSegmentStart

Extern DefType,         WORD         ;155531
Extern DebData,         WORD
Extern RegSA,           WORD
Extern pRegSA,          WORD
Extern DisAddr,         WORD
Extern opbuf,           BYTE
Extern pTXT,            WORD
extrn  _vpCRI:word

; LARRYB
; Extern fTraceCount,     BYTE
; Extern fRegDisp,        BYTE

;
;       Global register message strings
;

Extern AXmsg,   WORD
Extern EAXmsg,  WORD
Extern BXmsg,   WORD
Extern EBXmsg,  WORD
Extern CXmsg,   WORD
Extern ECXmsg,  WORD
Extern DXmsg,   WORD
Extern EDXmsg,  WORD
Extern SPmsg,   WORD
Extern ESPmsg,  WORD
Extern BPmsg,   WORD
Extern EBPmsg,  WORD
Extern SImsg,   WORD
Extern ESImsg,  WORD
Extern DImsg,   WORD
Extern EDImsg,  WORD
Extern CSmsg,   WORD
Extern DSmsg,   WORD
Extern ESmsg,   WORD
Extern SSmsg,   WORD
Extern IPmsg,   WORD
Extern EIPmsg,  WORD
Extern Fmsg,    WORD
Extern EFmsg,   WORD
Extern TRmsg,   WORD
Extern LDTRmsg, WORD
Extern IOPLmsg, WORD
Extern MSWmsg,  WORD
Extern GDTRmsg, WORD
Extern IDTRmsg, WORD
Extern GDTBmsg, WORD
Extern GDTLmsg, WORD
Extern IDTBmsg, WORD
Extern IDTLmsg, WORD
Extern CR0msg,  WORD
Extern CR2msg,  WORD
Extern CR3msg,  WORD
Extern FSmsg,   WORD
Extern GSmsg,   WORD
Extern DR0msg,  WORD
Extern DR1msg,  WORD
Extern DR2msg,  WORD
Extern DR3msg,  WORD
Extern TR6msg,  WORD
Extern TR7msg,  WORD
Extern DR6msg,  WORD
Extern DR7msg,  WORD

Static PCmsg,   STRING, "PC"

;
;  Flag strings.
;

Static NTfmsg,  STRING, "NT"
Static OVfmsg,  STRING, "OV"
Static DNfmsg,  STRING, "DN"
Static EIfmsg,  STRING, "EI"
Static NGfmsg,  STRING, "NG"
Static ZRfmsg,  STRING, "ZR"
Static ACfmsg,  STRING, "AC"
Static PEfmsg,  STRING, "PE"
Static CYfmsg,  STRING, "CY"
Static NVfmsg,  STRING, "NV"
Static UPfmsg,  STRING, "UP"
Static DIfmsg,  STRING, "DI"
Static PLfmsg,  STRING, "PL"
Static NZfmsg,  STRING, "NZ"
Static NAfmsg,  STRING, "NA"
Static POfmsg,  STRING, "PO"
Static NCfmsg,  STRING, "NC"
Static RFfmsg,  STRING, "RF"
Static VMfmsg,  STRING, "VM"
Static Min2msg, STRING, "--"

;
; MSW flag strings
;

Static PMfmsg,  STRING, "PM"
Static MPfmsg,  STRING, "MP"
Static EMfmsg,  STRING, "EM"
Static TSfmsg,  STRING, "TS"
Static Blankmsg,STRING, " "

;
; CR0 flag strings
;

Static PGfmsg,  STRING, "PG"
Static ETfmsg,  STRING, "ET"

;
;       Tables and strings for DR0-3 R/W and Len messages
;         Note: Rmsg and Wmsg also used by TR6 print routine
;

Static RWmsgTbl, LABEL, WORD
        dw      dataOFFSET Emsg                 ; 0
        dw      dataOFFSET Wmsg                 ; 1
        dw      dataOFFSET Undmsg               ; 2
        dw      dataOFFSET Rmsg                 ; 3

Static LnmsgTbl, LABEL, WORD
        dw      dataOFFSET Onemsg               ; 0
        dw      dataOFFSET Twomsg               ; 1
        dw      dataOFFSET Undmsg               ; 2
        dw      dataOFFSET Fourmsg              ; 3

Static Onemsg,          STRING, "1"
Static Emsg,            STRING, "E"
Static Twomsg,          STRING, "2"
Static Rmsg,            STRING, "R"
Static Undmsg,          STRING, "U"
Static Fourmsg,         STRING, "4"
Static Wmsg,            STRING, "W"
Static Gfmsg,           STRING, "G"
Static Minfmsg,         STRING, "-"
Static Lfmsg,           STRING, "L"
Static Bfmsg,           STRING, "B"

;
;       TR6 flag field strings
;

Static Veqmsg,          STRING, " V="
Static Deqmsg,          STRING, " D="
Static Ueqmsg,          STRING, " U="
Static Weqmsg,          STRING, " W="
Static Ceqmsg,          STRING, " C="

;
;       TR7 flag field strings
;

Static HTeqmsg,         STRING, " HT="
Static RPeqmsg,         STRING, " REP="

;
;       DR6 flag strings
;

Static BTfmsg,          STRING, "BT"
Static BSfmsg,          STRING, "BS"
Static BDfmsg,          STRING, "BD"

;
;       DR7 flag strings
;

Static GEfmsg,          STRING, "GE"
Static LEfmsg,          STRING, "LE"

;
;       286 environment register display
;

Static  PrtRegs, LABEL, BYTE

        OutMsglc        AXmsg
        OutWordHexPtr   AXsav
        OutBlanks       2

        OutMsglc        BXmsg
        OutWordHexPtr   BXsav
        OutBlanks       2

        OutMsglc        CXmsg
        OutWordHexPtr   CXsav
        OutBlanks       2

        OutMsglc        DXmsg
        OutWordHexPtr   DXsav
        OutBlanks       2

        OutMsglc        SPmsg
        OutWordHexPtr   SPsav
        OutBlanks       2

        OutMsglc        BPmsg
        OutWordHexPtr   BPsav
        OutBlanks       2

        OutMsglc        SImsg
        OutWordHexPtr   SIsav
        OutBlanks       2

        OutMsglc        DImsg
        OutWordHexPtr   DIsav
        OutCrLf

        OutMsglc        IPmsg
        OutWordHexPtr   IPsav
        OutBlanks       2

        OutMsglc        CSmsg
        OutWordHexPtr   CSsav
        OutBlanks       2

        OutMsglc        DSmsg
        OutWordHexPtr   DSsav
        OutBlanks       2

        OutMsglc        ESmsg
        OutWordHexPtr   ESsav
        OutBlanks       2

        OutMsglc        SSmsg
        OutWordHexPtr   SSsav
        OutBlanks       2

        CallOp          PrtFlags, Fsav
        OutCrLf
        EndOp

Static  PrtRegs2, LABEL, BYTE

        OutMsglc        GDTRmsg
        Out24HexPtr     GDTsav.DTRBaseLow
        OutBlank
        OutWordHexPtr   GDTsav.DTRLimit
        OutBlanks       2

        OutMsglc        IDTRmsg
        Out24HexPtr     IDTsav.DTRBaseLow
        OutBlank
        OutWordHexPtr   IDTsav.DTRLimit
        OutBlanks       2

        OutMsglc        TRmsg
        OutWordHexPtr   TRsav
        OutBlanks       2

        OutMsglc        LDTRmsg
        OutWordHexPtr   LDTsav
        OutBlank

        OutMsglc        IOPLmsg
        OutBitFHexPtr   Fsav, 12, 2
        OutBlank

        CallOp          PrtMSW, MSWsav
        OutCrLf
        EndOp

;
;       Displays the terse registers dump
;

Static  PrtERegs, LABEL, BYTE

        OutMsglc        EAXmsg
        OutDwordHexPtr  EAXsav
        OutBlank

        OutMsglc        EBXmsg
        OutDwordHexPtr  EBXsav
        OutBlank

        OutMsglc        ECXmsg
        OutDwordHexPtr  ECXsav
        OutBlank

        OutMsglc        EDXmsg
        OutDwordHexPtr  EDXsav
        OutBlank

        OutMsglc        ESImsg
        OutDwordHexPtr  ESIsav
        OutBlank

        OutMsglc        EDImsg
        OutDwordHexPtr  EDIsav
        OutCrLf

        OutMsglc        EIPmsg
        OutDwordHexPtr  EIPsav
        OutBlank

        OutMsglc        ESPmsg
        OutDwordHexPtr  ESPsav
        OutBlank

        OutMsglc        EBPmsg
        OutDwordHexPtr  EBPsav
        OutBlank

        OutMsglc        IOPLmsg
        OutBitFHexPtr   Fsav, 12, 2
        OutBlank

        CallOp          PrtRFVM, EFsav          ; Prints only RF/VM flags
        OutBlank
        CallOp          PrtFlags, Fsav
        OutCrLf

        OutMsglc        CSmsg
        OutWordHexPtr   CSsav
        OutBlank

        OutMsglc        SSmsg
        OutWordHexPtr   SSsav
        OutBlank

        OutMsglc        DSmsg
        OutWordHexPtr   DSsav
        OutBlank

        OutMsglc        ESmsg
        OutWordHexPtr   ESsav
        OutBlank

        OutMsglc        FSmsg
        OutWordHexPtr   FSsav
        OutBlank

        OutMsglc        GSmsg
        OutWordHexPtr   GSsav
        OutBlanks       2

        OutMsglc        CR2msg
        OutDwordHexPtr  CR2sav
        OutBlanks       2

        OutMsglc        CR3msg
        OutDwordHexPtr  CR3sav
        OutCrLf

        EndOp

;
;       Displays the non-terse registers
;

Static  PrtERegs2, LABEL, BYTE
        OutMsglc        GDTRmsg
        OutDwordHexPtr  GDTsav.DTRBaseLow
        OutBlank
        OutWordHexPtr   GDTsav.DTRLimit
        OutBlanks       2

        OutMsglc        IDTRmsg
        OutDwordHexPtr  IDTsav.DTRBaseLow
        OutBlank
        OutWordHexPtr   IDTsav.DTRLimit
        OutBlanks       2

        OutMsglc        TRmsg
        OutWordHexPtr   TRsav
        OutBlank

        OutMsglc        LDTRmsg
        OutWordHexPtr   LDTsav
        OutBlank

        CallOp          PrtCR0                          ; Print CR0 flags
        OutCrLf

        OutMsglc        DR0msg
        OutDwordHexPtr  DR0sav
        OutBlank
        CallOp          PrtDR0b, DR7sav                 ; DR7 flags (dr0)
        OutBlanks       2

        OutMsglc        DR1msg
        OutDwordHexPtr  DR1sav
        OutBlank
        CallOp          PrtDR1b, DR7sav                 ; DR7 flags (dr1)
        OutBlanks       2

        OutMsglc        DR2msg
        OutDwordHexPtr  DR2sav
        OutBlank
        CallOp          PrtDR2b, DR7sav                 ; DR7 flags (dr2)
        OutBlanks       2

        OutMsglc        DR3msg
        OutDwordHexPtr  DR3sav
        OutBlank
        CallOp          PrtDR3b, DR7sav                 ; DR7 flags (dr3)
        OutCrLf

        OutMsglc        TR6msg
        CallOp          PrtTR6, TR6sav                  ; Print TR6 flags
        OutBlanks       2

        OutMsglc        TR7msg
        CallOp          PrtTR7, TR7sav                  ; Print TR7 flags
        OutBlanks       2

        OutMsglc        DR6msg
        CallOp          PrtDR6, DR6sav                  ; Print DR6 flags
        OutBlanks       2

        OutMsglc        DR7msg
        CallOp          PrtDR7, DR7sav
        OutCrLf

        EndOp
;
;       Print MSW flags OpInterpret opcode subroutine.
;

MSWoffst        equ     0

Global  PrtMSW, LABEL, BYTE
        OutMsglc                MSWmsg
        OutMsgIfBitSetArglc     MSWoffst,  3, TSfmsg
        OutMsgIfBitSetArglc     MSWoffst,  3, Blankmsg
        OutMsgIfBitSetArglc     MSWoffst,  2, EMfmsg
        OutMsgIfBitSetArglc     MSWoffst,  2, Blankmsg
        OutMsgIfBitSetArglc     MSWoffst,  1, MPfmsg
        OutMsgIfBitSetArglc     MSWoffst,  1, Blankmsg
        OutMsgIfBitSetArglc     MSWoffst,  0, PMfmsg
        EndOp                   1

;
;       Print flags OpInterpret opcode subroutine format list.
;

FlagOffst       equ     0

Global  PrtFlags, LABEL, BYTE
        OutMsgIfBitSetArglc     FlagOffst, 14, NTfmsg
        OutMsgIfBitClrArglc     FlagOffst, 14, Min2msg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 11, OVfmsg
        OutMsgIfBitClrArglc     FlagOffst, 11, NVfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 10, DNfmsg
        OutMsgIfBitClrArglc     FlagOffst, 10, UPfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 9, EIfmsg
        OutMsgIfBitClrArglc     FlagOffst, 9, DIfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 7, NGfmsg
        OutMsgIfBitClrArglc     FlagOffst, 7, PLfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 6, ZRfmsg
        OutMsgIfBitClrArglc     FlagOffst, 6, NZfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 4, ACfmsg
        OutMsgIfBitClrArglc     FlagOffst, 4, NAfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 2, PEfmsg
        OutMsgIfBitClrArglc     FlagOffst, 2, POfmsg
        OutBlank

        OutMsgIfBitSetArglc     FlagOffst, 0, CYfmsg
        OutMsgIfBitClrArglc     FlagOffst, 0, NCfmsg
        EndOp           1

;
;       Print RFVM flags OpInterpret opcode subroutine.
;

RFVMoffst       equ     0

Global  PrtRFVM, LABEL, BYTE
        OutMsgIfBitSetArglc     RFVMoffst, 16, RFfmsg
        OutMsgIfBitClrArglc     RFVMoffst, 16, Min2msg
        OutBlank
        OutMsgIfBitSetArglc     RFVMoffst, 17, VMfmsg
        OutMsgIfBitClrArglc     RFVMoffst, 17, Min2msg
        EndOp                   1

;
;       Print CR0 flags OpInterpret opcode subroutine.
;

Static  PrtCR0, LABEL, BYTE
        OutMsglc                CR0msg
        OutMsgIfBitSetlc        CR0sav, 31, PGfmsg
        OutMsgIfBitClrlc        CR0sav, 31, Min2msg
        OutBlank
        OutMsgIfBitSetlc        CR0sav, 4, ETfmsg
        OutMsgIfBitClrlc        CR0sav, 4, Min2msg
        OutBlank
        OutMsgIfBitSetlc        CR0sav, 3, TSfmsg
        OutMsgIfBitClrlc        CR0sav, 3, Min2msg
        OutBlank
        OutMsgIfBitSetlc        CR0sav, 2, EMfmsg
        OutMsgIfBitClrlc        CR0sav, 2, Min2msg
        OutBlank
        OutMsgIfBitSetlc        CR0sav, 1, MPfmsg
        OutMsgIfBitClrlc        CR0sav, 1, Min2msg
        OutBlank
        OutMsgIfBitSetlc        CR0sav, 0, PMfmsg
        OutMsgIfBitClrlc        CR0sav, 0, Min2msg
        EndOp                   0

;
;       Print DR7 fields for DR0-3 OpInterpret opcode subroutine.
;

DR7offst        equ     0

Static  PrtDR0b, LABEL, BYTE
        OutMsgIfBitSetArglc     DR7offst, 1, Gfmsg
        OutMsgIfBitClrArglc     DR7offst, 1, Minfmsg
        OutMsgIfBitSetArglc     DR7offst, 0, Lfmsg
        OutMsgIfBitClrArglc     DR7offst, 0, Minfmsg
        OutMsgBitFlc            DR7sav.HighWord, 0, 2, RWmsgTbl
        OutMsgBitFlc            DR7sav.HighWord, 2, 2, LnmsgTbl
        OutMsgIfBitSetlc        DR6sav, 0, Bfmsg
        OutMsgIfBitClrlc        DR6sav, 0, Minfmsg
        EndOp                   1

Static  PrtDR1b, LABEL, BYTE
        OutMsgIfBitSetArglc     DR7offst, 3, Gfmsg
        OutMsgIfBitClrArglc     DR7offst, 3, Minfmsg
        OutMsgIfBitSetArglc     DR7offst, 2, Lfmsg
        OutMsgIfBitClrArglc     DR7offst, 2, Minfmsg
        OutMsgBitFlc            DR7sav.HighWord, 4, 2, RWmsgTbl
        OutMsgBitFlc            DR7sav.HighWord, 6, 2, LnmsgTbl
        OutMsgIfBitSetlc        DR6sav, 1, Bfmsg
        OutMsgIfBitClrlc        DR6sav, 1, Minfmsg
        EndOp                   1

Static  PrtDR2b, LABEL, BYTE
        OutMsgIfBitSetArglc     DR7offst, 5, Gfmsg
        OutMsgIfBitClrArglc     DR7offst, 5, Minfmsg
        OutMsgIfBitSetArglc     DR7offst, 4, Lfmsg
        OutMsgIfBitClrArglc     DR7offst, 4, Minfmsg
        OutMsgBitFlc            DR7sav.HighWord, 8, 2, RWmsgTbl
        OutMsgBitFlc            DR7sav.HighWord, 10, 2, LnmsgTbl
        OutMsgIfBitSetlc        DR6sav, 2, Bfmsg
        OutMsgIfBitClrlc        DR6sav, 2, Minfmsg
        EndOp                   1

Static  PrtDR3b, LABEL, BYTE
        OutMsgIfBitSetArglc     DR7offst, 7, Gfmsg
        OutMsgIfBitClrArglc     DR7offst, 7, Minfmsg
        OutMsgIfBitSetArglc     DR7offst, 6, Lfmsg
        OutMsgIfBitClrArglc     DR7offst, 6, Minfmsg
        OutMsgBitFlc            DR7sav.HighWord, 12, 2, RWmsgTbl
        OutMsgBitFlc            DR7sav.HighWord, 14, 2, LnmsgTbl
        OutMsgIfBitSetlc        DR6sav, 3, Bfmsg
        OutMsgIfBitClrlc        DR6sav, 3, Minfmsg
        EndOp                   1

;
;       Print TR6 and flags OpInterpret opcode subroutine.
;

TR6offst        equ     0

Static  PrtTR6, LABEL, BYTE
        OutBitFHexArg           TR6offst, 12, 20, 5
        OutMsglc                Veqmsg
        OutBitFHexArg           TR6offst, 11, 1
        OutMsglc                Deqmsg
        OutBitFHexArg           TR6offst, 10, 1
        OutBitFHexArg           TR6offst, 9, 1
        OutMsglc                Ueqmsg
        OutBitFHexArg           TR6offst, 8, 1
        OutBitFHexArg           TR6offst, 7, 1
        OutMsglc                Weqmsg
        OutBitFHexArg           TR6offst, 6, 1
        OutBitFHexArg           TR6offst, 5, 1
        OutMsglc                Ceqmsg
        OutMsgIfBitSetArglc     TR6offst, 1, Rmsg
        OutMsgIfBitClrArglc     TR6offst, 1, Wmsg
        EndOp                   1

;
;       Print TR7 and flags OpInterpret opcode subroutine.
;

TR7offst        equ     0

Static  PrtTR7, LABEL, BYTE
        OutBitFHexArg           TR7offst, 12, 20, 5
        OutMsglc                HTeqmsg
        OutBitFHexArg           TR7offst, 4, 1
        OutMsglc                RPeqmsg
        OutBitFHexArg           TR7offst, 2, 2
        EndOp                   1

;
;       Print DR6 flags OpInterpret opcode subroutine.
;

DR6offst        equ     0

Static  PrtDR6, LABEL, BYTE
        OutMsgIfBitSetArglc     DR6offst, 15, BTfmsg
        OutMsgIfBitClrArglc     DR6offst, 15, Min2msg
        OutBlank
        OutMsgIfBitSetArglc     DR6offst, 14, BSfmsg
        OutMsgIfBitClrArglc     DR6offst, 14, Min2msg
        OutBlank
        OutMsgIfBitSetArglc     DR6offst, 13, BDfmsg
        OutMsgIfBitClrArglc     DR6offst, 13, Min2msg
        EndOp                   1

;
;       Print DR7 flags OpInterpret opcode subroutine.
;

DR7offst        equ     0

Static  PrtDR7, LABEL, BYTE
        OutMsgIfBitSetArglc     DR7offst, 9, GEfmsg
        OutMsgIfBitClrArglc     DR7offst, 9, Min2msg
        OutBlank
        OutMsgIfBitSetArglc     DR7offst, 8, LEfmsg
        OutMsgIfBitClrArglc     DR7offst, 8, Min2msg
        EndOp                   1

DataSegmentEnd

CodeSegmentStart

Extern  CmdBreak,       NEAR
Extern  perror,         NEAR


;***    reg
;
;       Perform register dump
;
;       Entry:  NONE
;
;       Exit:   NONE
;
;       Uses:   ALL
;

DefProc reg, NEAR, PUBLIC
        Pcall   ScanP
        jnz     short reg1
; LARRYB
;        Pcall   SetDefaults
;        mov     di,offset RegSA
;        mov     si,_vpCRI
;        mov     es,_vpCRI+2
; .386
;        mov     eax,dword ptr es:[si+cri_eax]
;        mov     [di].EAXsav,eax
;        mov     eax,dword ptr es:[si+cri_ebx]
;        mov     [di].EBXsav,eax
;        mov     eax,dword ptr es:[si+cri_ecx]
;        mov     [di].ECXsav,eax
;        mov     eax,dword ptr es:[si+cri_edx]
;        mov     [di].EDXsav,eax
;        mov     eax,dword ptr es:[si+cri_ebp]
;        mov     [di].EBPsav,eax
;        mov     eax,dword ptr es:[si+cri_esp]
;        mov     [di].ESPsav,eax
;        mov     ax,word ptr es:[si+cri_ss]
;        mov     [di].SSsav,ax
;        mov     ax,word ptr es:[si+cri_cs]
;        mov     [di].CSsav,ax
;        mov     eax,word ptr es:[si+cri_eip]
;        mov     [di].EIPsav,eax
;.286
        mov     ax,ds
        mov     es,ax           ; restore ES
        mov     [pRegSA],dataOFFSET RegSA
        Pcall   DispReg
        jmp     short regx

reg1:   mov     si,pTXT
        cmp     byte ptr [si],'T'
        jne     regx
        cmp     byte ptr [si+1],0
        jne     regx
        Pcall   SkipB
        xor     DebData.InitFlag,INIT_NOREGTERSE
        jmp     short regx

regx:
EndProc


;***    DispReg
;
;       Pcall   DispReg
;
;       Display registers.
;
;       ENTRY:  [pRegSA] points to RegSA_Frame to be used.
;
;       EXIT:   NONE
;
;       USES:   AX, BX, CX, DX, SI, DI, Flags
;

DefProc DispReg, NEAR, PUBLIC

;       Print the fault message and error code (if any).

; LARRYB
;        Pcall   PrintTrapMsg

;       Print anything only if enabled to do so.

;        cmp     fTraceCount,0
;        je      short prg0                      ; Normal reg dump
;        jmp     short prg5                      ; No display

;       Print the register save area only if we are enabled to do so

prg0:
; LARRYB
;        cmp     fRegDisp,0
;        je      short prg3

        mov     di,[pRegSA]
        mov     si,dataOFFSET PrtRegs           ; assume 16 bit regs
        test    DebData.InitFlag,INIT_ENV386
        jz      short prg1
        mov     si,dataOFFSET PrtERegs          ; dump 32 bit regs
prg1:   Pcall   OpInterpret

        test    DebData.InitFlag,INIT_NOREGTERSE; if 0, dump terse register set
        jz      prg3

        mov     si,dataOFFSET PrtRegs2          ; assume 16 bit regs
        test    DebData.InitFlag,INIT_ENV386
        jz      short prg2
        mov     si,dataOFFSET PrtERegs2         ; dump full register set
prg2:   Pcall   OpInterpret

;       Print the current cs:ip disassembled

prg3:
;155531 make .r use the correct addressing mode based on EFLAGS etc..
        mov     ax,EXPR_SIZE_DWORD_W + EXPR_TYPE_SEL_W
        mov     bx,RegSA.EFsav.HighWord ; (bx) = high word of eflags ;155531
        and     bx,10b                  ; (bx) = 0000 0000 0000 00V0 ;155531
        jz      short prg31             ;                            ;155531
        mov     ax,EXPR_SIZE_DWORD_W + EXPR_TYPE_SEG_W               ;155531
prg31:  mov     [DefType],ax            ; set default address type   ;155531
        lea     bx,DisAddr
        mov     ax,word ptr RegSA.IPsav
        mov     cx,word ptr RegSA.IPsav+2
        mov     dx,word ptr RegSA.CSsav
;155531        Pcall   FillSelAddr, <bx, dx, ax,cx>
        Pcall   FillDefAddr, <bx, dx, ax,cx>                        ;155531

        Pcall   disasln
        or      ax,ax                           ; Any bytes disassembled?
        jz      short prg4                      ;  no, skip ahead
        push    ds
        push    offset opbuf
        call    far ptr _decodeop
        add     sp,4
;        Ccall   decodeop, <dataOFFSET opbuf>    ; Decode operands into buffer

prg4:
        mov     dx,dataOFFSET opbuf
        Pcall   rprbuf                          ; Print disassembled instrs
        Pcall   crlf
        mov     bx,[pRegSA]
        add     bx,CSIPsav
        Pcall   CopyAddr, <bx, dataOFFSET DisAddr>
prg5:

EndProc

CodeSegmentEnd

        end
