Professional Documents
Culture Documents
:
.
-.
KB64.
LIFO - LAST IN FIRST OUT
.
C. Yehezkel
SP . 2
SP
[SP-1]<= CL
[SP-2]<= CH
SP <= SP-2
SP -
, SP
. 2-
SP <= SP+2
:
:
>, PUSH AX < PUSH
:
> , POP AX < POP
C. Yehezkel
C. Yehezkel
PUSH CX
POP CX
C. Yehezkel
1000h
0FFFh
PUSH
POP
0FFEh
SP1
0FFDh
mov sp,1000H
0FFCh
PUSH CX
PUSH BX
POP BX
POP CX
0FFBh
C. Yehezkel
CH | CL
CX
BH | BL
BX
0FFAh
0FF9h
5
C. Yehezkel
PUSH BX
PUSH CX
SP1
CX
CH | CL
BX
BH | BL
SP2
SP3
SP1
1000h
0FFFh
CL
0FFEh
CH
0FFDh
BL
0FFCh
BH
CX
CH | CL
BX
BH | BL
SP2
0FFFh
CL
0FFEh
CH
0FFDh
0FFCh
0FFBh
0FFBh
0FFAh
0FFAh
0FF9h
8
1000h
0FF9h
C. Yehezkel
C. Yehezkel
POP CX
POP BX
SP1
CX
CH | CL
BX
BH | BL
SP2
SP1
1000h
0FFFh
CL
CL
0FFEh
CH
CH
0FFDh
BL
0FFCh
BH
CX
CH | CL
BX
BH | BL
SP2
SP3
0FFFh
CL
CL
0FFEh
CH
CH
0FFDh
BL
0FFCh
BH
0FFBh
0FFBh
0FFAh
0FFAh
0FF9h
10
1000h
0FF9h
C. Yehezkel
10
C. Yehezkel
SP1
CX
CH | CL
BX
BH | BL
SP1
1000h
0FFFh
CL
0FFEh
CH
0FFDh
BL
0FFCh
CX
CH | CL
BX
BH | BL
BH
C. Yehezkel
0FFFh
CL
0FFEh
CH
0FFDh
BL
0FFCh
BH
0FFBh
0FFBh
0FFAh
0FFAh
0FF9h
12
1000h
0FF9h
12
11
C. Yehezkel
11
PUSH EAX
:
PUSHF
POPF
16 .
POPF
POP EAX
]POP dword Ptr [EBX
POP DS
EFLAGS
13
32
EFLAGS
C. Yehezkel
POPA
POPAD
POPF
POPFD
15
Subroutine
CALL Target
RET
16
C. Yehezkel
16
:
. -
.
. -
- .
C. Yehezkel
14
C. Yehezkel
14
16 bits
32 bits
POP reg 16 POP reg 32
POP mem POP mem 32
16
POP Seg
16
17
PushA
PushAD
PushF
PushFD
32
15
`PUSH `A
Push
16
C. Yehezkel
13
PUSHF
16
.
Push reg 32
Push reg 16
:
.1
.2
17
18
C. Yehezkel
18
instruction 1
instruction 2
Call
CALL
:
) IP (
,
.
IP
RET
CALL-
instruction 3
instruction 4
instruction 5
subroutine
RET
subroutine
19
C. Yehezkel
19
20
20
C. Yehezkel
Call
AX
65536
AX
Decision
subroutine
21
RET
subroutine
21
C. Yehezkel
22
PROC NEAR
PUSH AX
MOV AX,0
REPEAT: DEC AX
JNZ REPEAT
POP AX
RET
DELAY ENDP
DELAY
22
C. Yehezkel
:
AX
65536
AX
23
Push ax
Call delay
DELAY : PUSH AX
MOV AX,0
REPEAT: DEC AX
JNZ REPEAT
POP AX
RET
C. Yehezkel
DELAY: PUSH AX
MOV AX,0
REPEAT: DEC AX
JNZ REPEAT
POP AX
RET
23
24
C. Yehezkel
24
pseudoinstructions
.model small
KB 64 :
.stack 100h
.data
.code
**************;
mov ax,@data
mov ds,ax
+++
mov ah,4ch
int 21h
**************;
end
26
C. Yehezkel
26
. push pop-
.
\ .
Call
ret- .
27
C. Yehezkel
27
instruction
-
Interrupt Service Routine. ISR
.
:
INT
INT
IRE
T
29
C. Yehezkel
29
.1
.INT
.2
TF & IF
& IF
TF
data bus
INTA
CPU
I/O
INT
01
30
instruction
instruction
28
C. Yehezkel
28
ISR
instruction
C. Yehezkel
IF
.3 IP:CS
.
.INTA
.4
.
30
CS:IP
31
C. Yehezkel
31
ISR - IRET
, -
:
CS
IP
CS IP
.
.
.
CS
IP
\
Sti=set IF cli =clear IF
32
C. Yehezkel
32
IPL
IPH
0FFEh
CSL
0FFDh
CSH
0FFCh
FLAGS
0FFBh
FLAGS
0FFAh
IRET
SP_OLD
1000h
0FFFh
1000h
IPH | IPL
IP
CSH | CSL
CS
FLAGS
FLAGS
SP_NEW
0FF9h
IPL
0FFFh
IPL
0FFEh
CSL
0FFDh
CSH
0FFCh
FLAGS
0FFBh
FLAGS
0FFAh
SP_NEW
IPH | IPL
IP
CSH | CSL
CS
FLAGS
FLAGS
SP_OLD
0FF9h
34
C. Yehezkel
34
C. Yehezkel
33
INT
33
35
35
C. Yehezkel
- INTR
Interrupt
Request
INT
.Data
Bus
8
Pointer
.4 ..12 .3
.6 .5
Interrupt
.type
Acknowledge
.
.Interrupt
number
- INTA.
.
.
;IRR=0
IRR=1
ISR=1
Programmable
Interrupt Controller
)(part of chipset
NMI Requesting
Device
NMI
INTA
NMI
Intel
8086 CPU
INTR
Interrupt Logic
8259A
11110101
PIC
Single
Step
Divide
Error
Traps
36
C. Yehezkel
into
11110101
11110101
int
Software
11110101
DATA BUS
36
37
Yehezkel C.
" . .
37
39
Interrupts Terminology -
39
C. Yehezkel
into - INTO
Into Software
Interrupt
Interrupt Overflow
-OVERFLOW -
. OF=1
Divide
by 0 Interrupt
INTO Interrupt
Traps or
Error
. OVERFLOW CPU-
41
C. Yehezkel
41
40
0000:0001
0000:0002
0000:0003
0000:0004
0000:0005
Offset
Interrupt 0
IP MSB
CS LSB
Offset
0000:0006
0000:0007
Segment
YES
YES
INTR
Execute
ISR
IF=0
TF=0
pop
IP and CS
IF
Offset = Type 4
TF
Offset
Example:
int 36h
push
CS and IP
popf
Fetch
Next
Instruction
Segment
C. Yehezkel
acknowledge
interrupt
call
ISR
Read Type
Code #
NMI
Resume
Interrupted
Service
Procedure
???
Interrupt 255
0000:03fe
NO
0000:03fc
43
Set
TEMP=TF
NO
0000:03ff
TEMP
NO
NMI
0000:03fd
YES
Internal
Interrupt
CS MSB
Interrupt 1
40
push
Flags
Complete
Current
Instruction
IP LSB
Segment
C. Yehezkel
IVT Format -
0000:0000
38
YES
NO
43
42
C. Yehezkel
42
Function
Divide Error
Single Step (DEBUG)
Nonmaskable Interrupt Pin
Breakpoint
Arithmetic Overflow
Print Screen Key
Invalid Opcode
Coprocessor Not Present
Time Signal
Keyboard Service
Originally Bus Ops (IBM PC)
Video Service Request
Equipment Check
Memory Size
Disk Service Request
Serial Port Service Request
Miscellaneous
Keyboard Service Request
45
Comment
Processor - zero or overflow
Processor - TF=1
Processor - NMI Signal
Processor - Similar to Sing Step
Processor - into
BIOS - Key Depressed
Processor - Invalid Opcode
Processor - no FPU
BIOS - From RT Chip (AT - IRQ0)
BIOS - Gen Service (AT - IRQ1)
BIOS - (AT - IRQ2-7)
BIOS - Accesses Video Driver
BIOS - Diagnostic
BIOS - DOS Memory
BIOS - Accesses Disk Driver
BIOS - Accesses Serial Port Drvr
BIOS - Cassette, etc.
BIOS - Accesses KB Driver
C. Yehezkel
45
-
Pentium
44
Type
17
18
19
1A
1B
1C
1D
1E
1F
20
21
22
23
24
25
26
27
28
2F
70-77
CSegment (High)
CSegment (Low)
IP (High)
IP(low)
C. Yehezkel
47
Function
Parallel Port LPT Service
ROM BASIC
Reboot
Clock Service
Control-Break Handler
User Timer Service
Pointer to Video Parm Table
Pointer to Disk Parm Table
Pointer to Graphics Fonts
Program Terminate
Function Call
Terminate Address
Control-C Handler
Fatal Error Handler
Absolute Disk Read
Absolute Disk Write
Terminate
Idle Signal
Print Spool
Hardware Interrupts in AT Bios
46
Comment
BIOS - Printer Driver
BIOS - BASIC Interpreter in ROM
BIOS - Bootstrap
BIOS - Time of Day from BIOS
BIOS - Keyboard Break
BIOS - Timer Tick
BIOS - Video Initialization
BIOS - Disk Subsystem Init.
BIOS - CGA Graphics Fonts
DOS - Clear Memory, etc.
DOS - Transfer Control
DOS - program Terminate handler
DOS - For OS Use
DOS - Critical Error
DOS - Disk Read
DOS - Disk Write
DOS - TSR Usage
DOS - Idle
DOS - Cassette, etc.
DOS - (AT - IRQs 8-15)
C. Yehezkel
46
halt Instruction
call int
ret
44
INT n: Vector: n 4
47
C. Yehezkel
iret
subroutine
CPU Asset
Content
FLAGS Register
0000h
IP
0000h
CS
ffffh
DS
0000h
SS
0000h
ES
0000h
Instruction Queue
Empty
C. Yehezkel
49
48
C. Yehezkel
48
Real -Mode -
POP PUSH
. -
.
CALL -
.RET
CALL
.
,
.ISR
, INT
.CALL
51
C. Yehezkel
. 1024
5
.Pentium 8086-
224
32 INTEL
.
51
50
C. Yehezkel
50
Computer Interrupt :
\
CPU
IN
IN AX, Port_Address (0-255)
I/O
IN AX, DX (>255)
Port DX
CPU
OUT
OUT Port_Address (0-255), AX
I/O
OUT DX (>255), AX
Port DX
53
C. Yehezkel
53
52
55
C. Yehezkel
C. Yehezkel
52
55
54
C. Yehezkel
54
Protected Mode -
:
IDT Interrupt Descriptor Table
256 * 8 Bytes
.
IDTR .
)IP (High
P |DPL|01110 00
Segment Selector
)IP (Low
56
16
57
C. Yehezkel
57
IRET -IRETD
IRET Real- Mode - RET
.
IRETD
Protected Mode -
RET +EIP EFLAGS
.
58
C. Yehezkel
58
59
C. Yehezkel
59