home *** CD-ROM | disk | FTP | other *** search
-
- Title 'Wolfware Assembler Sample Program', '8087 State Display'
-
- ;=============================================================================
- ; Show87
- ; Copyright (c) 1987-1988 Eric Tauck
- ; All Rights Reserved
- ;
- ; This a memory resident program to display the present state of an
- ; installed 8087 coprocessor. Once assembled, to execute, type:
- ;
- ; SHOW87 [/R]
- ;
- ; If run without any options, the program executes a DOS shell and can be
- ; removed from memory by typing EXIT at any DOS prompt. If run with the
- ; /R option, the progam is made resident and cannot be removed (but uses
- ; less memory). Uses about 5600 bytes of memory with /R, over 8000 without.
- ; Requires CONVERT1.INC, CONVERT2.INC, VIDEO1.INC, and VIDEO2.INC on the
- ; default drive/path for assembly.
- ;
- ; The hot key is ALT-7. Traps interrupt 16H and uses only BIOS routines for
- ; display, thus should work on most computers with most software.
- ;
- ; Show87 assumes that an 8087 is installed. If one isn't installed, this
- ; program will probably hang the computer.
- ;
- ;----------------------------------------------------------------------------
- ;8 Ins Ptr XXXXX | Prec XX | ST(0) +X.XXXXXXXXXXXXXXXXX +XXXXX XXXXXX S
- ;0 Opr Ptr XXXXX | Round XXXXX | ST(1) +X.XXXXXXXXXXXXXXXXX +XXXXX XXXXXX H
- ;8 Op Code XXXX | Infin XXXXX | ST(2) +X.XXXXXXXXXXXXXXXXX +XXXXX XXXXXX O
- ;7 Control XXXX |------------- | ST(3) +X.XXXXXXXXXXXXXXXXX +XXXXX XXXXXX W
- ;| Status XXXX | Cond XXXX | ST(4) =XXXXXXXXXXXXXXXX =XXXX XXXXXX 8
- ;S Tag XXXX | Comp X | ST(5) =XXXXXXXXXXXXXXXX =XXXX XXXXXX 7
- ;T ---------------| Test X | ST(6) =XXXXXXXXXXXXXXXX =XXXX XXXXXX |
- ;A Stack Top X | Exam XXXXXX | ST(7) =XXXXXXXXXXXXXXXX =XXXX XXXXXX X
- ;T ------------------------------------------------------------------------ X
- ;E Except PX UX OX ZX DX IX Intr Mask PX UX OX ZX DX IX Ints XXXXXXXX X
- ;----------------------------------------------------------------------------
- ;
- ; Compare: > < = ?
- ; Test: + - 0 ?
- ; Examine: +Unorm +NAN -Unorm -NAN +Norm +Infin -Norm -Infin +0 -0 +Dnorm
- ; -Dnorm Empty
- ; Precision: 24 53 64 ??
- ; Rounding: Near Up Down Trunc
- ; Infinity: Proj Affin
- ; Interrupts: Enabled Disabled
-
- Ver_Hi Equ 1 ;ones version number
- Ver_Lo Equ 10 ;tens version number
-
- Hotkey Equ 7e00h ;hot key, Alt-7
-
- StartRow Equ 0 ;screen row offset
- StartCol Equ 0 ;screen column offset
- Rows Equ 12 ;rows in display
- Cols Equ 76 ;columns in display
-
- Atr_Bor Equ 07h ;border attribute
- Atr_Mes Equ 70h ;edge text attribute
- Atr_Lin Equ 07h ;line attribute
- Atr_Tex Equ 07h ;center text attribute
- Atr_Set Equ 07h ;number and settings attribute
-
- Sig_Bits Equ 57 ;number of significant bits in real number display
-
- ;================================================
- ; Main program, execute shell after resetting
- ; interrupt 16H.
-
- Jmp Init ;go to initialization
-
- ;--- switch stack and set memory allocation
-
- Start
- Mov Bx, Offset Program_Stack ;new stack top
- Mov Sp, Bx ;switch to stack
- Mov Cl, 4
- Shr Bx, Cl ;make paragraph
- Inc Bx ;account for extra
-
- Test Status, Status1 ;check if resident mode
- Jnz Main1
-
- Mov Ah, 4ah ;function
- Int 21h ;execute
-
- ;--- save the interrupt data
-
- Main1
- Push Bx
- Push Es
- Mov Ax, 3516h ;function and interrupt number
- Int 21h
- Mov Word Original16, Bx ;save offset
- Mov Word Original16+2, Es ;save segment
- Pop Es
- Pop Bx
-
- ;--- load the new interrupt
-
- Mov Ax, 2516h ;function
- Mov Dx, Offset Interrupt16 ;entry point offset
- Int 21h ;execute
-
- Test Status, Status1 ;check if resident mode
- Jnz Main3
-
- ;--- initialize the EXEC parameter block and enter shell
-
- Push Es
- Push Ds
- Mov Prog_Off, Sp ;save stack offset
- Mov Prog_Seg, Ss ;save stack segment
-
- Mov Ax, 4b00h
- Mov Bx, Offset Parameter_Blk ;pararmeter block location
- Mov [Bx+4], Cs ;save the present segment
- Mov Dx, CmdLoc ;program name offset
- Mov Ds, [2ch] ; segment
- Int 21h
-
- Cli
- Cs:
- Mov Sp, Prog_Off ;restore stack offset
- Cs:
- Mov Ss, Prog_Seg ;restore stack segment
- Sti
- Pop Ds
- Pop Es
-
- ;--- show exit message
-
- Sub Al, Al
- Mov Dx, Offset Closemes ;normal termination message
- Jnc Main2
- Mov Al, 0ffh
- Mov Dx, Offset Errormes ;error message
- Main2
- Mov Ah, 9 ;function
- Int 21h ;show message
-
- ;--- finished
-
- Push Ax ;save return code
- Mov Ax, 2516h ;function
- Lds Dx, Original16 ;load original interrupt location
- Int 21h ;execute
- Pop Ax
-
- Mov Ah, 4ch ;exit function
- Int 21h ;execute
-
- ;--- resident mode, terminate and stay resident
-
- Main3
- Mov Ax, 3100h ;function and return code
- Mov Dx, Bx ;paragraphs to save
- Int 21h ;execute
-
- ;================================================
- ; Control recieved through interrupt 16H.
-
- Interrupt16 Proc Far
-
- ;--- check if activation key
-
- Sti ;interrrupts on
- Cmp Ah, 0 ;check if key request
- Je Inter1
- Cmp Ah, 1 ;check if status request
- Je Inter2
- Cs:
- Jmp Original16 ;non-key request, transfer directly to INT 16
-
- ;--- key request, function 0
-
- Inter1
- Pushf ;flags on stack
- Cs:
- Call Original16 ;get key
- Cmp Ax, HotKey ;check if activation key
- Je Inter5 ;jump if so
- Iret
-
- ;--- key status request
-
- Inter2
- Pushf ;flags on stack
- Cs:
- Call Original16 ;get key status
- Jz Inter3 ;jump if no key
- Pushf ;must save return flags
- Cmp Ax, HotKey ;check if activation key
- Je Inter4 ;jump if so
- Popf ;not key, restore flags
- Inter3
- Ret 2
-
- ;=== activation key detected, proceed with display
-
- ;--- status only, must toss out key
-
- Inter4
- Add Sp, 2 ;throw out flags save by status
- Sub Ah, Ah ;get key function
- Pushf ;flags on stack
- Cs:
- Call Original16 ;get key
- Mov Ah, 1 ;reset actual function
-
- ;--- save stack
-
- Inter5
- Cs:
- Mov Stack_Seg, Ss ;segment
- Cs:
- Mov Stack_Off, Sp ;offset
-
- ;--- switch to local stack
-
- Cli
- Push Cs
- Pop Ss ;set to local segment
- Mov Sp, Offset Local_Stack ;set to offset
- Sti
-
- ;--- save registers
-
- Pushf
- Push Ax
- Push Bx
- Push Cx
- Push Dx
- Push Di
- Push Si
- Push Bp
- Push Ds
- Push Es
-
- ;--- initialize
-
- Push Cs
- Pop Ds ;set data segment
- Push Cs
- Pop Es ;set other data segment
-
- Cli
- Fnsave State_Area ;save the 8087 state
- Fwait ;synchronize
- Sti
-
- Cld ;normal direction
- Mov IntFunc, Ah ;save the function for termination
- Call Video_Init ;initialize display data
-
- Call Video_Cget ;get the cursor location
- Mov CurLoc, Dx ;save it
-
- ;--- save the screen area
-
- Mov Dh, StartRow ;first row
- Mov Di, Offset Save_Area ;screen save area
-
- Inter6
- Mov Dl, StartCol ;first column
-
- Inter7
- Call Video_Cset ;move cursor
-
- Mov Ah, 8 ;function
- Mov Bh, Video_Page ;get the page
- Push Di
- Int 10h ;execute, get character
- Pop Di
- Stosw ;store AH and AL
- Inc Dl ;next column
-
- Cmp Dl, StartCol+Cols ;check if past end
- Jb Inter7 ;loop back if not
- Inc Dh ;next row
-
- Cmp Dh, StartRow+Rows ;check if past end
- Jb Inter6 ;loop back if not
-
- ;--- show main display
-
- Mov Bl, Atr_Set ;attribute
- Mov Cx, StartRow*256+StartCol ;upper left corner
- Mov Dx, (StartRow+Rows-1*256)+StartCol+Cols-1 ;lower right corner
- Call Video_Cpag ;clear screen area
- Mov Si, Offset Display1 ;main display string
- Call Video_Wstr ;write to screen
-
- ;--- show stats
-
- Call Display_State ;show state
-
- ;--- wait for key
-
- Mov Dx, (StartRow+Rows-1*256)+StartCol+Cols-1 ;lower right corner
- Call Video_Cset ;move cursor there
-
- Sub Ah, Ah ;function number
- Pushf
- Call Original16 ;get a key
-
- ;--- restore the screen area
-
- Mov Dh, StartRow ;first row
- Mov Si, Offset Save_Area ;screen save area
-
- Inter8
- Mov Dl, StartCol ;first column
-
- Inter9
- Call Video_Cset ;move cursor
-
- Lodsw ;load character and attribute
- Mov Bl, Ah ;attribute
- Mov Ah, 9 ;function
- Mov Bh, Video_Page ;get the page
- Mov Cx, 1 ;count
- Push Si
- Int 10h ;execute, get character
- Pop Si
-
- Inc Dl
- Cmp Dl, StartCol+Cols ;check if past end
- Jb Inter9 ;loop back if not
- Inc Dh ;next row
-
- Cmp Dh, StartRow+Rows ;check if past end
- Jb Inter8 ;loop back if not
-
- ;--- finished
-
- Mov Dx, CurLoc ;get cursor location
- Call Video_Cset ;set it
-
- Frstor State_Area ;restore state
-
- Pop Es
- Pop Ds
- Pop Bp
- Pop Si
- Pop Di
- Pop Dx
- Pop Cx
- Pop Bx
- Pop Ax
- Popf
-
- ;--- restore original stack
-
- Cli
- Cs:
- Mov Ss, Stack_Seg ;segment
- Cs:
- Mov Sp, Stack_Off ;offset
- Sti
-
- ;--- transfer to interrupt 16H as if nothing had happened
-
- Cs:
- Mov Ah, IntFunc ;save the function for termination
- Cs:
- Jmp Original16 ;transfer to INT 16
- Endp ;Interrupt16
-
- ;================================================
- ; Display the 8087 state.
-
- Display_State Proc Near
-
- ;--- instruction pointer
-
- Mov Ax, State_Area+6 ;instruction pointer, lower 16 bits
- Mov Bx, State_Area+8 ; upper 4 bits
- Mov Cl, 12
- Shr Bx, Cl ;put the bits in the bottom
- Mov Cx, 5*256+16 ;display width and base
- Mov Dx, 1*256+11 ;display location offset
- Call Display_Number ;display
-
- ;--- operand pointer
-
- Mov Ax, State_Area+10 ;operand pointer, lower 16 bits
- Mov Bx, State_Area+12 ; upper 4 bits
- Push Cx
- Mov Cl, 12
- Shr Bx, Cl ;put the bits in the bottom
- Pop Cx
- Inc Dh ;next row
- Call Display_Number ;display
-
- ;--- op code
-
- Mov Ax, State_Area+8 ;get the op code
- And Ax, 0000011111111111b ;mask out bits
- Or Ax, 1101100000000000b ;set implicit bits
- Sub Bx, Bx ;clear high word
- Mov Ch, 4 ;new display width
- Inc Dh ;next row
- Inc Dl ;next column
- Call Display_Number ;display
-
- ;--- control word
-
- Mov Ax, State_Area ;control word
- Inc Dh ;next row
- Call Display_Number ;display
-
- ;--- status word
-
- Mov Ax, State_Area+2 ;status word
- Inc Dh ;next row
- Call Display_Number ;display
-
- ;--- tag word
-
- Mov Ax, State_Area+4 ;tag word
- Inc Dh ;next row
- Call Display_Number ;display
-
- ;--- stack top
-
- Call Get_Stack ;get the stack top
- Sub Ah, Ah
- Add Dx, 0203h ;add two to the rows and add three to the columns
- Mov Cx, 1*256+10 ;display width and base
- Call Display_Number ;display
-
- ;--- precision
-
- Mov Bl, State_Area+1 ;high word of control
- And Bl, 11b ;mask bits
- Sub Bh, Bh
- Mov Cl, 2 ;width
- Mov Dx, 1*256+29 ;display location offset
- Mov Di, Offset Dissta3b ;table
- Call Display_Istr ;display string
-
- ;--- rounding
-
- Mov Bl, State_Area+1 ;high word of control
- And Bl, 1100b ;mask bits
- Sub Bh, Bh
- Shr Bx
- Shr Bx
- Mov Cl, 5 ;width
- Inc Dh
- Sub Dl, 3 ;display location offset
- Mov Di, Offset Dissta4b ;table
- Call Display_Istr ;display string
-
- ;--- infinity
-
- Mov Bl, State_Area+1 ;high word of control
- And Bl, 10000b ;mask bit
- Sub Bh, Bh
- Mov Cl, 4
- Shr Bx, Cl
- Mov Cl, 5 ;width
- Inc Dh ;next row
- Mov Di, Offset Dissta5b ;table
- Call Display_Istr ;display string
-
- ;--- condition codes
-
- Mov Al, State_Area+3 ;high byte of status
- Call Adjst_Codes ;adjust the condition codes
- Sub Bx, Bx ;clear high word
- Mov Cx, 4*256+2 ;display width and base
- Add Dx, 0201h ;new location
- Call Display_Number ;display
-
- ;--- comparison and test
-
- Call Get_Comp ;get the index
- Mov Cl, 1 ;width
- Add Dx, 0103h ;location
- Mov Di, Offset Dissta1b ;table
- Call Display_Istr ;display string
-
- Inc Dh
- Mov Di, Offset Dissta2b ;table
- Call Display_Istr ;display string
-
- ;--- examine
-
- Mov Al, State_Area+3 ;high byte of status
- Inc Dh
- Sub Dl, 5 ;location
- Call Display_Exam ;display
-
- ;--- exception bit settings
-
- Mov Al, State_Area+2 ;get the bits
- Mov Dx, 10*256+10 ;display offset
- Call Display_Bits ;display
-
- ;--- mask bit settings
-
- Mov Al, State_Area ;get the bits
- Mov Dx, 10*256+41 ;display offset
- Call Display_Bits ;display
-
- ;--- interrupts
-
- Mov Ax, State_Area ;control word
- Shl Ax ;shift bit to high byte
- And Ah, 1b ;mask
- Mov Bl, Ah
- Sub Bh, Bh
- Mov Cl, -8 ;width
- Mov Dx, 10*256+66 ;display offset
- Mov Di, Offset Dissta6b ;table
- Call Display_Istr ;display string
-
- ;--- show stack data
-
- Call Display_Stack ;show stack values
- Ret
-
- ;--- data
-
- Dissta1a Db '>',0, '<',0, '=',0, '?',0
- Dissta1b Dw Offset Dissta1a, Offset Dissta1a+2,
- Dw Offset Dissta1a+4, Offset Dissta1a+6
-
- Dissta2a Db '+',0, '-',0, '0',0, '?',0
- Dissta2b Dw Offset Dissta2a, Offset Dissta2a+2,
- Dw Offset Dissta2a+4, Offset Dissta2a+6
-
- Dissta3a Db '24',0, '??',0, '53',0, '64',0
- Dissta3b Dw Offset Dissta3a, Offset Dissta3a+3,
- Dw Offset Dissta3a+6, Offset Dissta3a+9
-
- Dissta4a Db 'Near',0, 'Up',0, 'Down',0, 'Trunc',0
- Dissta4b Dw Offset Dissta4a, Offset Dissta4a+5,
- Dw Offset Dissta4a+8, Offset Dissta4a+13
-
- Dissta5a Db 'Proj',0, 'Affin',0
- Dissta5b Dw Offset Dissta5a, Offset Dissta5a+5
-
- Dissta6a Db 'Enabled',0, 'Disabled',0
- Dissta6b Dw Offset Dissta6a, Offset Dissta6a+8
- Endp ;Display_State
-
- ;================================================
- ; Display of the settings of six consecutive
- ; bits.
- ;
- ; In: AL= bit pattern; DX= row and column display
- ; offset.
-
- Display_Bits Proc Near
- Mov Ah, Al
- Mov Bh, 20h ;first bit to check
- Mov Cx, 6 ;bits to check
- Add Dx, StartRow*256+StartCol ;real screen location
-
- ;--- loop for each bit
-
- Disbit1
- Mov Al, '-' ;not set sign
- Test Ah, Bh ;check if set
- Jz Disbit2
- Mov Al, '+' ;set sign
-
- Disbit2
- Call Display_Char ;display character
- Shr Bh ;shift bit to test
- Add Dl, 2 ;next location
- Loop Disbit1
-
- Ret
- Endp ;Display_Bits
-
- ;================================================
- ; Display the stack values.
-
- Display_Stack Proc Near
- Std
- Mov Bx, Offset State_Area ;save area
- Add Bx, 14 ;skip to numbers
- Mov Cx, 8 ;8087 stack entries
- Mov Dh, StartRow+1 ;first display row
-
- ;=== display a number
-
- Disstk1
- Push Bx
- Push Cx
-
- Fld Tbyte [Bx] ;load number
-
- ;--- get number type or set to empty
-
- Push Cx ;save stack number
- Call Get_Stack ;get the stack top
- Mov Cl, Al
- Mov Ax, State_Area+4 ;get the tag word
- Shl Cl ;two bits for each tag
- Ror Ax, Cl ;adjust so first tag is in low bits
- Pop Cx
- Mov Ch, 8
- Sub Ch, Cl
- Shl Ch ;bits to shift to put set tag low
- Mov Cl, Ch
- Shr Ax, Cl ;tag bits to lower bit locations 0 and 1
- And Ax, 11b ;mask bits
-
- ;--- check type
-
- Cmp Ax, 11b ;check if empty
- Je Disstk2
-
- Fxam ;check number type
- Fstsw Status87 ;store status
-
- Cmp Ax, 10b ;check if special
- Je Disstk3 ;jump if so
-
- ;--- normal value
-
- Call Display_Float ;display decimal number
- Jmps Disstk4
-
- ;--- empty
-
- Disstk2
- Mov Status87, 0ffffh ;set all bits
-
- ;--- special number
-
- Disstk3
- Call Display_Hex ;display hexadecimal bit pattern
-
- ;--- finished with a single stack number
-
- Disstk4
- Mov Al, Byte Status87+1 ;high byte of status
- Call Display_Exam ;display
- Pop Cx
- Pop Bx
-
- Add Bx, 10 ;next stack entry
- Inc Dh ;next row
- Loop Disstk1 ;loop for each entry
-
- Cld
- Ret
- Endp ;Display_Stack
-
- ;================================================
- ; Display a decimal floating point number.
- ;
- ; In: ST(0)= number; DH= row.
- ;
- ; Out: DX= row and column one space after number.
-
- Display_Float Proc Near
-
- ;--- convert number and store
-
- Mov Ax, Sig_Bits ;number of significant bits
- Call Flt2dec ;convert to decimal
- Mov Si, Offset Number_Store ;storage for number
- Fbstp Tbyte [Si] ;save number string
-
- ;--- display the mantissa sign
-
- Push Ax ;save the exponent
- Mov Dl, StartCol+40 ;column
-
- Add Si, 9 ;goto last byte
- Lodsb ;get the sign byte
- Mov Ah, '+'
- Test Al, 80h ;check if negative
- Jz Disflt1
- Mov Ah, '-'
- Disflt1
- Mov Al, Ah ;sign
- Call Display_Char ;display character
-
- ;--- first two digits and decimal point
-
- Lodsb
- Call Display_Bhi ;high digit
- Push Ax
- Mov Al, '.' ;decimal point
- Call Display_Char ;write point
- Pop Ax
- Call Display_Blo ;low digit
-
- ;--- remaining mantissa digits
-
- Mov Cx, 8 ;remaining number of packed bytes
-
- Disflt2
- Lodsb
- Call Display_Bhi ;high digit
- Call Display_Blo ;low digit
- Loop Disflt2
-
- ;--- exponent sign
-
- Pop Ax
- Inc Dl ;skip to exponent location
-
- Mov Cl, '+' ;plus
- Add Ax, 17 ;adjust for decimal point
- Jns Disflt3 ;jump if not minus
- Mov Cl, '-' ;minus
- Neg Ax
- Disflt3
- Push Ax
- Mov Al, Cl
- Call Display_Char ;display
- Pop Ax
-
- ;--- exponent
-
- Sub Bx, Bx ;clear high word
- Mov Cx, 5*256+10 ;load width and base
- Call Display_Number ;display
- Add Dl, 6 ;position cursor at end
- Ret
-
- ;------------------------------------------------
- ; Display a high packed BCD digit.
- ;
- ; In: AL= packed BCD digits; BL= attribute.
-
- Display_Bhi Proc Near
- Push Ax
- Shr Al
- Shr Al
- Shr Al
- Shr Al ;shift the high bits
- Add Al, '0' ;convert to decimal digit
- Call Display_Char ;write point
- Pop Ax
- Ret
- Endp ;Display_Bhi
-
- ;------------------------------------------------
- ; Display a low packed BCD digit.
- ;
- ; In: AL= packed BCD digits; BL= attribute.
-
- Display_Blo Proc Near
- Push Ax
- And Al, 0fh ;mask relevant bits
- Add Al, '0' ;convert to decimal digit
- Call Display_Char ;write point
- Pop Ax
- Ret
- Endp ;Display_Blo
-
- Endp ;Display_Float
-
- ;================================================
- ; Display the bit pattern of a floating point
- ; number.
- ;
- ; In: ST(0)= number; DH= row.
- ;
- ; Out: DX= row and column one space after number.
-
- Display_Hex Proc Near
- Fstp Dishex1 ;store number
- Fwait ;wait just in case
-
- Mov Al, '=' ;starting character
- Mov Dl, StartCol+43 ;column
- Call Display_Char ;display
-
- Mov Cx, 8 ;bytes
- Lea Si, Dishex1+7 ;last byte of mantissa
- Call Display_Byts ;display
-
- Mov Al, '=' ;starting character
- Add Dl, 2 ;column
- Call Display_Char ;display
-
- Mov Cx, 2 ;bytes
- Lea Si, Dishex1+9 ;last byte of exponent
- Call Display_Byts ;display
-
- Inc Dl ;next column
- Ret
-
- ;--- storage for the tempory real number
-
- Dishex1 Label Tbyte
- Ds 10
-
- ;------------------------------------------------
- ; Display backwards bytes.
- ;
- ; In: SI= starting location; CX= bytes.
-
- Display_Byts Proc Near
- Pushf
- Std
- Sub Ah, Ah ;clear high byte
- Sub Bx, Bx ;clear high word
-
- Disbys1
- Lodsb ;load byte
- Push Cx
- Push Si
- Mov Cx, 2*256+16 ;format
- Call Display_Number ;display
- Add Dl, 2 ;next location
- Pop Si
- Pop Cx
- Loop Disbys1 ;loop for each byte
- Popf
- Ret
- Endp ;Display_Byts
-
- Endp ;Display_Hex
-
- ;================================================
- ; Display an FXAM result.
- ;
- ; In: AL= high byte of 8087 status; DX= row and
- ; column location.
-
- Display_Exam Proc Near
- Call Adjst_Codes ;adjust the condition codes
- Mov Bx, Ax
- Mov Cl, 6 ;width
- Mov Di, Offset Disexm1b ;table
- Call Display_Istr ;display string
- Ret
-
- ;--- data
-
- Disexm1a Db '+Unorm',0, '+NAN',0, '-Unorm',0, '-NAN',0,
- Db '+Norm',0, '+Infin',0, '-Norm',0, '-Infin',0,
- Db '+0',0, '-0',0, '+Dnorm',0, '-Dnorm',0, 'Empty',0
- Disexm1b Dw Offset Disexm1a, Offset Disexm1a+7,
- Dw Offset Disexm1a+12, Offset Disexm1a+19
- Dw Offset Disexm1a+24, Offset Disexm1a+30
- Dw Offset Disexm1a+37, Offset Disexm1a+43
- Dw Offset Disexm1a+50, Offset Disexm1a+70
- Dw Offset Disexm1a+53, Offset Disexm1a+70
- Dw Offset Disexm1a+56, Offset Disexm1a+70
- Dw Offset Disexm1a+63, Offset Disexm1a+70
-
- Endp ;Display_Exam
-
- ;================================================
- ; Get the stack top number.
- ;
- ; Out: AL= stack number.
-
- Get_Stack Proc Near
- Mov Al, State_Area+3 ;get the high byte of the status word
- And Al, 00111000b ;mask out stack
- Shr Al
- Shr Al
- Shr Al ;adjust
- Ret
- Endp ;Get_Stack
-
- ;================================================
- ; Adjust the condition codes to consecutive bits.
- ;
- ; In: AL= high byte of status.
- ; Out: AX= condition codes in consecutive, least
- ; significant bit locations.
-
- Adjst_Codes Proc Near
- Mov Ah, Al
- And Al, 00000111b ;mask C2 to C0 bits
- And Ah, 01000000b ;mask C3 bit
- Shr Ah
- Shr Ah
- Shr Ah ;shift bit over
- Or Al, Ah ;combine
- Sub Ah, Ah
- Ret
- Endp ;Adjst_Codes
-
- ;================================================
- ; Get an index for the comparison and test
- ; instructions. Based on the condition codes.
- ;
- ; Out: BX= index.
-
- Get_Comp Proc Near
- Sub Bx, Bx
- Mov Al, State_Area+3 ;high byte of state
- And Al, 01000101b ;mask C3 C2 and C0
- Cmp Al, 00000000b ;check if 0 0 0
- Je Getcom1
- Inc Bx
- Cmp Al, 00000001b ;check if 0 0 1
- Je Getcom1
- Inc Bx
- Cmp Al, 01000000b ;check if 1 0 0
- Je Getcom1
- Inc Bx
-
- Getcom1 Ret
- Endp ;Get_Comp
-
- ;================================================
- ; Display a single character.
- ;
- ; In: AL= character; DX= location.
-
- Display_Char Proc Near
- Mov Bl, Atr_Set ;attribute
- Call Video_Cset ;set cursor location
- Call Video_Wchr ;write character
- Inc Dl ;next column
- Ret
- Endp ;Display_Char
-
- ;================================================
- ; Display a zero padded number to a location.
- ;
- ; In: BX:AX= number; CL= number base; CH= the
- ; display width; DX= location.
-
- Display_Number Proc Near
- Push Ax
- Push Cx
- Push Dx
- Add Dx, StartRow*256+StartCol ;real screen location
- Call Video_Cset ;move cursor
-
- Push Cx
- Sub Ch, Ch
- Mov Dx, Bx ;high word
- Mov Di, Offset Number_Store ;place to store
- Call Convert_Num ;convert to string
- Pop Cx
-
- Mov Al, '0' ;pad character
- Mov Cl, Ch
- Sub Ch, Ch
- Mov Si, Di
- Call Video_Wstrr ;display number
- Pop Dx
- Pop Cx
- Pop Ax
- Ret
- Endp ;Display_Number
-
- ;================================================
- ; Given an index and a table, displays a space
- ; padded string to a location.
- ;
- ; In: BX= index; DI= table offset; CL= width, if
- ; negative, the string is right justified instead
- ; of left; DX= location.
-
- Display_Istr Proc Near
- Push Ax
- Push Bx
- Push Cx
- Push Dx
- Push Si
-
- ;--- locate cursor
-
- Add Dx, StartRow*256+StartCol ;real screen location
- Call Video_Cset ;move cursor
-
- ;--- display string
-
- Mov Al, ' ' ;pad with spaces
- Shl Bx ;two bytes for offset
- Sub Ch, Ch
- Mov Si, [Di+Bx] ;get the string location
-
- Cmp Cl, 0
- Jg Disist1
-
- Neg Cl ;absolute value
- Call Video_Wstrl ;display, left justified
- Jmps Disist2
-
- Disist1
- Call Video_Wstrr ;display, right justified
-
- Disist2
- Pop Si
- Pop Dx
- Pop Cx
- Pop Bx
- Pop Ax
- Ret
- Endp ;Display_Istr
-
- ;================================================
- ; External files.
-
- Include 'Video1.Inc'
- Include 'Video2.Inc'
- Include 'Convert1.Inc'
- Include 'Convert2.Inc'
-
- ;================================================
- ; Data.
-
- ;--- program status
-
- Status1 Equ 01h ;execute in memory resident mode
-
- Status Db 0
-
- ;--- original interrupt 16H
-
- Original16 Label Dword
- Dw ? ;offset
- Dw ? ;segment
-
- ;--- shell parameter block
-
- Parameter_Blk Label Word
- Dw 0 ;use default environment
- Dw Offset CmdTail ;command tail
- Dw ? ;present segment
- Dw -1 ;
- Dw -1 ;
- Dw -1 ;-- no FCB'S
- Dw -1 ;
-
- CmdTail Db 0, 13
-
- ;--- saved stack addresses
-
- Prog_Off Dw ? ;-- save area through EXEC function
- Prog_Seg Dw ? ;
-
- Stack_Off Dw ? ;-- save area for alternate int 16
- Stack_Seg Dw ? ;
-
- ;--- other data
-
- CmdLoc Dw ? ;offset of command processor in environment
- Intfunc Db ? ;int 16 request
- CurLoc Dw ? ;saved cursor location
-
- ;--- main display string
-
- Display1 Label Byte
- Db FrmAtr, Atr_Bor
- Db FrmLoc, StartRow, StartCol, 219, FrmHor, 223, Cols-2, 219
- Db FrmLoc, StartRow+1, StartCol, FrmVer, 219, Rows-2
- Db FrmLoc, StartRow+1, StartCol+Cols-1, FrmVer, 219, Rows-2
- Db FrmLoc, StartRow+Rows-1, StartCol, 219, FrmHor, 220, Cols-2, 219
-
- Db FrmAtr, Atr_Lin
- Db FrmLoc, StartRow+9, StartCol+2, FrmHor, 196, 72
- Db FrmLoc, StartRow+1, StartCol+32, FrmVer, 179, 8, 193
- ;this prints some other lines, but I decided it looked better without them
- ; Db FrmLoc, StartRow+1, StartCol+17, FrmVer, 179, 8
- ; Db FrmLoc, StartRow+7, StartCol+2, FrmHor, 196, 15, 180
- ; Db FrmLoc, StartRow+4, StartCol+17, 195, FrmHor, 196, 13
-
- Db FrmAtr, Atr_Mes
- Db FrmLoc, StartRow+1, StartCol, '8'
- Db FrmLoc, StartRow+2, StartCol, '0'
- Db FrmLoc, StartRow+3, StartCol, '8'
- Db FrmLoc, StartRow+4, StartCol, '7'
- Db FrmLoc, StartRow+6, StartCol, 'S'
- Db FrmLoc, StartRow+7, StartCol, 'T'
- Db FrmLoc, StartRow+8, StartCol, 'A'
- Db FrmLoc, StartRow+9, StartCol, 'T'
- Db FrmLoc, StartRow+10, StartCol, 'E'
-
- Db FrmLoc, StartRow+1, StartCol+Cols-1, 'S'
- Db FrmLoc, StartRow+2, StartCol+Cols-1, 'H'
- Db FrmLoc, StartRow+3, StartCol+Cols-1, 'O'
- Db FrmLoc, StartRow+4, StartCol+Cols-1, 'W'
- Db FrmLoc, StartRow+5, StartCol+Cols-1, '8'
- Db FrmLoc, StartRow+6, StartCol+Cols-1, '7'
- Db FrmLoc, StartRow+8, StartCol+Cols-1, Ver_Hi\10+'0'
- Db FrmLoc, StartRow+9, StartCol+Cols-1, Ver_Lo/10+'0'
- Db FrmLoc, StartRow+10, StartCol+Cols-1, Ver_Lo\10+'0'
-
- Db FrmAtr, Atr_Tex
- Db FrmLoc, StartRow+1, StartCol+2, 'Ins Ptr'
- Db FrmLoc, StartRow+2, StartCol+2, 'Opr Ptr'
- Db FrmLoc, StartRow+3, StartCol+2, 'Op Code'
- Db FrmLoc, StartRow+4, StartCol+2, 'Control'
- Db FrmLoc, StartRow+5, StartCol+2, 'Status'
- Db FrmLoc, StartRow+6, StartCol+2, 'Tag'
-
- Db FrmLoc, StartRow+8, StartCol+2, 'Stack Top'
-
- Db FrmLoc, StartRow+1, StartCol+19, 'Prec'
- Db FrmLoc, StartRow+2, StartCol+19, 'Round'
- Db FrmLoc, StartRow+3, StartCol+19, 'Infin'
-
- Db FrmLoc, StartRow+5, StartCol+19, 'Cond'
- Db FrmLoc, StartRow+6, StartCol+19, 'Comp'
- Db FrmLoc, StartRow+7, StartCol+19, 'Test'
- Db FrmLoc, StartRow+8, StartCol+19, 'Exam'
-
- Db FrmLoc, StartRow+1, StartCol+34, 'ST(0)'
- Db FrmLoc, StartRow+2, StartCol+34, 'ST(1)'
- Db FrmLoc, StartRow+3, StartCol+34, 'ST(2)'
- Db FrmLoc, StartRow+4, StartCol+34, 'ST(3)'
- Db FrmLoc, StartRow+5, StartCol+34, 'ST(4)'
- Db FrmLoc, StartRow+6, StartCol+34, 'ST(5)'
- Db FrmLoc, StartRow+7, StartCol+34, 'ST(6)'
- Db FrmLoc, StartRow+8, StartCol+34, 'ST(7)'
-
- Db FrmLoc, StartRow+10, StartCol+2, 'Except'
- Db FrmLoc, StartRow+10, StartCol+9, FrmStr, Offset Display2
- Db FrmLoc, StartRow+10, StartCol+30, 'Intr Mask'
- Db FrmLoc, StartRow+10, StartCol+40, FrmStr, Offset Display2
- Db FrmLoc, StartRow+10, StartCol+61, 'Ints'
-
-
- Db FrmAtr, Atr_Set
- Db 0
-
- Display2 Db 'P U O Z D I', 0
-
- ;--- exit message
-
- Closemes Db 13,10,'SHOW87 is removed from memory.',13,10,'$'
- Errormes Db 13,10,'Error: Could not install SHOW87', 13,10,'$'
-
- ;================================================
- ; Uninitialized data.
-
- Save_Area Label Byte ;screen data
- Org +(Rows * Cols * 2)
- State_Area Label Anysize ;area to save the 8087 state
- Org +94
- Status87 Label Word ;8087 status storage for checking numbers
- Org +2
- Number_Store Label Byte ;storage for decimal number strings
- Org +11
- Org +100h
- Local_Stack Label Byte ;local stack for state display
- Org +100h
- Program_Stack Label Byte ;main program stack
-
- Org Offset Save_Area ;fix location
-
- ;================================================
- ; Transient code. Exists in unitialized data
- ; area, must be executed before the data area is
- ; used.
-
- ;--- display opening message
-
- Init
- Mov Dx, Offset Openmes ;message
- Mov Ah, 9 ;function
- Int 21h ;display
-
- ;--- find command processor
-
- Push Es
- Mov Cx, 8 ;string length
- Sub Di, Di ;starting offset of environment
- Mov Es, [2ch] ;environment segment
-
- ;--- loop for each string in the environment
-
- Init1
- Es:
- Cmp Byte [Di], 0 ;check if end of environment
- Je Init8
-
- Mov Cx, 8 ;string length
- Mov Si, Offset Comspec ;string location
-
- Repe
- Cmpsb ;compare bytes
- Je Init3 ;jump if found
-
- Init2
- Es:
- Cmp Byte [Di-1], 0 ;see if stopped on end of string
- Je Init1
- Inc Di ;next byte
- Jmps Init2
-
- Init3
- Mov CmdLoc, Di ;save location
- Pop Es
-
- ;--- set resident flag
-
- Mov Si, 80h ;command tail
- Lodsb ;get the length
- Or Al, Al ;check if none
- Jz Init6
- Mov Cl, Al
- Sub Ch, Ch ;put count in CX
-
- ;--- loop through characters in command tail
-
- Init4
- Lodsb ;load next byte
- Cmp Al, '/' ;check if switch
- Je Init7 ;jump if so
- Init5
- Loop Init4 ;otherwise loop back
-
- Init6
- Jmp Start
-
- ;--- found slash
-
- Init7
- Dec Cx ;reduce count
- Jz Init6 ;jump if no more bytes
-
- Lodsb ;load command character
- Sub Al, 'a'-'A' ;convert to upper-case
- Cmp Al, 'R' ;check if R
- Jne Init5 ;if not, go back to loop
- Xor Status, Status1 ;set (or clear) flag
- Jmp Start
-
- ;--- could not find COMSPEC=
-
- Init8
- Mov Dx, Offset Errormes ;error message
- Mov Ah, 9 ;function
- Int 21h ;show message
-
- Mov Ax, 4cffh ;exit function
- Int 21h ;execute
-
- ;--- transient data
-
- Openmes Db 13,10
- Db 'SHOW87, Version '
- Db Ver_Hi\10+'0', '.', Ver_Lo/10+'0', Ver_Lo\10+'0', 13, 10
- Db 'Copyright (c) 1987-1988 Eric Tauck',13,10
- Db 'All rights reserved',13,10,'$'
-
- ;--- command environment string
-
- Comspec Db 'COMSPEC='
-