Title: What is System Programming?
1Lecture 20
2Determining the Processor Type
- Flags register test to identify 8086
12
15
Unused in 8086
Pushing or Pop the flags register will set these
4-bits in 8086.
3Determining the Processor Type
- mov AX, 0
- push AX
- popf
- pushf
- pop AX
- Test the bits 15 12 of AX if all set, the
- processor is 8086 else higher processor.
4Determining the Processor Type
- Flags test for 80286
- mov AX, 7000H
- push AX
- popf
- pushf
- pop AX
- If the bits 14 12 are cleared the
- processor is 286 only.
5Alignment Test ( If Not 286)
18
Eflags
Alignment Check
Alignment Check mov dword ptr 12, EDX
6Alignment Test
- pushfd
- pop eax
- mov ecx, eax
- mov dword ptr 13, EDX
- pushfd
- pop eax
7CPUID Test
- 486 will pass the alignment test.
- To distinguish 486 with Pentium CPUID Test is
used.
8CPUID Test
21
Eflags
- If a program can set and also clear bit 21 of
Eflags, then processor supports CPUID
instructions. - Set bit 21 of Eflags and read value of Eflags and
store it. - Clear bit 21 of Eflags, read the value of Eflags.
- Compare both the value if bit 21 has changed the
CPUID instruction is available.
9CPUID Instruction
- Before After the execution of Instruction
- EAX 0 EAX 1
- EBX EDX ECX
- EBX Genu
- EDX ineI
- ECX ntel
- EAX 1 EAX (bit 3 0) Stepping ID
- EAX (bit 7 4) Model
- EAX (bit 11 8) Family
- EAX (bit 13 12) Type
- EAX (bit 14 31) Reserved
10Coprocessor Control Word
7
1 1
Interrupt enable flag
11 after initialization signifies extended
precision operation
11Coprocessor Status Word
10
14
8
9
C0
C3
C1
C3
C3 C2 C0 0 0
0 st gt operand 0 0
1 st lt operand 1 0
0 st operand
12To Check Coprocessor is Present
- Initialize
- Read Hi Byte of Control register.
- If value in Hi Byte is 3, then coprocessor is
available, otherwise its absent.
13Check for 8087 Coprocessor
- IEM can be set in 8087.
- IEM cannot be set in 80287, 80837 as they use
exception to inform the software about any
invalid instruction. - If an attempt to set this bit fail then it
implies, its not a 8087 coprocessor FDISI.
14Distinguish between 80287 80387
- 80387 only allows to reverse the sign of
infinity. - Perform a division by zero.
- If the sign of result can be reversed then the
coprocessor is 80387.
15 void PrintConfig( void )
union REGS Register BYTE
AT
clrscr() AT (peekb(0xF000, 0xFFFE) 0xFC)
printf("CONFIGC
- (c) 1987, 92 by Michael Tischer\n")
printf("Your PC Configuration \n")
printf("------------------
----------------------------\n") printf("PC
type ")
switch( peekb(0xF000, 0xFFFE) )
case 0xFF printf("PC\n")
break
case 0xFE
printf("XT\n")
break
default printf("AT or higher\n")
break
16printf("Conventional RAM ")
int86(0x12, Register,
Register) printf("d K\n",Register.x.ax)
if ( AT )
Register.h.ah 0x88 int86(0x15,
Register, Register)
printf("Additional RAM d K over 1
megabyte\n", Register.x.ax)
int86(0x11, Register, Register)
printf("Default video mode ")
printf("Disk drives d\n",
(Register.x.ax gtgt 6 3) 1) printf("Serial
interfaces d\n", Register.x.ax gtgt 9
0x03) printf("Parallel interfaces
d\n\n", Register.x.ax gtgt 14)
void main()
PrintConfig()