אסמבלר- הרצאה 8 - בקר פסיקות

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

1

Yehezkel C.

Software Layers

Pentium pinout

Yehezkel C.

Yehezkel C.

)Busses (part of the pinout

Yehezkel C.



:
- Non Maskable interrupt - NMI .1
.
.

Programmable
Interrupt Controller

- INTR .2 . disable
(enable) -
IRET ) IRETD 386(.

:
- INTA .3 vector type number
.data bus -

12

12

13

Yehezkel C.

13

Timing Diagram

8259 - PIC






- Programmable Interrupt Controller - PIC


.
: / ) (I/O
.
.Interrupt -
:
.
Pulling
.
.

Vector Intr
14

14

Yehezkel C.

15

Yehezkel C.

15

IRR ,ISR ,IMR

Inside - PIC

ISR

IRR
IR0
IR1
IMR0

Priority
Decoder

IR2
IR3
IR4

IMR
.
.

IR5
IR6
IR7

IMR7

16

16

Yehezkel C.

17

- INTR

Interrupt

Request

INT

. Data
Bus

8
Pointer

. 4 . 12 . 3

Acknowledge

.6 .5

Interrupt
.type

. Interrupt
number
- INTA.

.
.

 EOI
CLEAR

Yehezkel C.

17

;IRR=0
IRR=1
ISR=1

2
2

15

...
..
. .

NMI
INTA

11110101
11110101

11110101
11110101
DATA BUS
18

Yehezkel C.

18

" . .

19

Yehezkel C.

19


IRQ 0 System timer
Keyboard
Reserved
)Serial Comm.(com2
)Serial Comm.(com1
)Parallel port(LPT2

IRQ 0 System timer

IRQ 1
IRQ 2
IRQ 3
IRQ 4
IRQ 5

PIC1

Keyboard
Reserved
)Serial Comm.(com2
)Serial Comm.(com1
)Parallel port(LPT2

Processor

IRQ 6 Floppy Disk Controller


)IRQ 7 Parallel printer(LPT1

Real Time Clock

IRQ 12 Reserved

Real Time Clock

PIC2

IRQ 12 Reserved
ISR

PIC2
ISR

IRQ 13 Math coprocessor


IRQ 14 Hard disk controller

IRQ 15 Reserved

IRQ 15 Reserved

PIC

Yehezkel C.

20

-Cascade 3

PIC
-
IRQ

2PIC

8-15

PIC
PIC

--

21

.1
.2

.6
.7
.8

Yehezkel C.

22

Yehezkel C.

21

.3
.4
.5

22

IRQ 8

IRQ 9 Redirect IRQ2


IRQ 10 Reserved
IRQ 11 Reserved

IRQ 13 Math coprocessor


IRQ 14 Hard disk controller

20

PIC1

Processor

IRQ 6 Floppy Disk Controller


)IRQ 7 Parallel printer(LPT1

IRQ 8

IRQ 9 Redirect IRQ2


IRQ 10 Reserved
IRQ 11 Reserved

IRQ 1
IRQ 2
IRQ 3
IRQ 4
IRQ 5

23

IRQ3

.IRR
INT.
.INTA
CPU ) (3
ISR 1 ) IRR (3 .0
INTA
DATA BUS IRQ
Non
specific EOI <=) .ISR -
.(ISR
IRET ISR ,CS ,IP
.
Yehezkel C.

23

Initialization Sequence


8259 :
.1 . Initialization command words - ICW
.2 . Operation command word - OCW
 : ICW 4 :
ICW1 , ICW2, ICW4
. ICW3
 : OCW 3 :

.ICW

24

Yehezkel C.

24

25

Yehezkel C.

25


Fully Nested mode
 ,Default IRQ :
IRQ0 IRQ7
-.
 IF Non-Specific End of Interrupt EOI -
Automatic End of Interrupt

Specially Fully Nested mode


.cascade -
Fully Nested Mode .

26

Yehezkel C.

26

 Non-Specific Rotating

. EOI
ISR-
.
.

. Inta EOI ISR
.
NonSpecific Rotating ISR -
.
 Specific Rotating
EOI ISR

.
27

Yehezkel C.

27

IRR
-
IR4IR6-

IRR
-
IR4IR6-

Priority

Priority

ISR

ISR

Priority

Priority

ISR

ISR

IRR

0
28

Yehezkel C.

28

NS_EOI

IRR

29

Yehezkel C.

29

IR4 IRR

IR4 IRR

IR6

IR6

5L

6H

Priority

ISR

NonSpecfic ISR

NonSpecfic ISR

EOI

EOI

4L

5H

Priority

6 31

0
1C.
Yehezkel

Priority
ISR

Priority
Specfic ISR

30

Yehezkel C.

EOI
30

Specfic ISR
EOI
Priority

31

ISR-
Special Mask 

PIC_Cntrl_Add equ 20h


ISR3: Proc far


.
interrupt - Pulling 
.STATUS -

EOI equ 00100000b.

Sti
.

Mov al, EOI

W2 W1 W0

Out PIC_Cntrl_Add, al
iret
ISR3 endp
33

Yehezkel C.

33

32

Yehezkel C.

32

Initialization Command Word 1 (ICW1)


Initialization Command Word 1 (ICW1)

A0=0
Bit(s) Function
7:5
Interrupt Vector Addresses for MCS-80/85 Mode.
MSB
4 Must be set to 1 for ICW1
1
Level Triggered Interrupts
3
0
Edge Triggered Interrupts
1
Call Address Interval of 4
2
0
Call Address Interval of 8
1
Single PIC
1
0
Cascaded PICs
1
Will be Sending ICW4
0 LSB
0
Don't need ICW4
35

Yehezkel C.

35

Initialization Command Word 2 (ICW2)

34

Yehezkel C.

34

Initialization Command Word 2 (ICW2)

A0=1

Bit
7
6
5
4
3
2
1
0

8086/8080Mode
I7
I6
I5
I4
I3
37

Yehezkel C.

MCS80/85Mode
A15
A14
A13
A12
A11
A10
A9
A8

37

36

Yehezkel C.

36

320h
C8h
IR0

323h

2Ch :

Mov al, 000010011b


Out 2Ch,al
Mov al, C8h
Out 2Dh, al

IR1
IR2

39

Yehezkel C.

39

Initialization Command Word 3 (ICW3)

Initialization Command Word 3 for Master PIC (ICW3)

Yehezkel C.

38

Initialization Command Word 3 (ICW3)



Cascade

Cascade -
Bit
7
6
5
4
3
2
1
0

38

A0=1

Function
IR7
IR6
IR5
IR4
IR3
IR2
IR1
IR0

is
is
is
is
is
is
is
is

connected
connected
connected
connected
connected
connected
connected
connected

to
to
to
to
to
to
to
to

a
a
a
a
a
a
a
a

Slave
Slave
Slave
Slave
Slave
Slave
Slave
Slave

Initialization Command Word 3 for Slaves (ICW3)


Bit(s)
7
6
5
4
3
2:0

Function
Reserved. Set
Reserved. Set
Reserved. Set
Reserved. Set
Reserved. Set
Slave ID

to 0
to 0
to 0
to 0
to 0
000
001
010
011
100
101
110
111

41

Slave
Slave
Slave
Slave
Slave
Slave
Slave
Slave

0
1
2
3
4
5
6
7

Yehezkel C.

41

40

A0=1

Master
.
Slave

Mov al, 00000100b


Out 2Dh, al ; master ICW3
Mov al, 00000011b
Out 35h, al; slave ICW3

Function
Reserved. Set to 0
Reserved. Set to 0
Reserved. Set to 0
1
Special Fully Nested Mode
0
Not Special Fully Nested Mode
0x
Non - Buffered Mode
10
Buffered Mode - Slave
11
Buffered Mode - Master
1
Auto EOI
0
Normal EOI
1
8086/8080 Mode
0
MCS-80/85

4
3:2

1
0

43

Yehezkel C.

40

ICW3

Initialization Command Word 4 (ICW4)


Bit(s)
7
6
5

Yehezkel C.

43

42

Yehezkel C.

42

Operation Control Word 1 (OCW1)


Bit
7
6
5
4
3
2
1
0

45

PIC 2
Mask IRQ15
Mask IRQ14
Mask IRQ13
Mask IRQ12
Mask IRQ11
Mask IRQ10
Mask IRQ9
Mask IRQ8

Intr_vect_table
Org 65*4
Vect_int
Intr_vect_table

PIC 1
Mask IRQ7
Mask IRQ6
Mask IRQ5
Mask IRQ4
Mask IRQ3
Mask IRQ2
Mask IRQ1
Mask IRQ0

Yehezkel C.

45


- Hardware Interrupts
old CS:EIP points past last completed instruction.
- Traps (INT 30, ... )
old CS:EIP points past instruction causing exception
- Faults (page fault, GPF, ... )
old CS:EIP points to instruction causing exception
- Aborts (hardware errors, bad system table vals...)
uncertain CS:EIP, serious problems, CPU confused

50

Edge_trig, single, +ICW4


PIC vector 40h
NSFNM, non-buf, normal EOI,8086
IR1 not masked
OCW2: nonspecific EOI

Yehezkel C.

44

Operation Control Word 2 (OCW2)


Bit(s)
7:5

Bit(s) Function
7
Must be set to 0
6:5
00
Reserved
01
Reserved
10
Reset Special Mask
11
Set Special Mask
4
Must be set to 0
3
Must be set to 1
1
Poll Command
2
0
No Poll Command
1:0
00
Reserved
01
Reserved
10
Next Read Returns Interrupt Request Register
11
Next Read Returns In-Service Register

Yehezkel C.

label dword
ends

ICW1 equ 00010011b


ICW2 equ 01000000b
ICW4 equ 00000001b
MASK equ 11111101b
EOF equ 0010 0000b
PIC1 equ 2Ch
PIC2 44equ 2Dh

Operation Control Word 3 (OCW3)

47

segment at 0

4
3
2:0

47

46

Function
000
Rotate in Auto EOI Mode (Clear)
001
Non Specific EOI
010
Reserved
011
Specific EOI
100
Rotate in Auto EOI Mode (Set)
101
Rotate on Non-Specific EOI
110
Set Priority Command (Use Bits 2:0)
111
Rotate on Specific EOI (Use Bits 2:0)
Must be set to 0
Must be set to 0
000
Act on IRQ 0 or 8
001
Act on IRQ 1 or 9
010
Act on IRQ 2 or 10
011
Act on IRQ 3 or 11
100
Act on IRQ 4 or 12
101
Act on IRQ 5 or 13
110
Act on IRQ 6 or 14
111
Act on IRQ 7 or 15
Yehezkel C.

;main program
PC_PIC = 20h
NSEOI_OCW2=?????????
;Change Interrupt Vectors

mov dx, 400


int 27h
;TSR keep the next 400 bytes in memory
:======================================
New_KeyB:
; read the scan code from keyboard
..
prtkey: int 0a0h

NS_EOI: mov al, NSEOI_OCW2


out PC_PIC, al
; non specific end of
interrupt
iret
;=======================================
mov ah,4ch
Yehezkel C.
int4921h

46

49

Faults and Traps

Exceptions
 Three types of exceptions
 Depending on the way they are reported
 Whether or not the interrupted instruction is restarted
 Faults
 Traps
 Aborts
 Faults and traps are reported at instruction boundaries
 Aborts report severe errors
 Hardware errors
 Inconsistent values in system tables

 Faults
 Instruction boundary before the instruction during which the

exception was detected


 Restarts the instruction
 Divide error (detected during div/idiv instruction)
 Segment-not-found fault

 Traps
 Instruction boundary immediately after the instruction during

which the exception was detected


 No instruction restart
 Overflow exception (interrupt 4) is a trap

From S. Danidamudi, Introduction to Assembly Language Programming, Second Edition, Springer, 2005.

 User defined interrupts are also examples of traps


From S. Danidamudi, Introduction to Assembly Language Programming, Second Edition, Springer, 2005.

53

52

Interrupt Vector Content (DOS)


#

Interrupt Name

Address

Owner

Interrupt Name

00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
20
21
22
23
24
25
26
27

Divide by Zero
Single Step
Nonmaskable
Breakpoint
Overflow
Print Screen
Invalid Opcode
Reserved
IRQ0 - System Timer
IRQ1 - Keyboard
IRQ2 - Reserved
IRQ3 - COM2
IRQ4 - COM1
IRQ5 - Reserved
IRQ6 - Diskette
IRQ7 - Printer
Video
Equipment Determination
Memory Size Determination
Fixed Disk/Diskette
Asynchronous Communication
System Services
Keyboard
Printer
Resident BASIC
Bootstrap Loader
Real-Time Clock Services
Keyboard Break
User Timer Tick
Video Parameters
Diskette Parameters
Video Graphics Characters
Program Terminate
General DOS Functions
Terminate Address
Ctrl+Break Handler Address
Critical Error Handler
Absolute Disk Read
Absolute Disk Write
Terminate and Stay Resident

1756:00D2
0070:06F4
1993:26D2
0070:06F4
0070:06F4
F000:FF54
F000:EB43
F000:EAEB
15BE:0000
15BE:001D
0A08:0057
0A08:006F
D60B:0095
0A08:009F
0A08:00B7
0070:06F4
15BE:0100
F000:F84D
F000:F841
15BE:0174
F000:E739
0C4C:19A0
F000:E82E
F000:EFD2
F000:E000
0C4C:1990
F000:FE6E
0070:06EE
1465:00D6
F000:F0A4
0000:0522
C000:5A52
0255:003A
15BE:01A1
18B9:02B1
1993:26BA
18B9:0155
0C4C:19DE
0C4C:1A27
0255:004C

NC
Unknown
DOS
Unknown
Unknown
BIOS
BIOS
BIOS
FAXTSR
FAXTSR
DOS
DOS
BIOS
DOS
DOS
Unknown
FAXTSR
BIOS
BIOS
FAXTSR
BIOS
SMARTDRV
BIOS
BIOS
BIOS
SMARTDRV
BIOS
Unknown
CASMGR
BIOS
Device Driver
BIOS
DOS System Area
FAXTSR
COMMAND
DOS
COMMAND
SMARTDRV
SMARTDRV
DOS System Area

28
29
2A
2B
2C
2D
2E
2F
....
40
41
42
43
44
45
46
....
70
71
72
73
74
75
76
77
....
F8
F9
FA
FB
FC
FD
FE
FF

DOS Idle
15BE:0222
DOS Internal - FAST PUTCHAR 0255:0052
Microsoft Networks
15BE:073E
Reserved for DOS
0116:10DA
Reserved for DOS
0116:10DA
Reserved for DOS
0116:10DA
DOS - Execute Command
0ACD:013F
Multiplex (Process Interface) 15BE:079E

FAXTSR
DOS System Area
FAXTSR
DOS System Area
DOS System Area
DOS System Area
COMMAND
FAXTSR

Diskette BIOS Revector


Fixed Disk Parameters
Relocated Video Handler
EGA/VGA User Font Table
Novell Netware API
Reserved
Fixed Disk Parameters

F000:EC59
F000:E13D
F000:F065
C000:5652
F000:EA97
F000:EA97
F000:E401

BIOS
BIOS
BIOS
BIOS
BIOS
BIOS
BIOS

IRQ8 - Real-Time Clock


IRQ9 - Reserved
IRQ10 - Reserved
IRQ11 - Reserved
IRQ12 - Reserved
IRQ13 - Redirect to NMI
IRQ14 - Fixed Disk
IRQ15 - Reserved

0A08:0052
F000:EED2
0A08:00CF
0A08:00E7
0A08:00FF
F000:EEDB
0A08:0117
F000:8E8D

DOS
BIOS
DOS
DOS
DOS
BIOS
DOS
BIOS

Reserved for User Programs


Reserved for User Programs
Reserved for User Programs
Reserved for User Programs
Reserved for User Programs
Reserved for User Programs
Reserved for User Programs
Reserved for User Programs

0040:0000
7A0E:7E00
0080:7C00
972F:0001
8304:F81C
EF40:7C00
F729:F80B
0002:F000

Device Driver
Unknown
SSCDROM
Unknown
Unknown
BIOS
SSCDROM
SMARTDRV

CPU Interrupts
External Interrupts

57

Address

Owner

You might also like