Download presentation
Presentation is loading. Please wait.
Published bySheila McDowell Modified over 8 years ago
1
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 1 High Level Language vs. Assembly Language Data Types HLL statements are implemented as sequences of assembly language statements compiler converts HLL to assembly language data types evolved into objects a set of values –sets for different types can intersect e.g. signed & unsigned integers a set of operations
2
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 2 Data Types (Continued) built-in data types: implemented by the language simple types: –HLL: integer, unsigned int, float, char, string, boolean, file (?) –Assembly language: byte, word, int, unsigned int –some processors also support: float – e.g. 80486+ Binary Coded Decimal (BCD) 2 digits per byte 4 bits / digit each digit range 0.. 9
3
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 3 Data Types (Continued) composite data types: –allow the design of static structures –HLL: array, record –assembly language: none (?) can reserve a block of memory use of memory is user-defined addressing modes to support access to array & record structures –user defines data structure determines set of possible values –user-defined operations
4
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 4 Data Types (Continued) HLL: other data types –enumerated –user-defined types: user defines data structure »determines set of possible values user-defined operations »how to manipulate structures –type casts
5
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 5 Data Variables, Expressions data variables instances of objects –STATE VARIABLES! HLL: wide variety Assembly: limited (e.g. registers, labels) expressions –evaluate to a “value” –value can be either a reference to a variable a value for some type HLL: complex expressions common Assembly: [BX + DI + 3] (very limited)
6
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 6 Assignment HLL: variable = value left side must evaluate to a reference to a variable of some type right side must evaluate to a legal value for a variable of the same type as lvalue Assembly: MOV left side (lvalue) right side (rvalue)
7
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 7 Control Flow HLL: IF statements, DO/FOR loops, GO TO, … Assembly: JMP, conditional jumps
8
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 8 Software Interrupts target subroutine of CALL is static must know subroutine start address when CALL is assembled dynamic binding to subroutines? different addressing modes for CALL? –register? CALL BX – address in BX memory? –CALL [BP + 6] address received as argument?
9
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 9 Software Interrupts alternate addressing might work in some cases what about case where software component is developed by very different group? –e.g. operating system (O/S) O/S is permanent resident of memory application is temporary resident applications need to use O/S services how can application access O/S ?
10
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 10 Software Interrupts: Interface Library Some possible solutions (application access to O/S) 1. O/S provides interface library (.OBJ file) interface library has knowledge of addresses where O/S resides link interface library to the application library is included as part of application O/S Application interface library
11
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 11 Software Interrupts: Interface Library (Continued) 1. Interface Library Problems: what if O/S changes? recreate application with new library?
12
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 12 Software Interrupts: O/S Gives I/F Address 2. O/S gives interface address when application is loaded loader is part of O/S – knows about current resident O/S after loading application, but before passing control to application – could load BX (say) with address of O/S interface subroutine –application then : CALL BX –OR, application could save address in global variable, and then: CALL [O/S address variable]
13
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 13 Software Interrupts: O/S Gives I/F Address (Continued) 2. O/S gives interface address when application is loaded Problems: might work – but extra programming burden on application developers more complex loading process more possible places to go wrong
14
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 14 Software Interrupts: Common Solution 3. More common solution: like above, but existence of global variables at particular addresses is ASSUMED by developers of both O/S and applications O/S puts pointers to O/S services in variables when O/S is loaded application programs are developed under the assumption that these global variables exist
15
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 15 Software Interrupts: Common Solution (Cont.) shared global variable applicationO/S initialized when O/S loaded
16
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 16 Software Interrupt Instruction Software Interrupt (or TRAP) Instruction uses the stored pointer (global variable) approach to support dynamic subroutine invocation in p86: INT instruction refer to subroutine invoked by INT as Interrupt Service Routine (ISR) INT Instruction based on globally assumed vector table table of pointers to ISRs INT has one operand: INT i operand = index into table to ISR pointer encoded as byte: range 0.. 255
17
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 17 INT Example INT5 executes ISR whose address is stored in element 5 of the vector table –vector table starts at element 0 Do real O/S’s use the vector table approach? YES! BIOS calls:INT 10H DOS calls: –use several table entries –e.g. INT 21H
18
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 18 Multi-Service ISR Can one ISR handle many services? YES! have service code as one parameter ISR return-value? number and type of other parameters? –depends on the service code parameter! Example: O/S ISR pseudo-prototype: void? ISRx ( byte ServiceCode,... ??? );
19
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 19 p86 Vector Table starts at address 0000H entries are 4 bytes each 32-bit address low 16-bits = ISR address high 16-bits = 0000H (more in 94.203!) words stored little endian! (bytes too!) offset to successive elements = 4 bytes if index into vector table = i then offset to relevant entry = 0000H + 4 * i
20
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 20 p86 Vector Table: Example INT5 accesses ISR address stored at: 0000H + 4 * 5 = 0014H 0014H ISR 5 address 0016H 0000H 0018H ISR 6 address 001AH 0000H 0010H ISR 4 address 0012H 0000H 5 th element of table 32-bit entries: stored little endian addresses: 0010H, 0011H 0012H, 0013H
21
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 21 Execution of INT Instruction performs the following steps: 1. push FLAGS 2. push 32-bit return address –pushes high word = 0000H (94.203!) 3. IP := ISR address –gets target ISR address from mem[ 4 * i ]
22
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 22 ISR Stack Frame the ISR stack frame is different from subroutines! parameter access? –extra bytes on stack –FLAGS –extra word of return address old BP 32-bit return address flags arguments BP return address + 8
23
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 23 IRET Instruction / Installing the ISR Returning from an ISR: RET instruction will not work! (why not?) IRET (Interrupt Return) instruction 1. pops 32-bit return address IP := low word throw away high word (203!!) 2. pops FLAGS INT mechanism only works if ISR address has been loaded previously into correct vector! called “installing” the ISR in the vector table
24
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 24 Summary of ISR Programming Issues install ISR in vector table done at program initialization memory reserved for vector table ? invoke ISR using INT extra bytes on stack! parameter access? return from ISR using IRET restores FLAGS !
25
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 25 Example: Subroutine vs. ISR ; very beginning of program: VectorTable: ; locations 0000H-03FFH set aside for VectorTable ORG 0400H... ; near the beginning of main program ; move the address of SUBR into memory address 4*12H (= 0048H) MOV AL, 12H MOV CL, 4 MUL CL ; 8 bit operand, thus AX:= AL*CL MOV BX, AX MOV word ptr[BX], SUBR ; (cannot use AX for indirect ; addressing, and must specify word ptr to avoid ambiguity) assume we are going to implement routine SUBR as ISR 12H Initialization (ISR Only):
26
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 26 Example: Subroutine vs. ISR (Continued) Subroutine: CALLsubr ADDSP, ; m = 2 * # arguments ISR: INT 12H ADDSP, ; m = 2 * # arguments Call set up
27
7-Nov-0194.201 - Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct. 2001 94201.lecture23-24-hll-interrupts 27 Example: Subroutine vs. ISR (Continued) Subroutine: SUBR: <access parameters [ BP + 4 ], [ BP + 6 ], … > RET ISR: SUBR: <access parameters [ BP + 8 ], [ BP + 10 ], … > IRET Implementation of Routine:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.