lunes, 24 de diciembre de 2018

Programming PDF – Unit 4


(4)

Unit 4

Programming Resources

SYSTEMS BASED ON MICROPROCESSORS

Degree in Computer Engineering

EPS – UAM

(4)

Index

Four. Programming resources

BIOS interrupts.
DOS interrupts.
Execution of programs from DOS.

4.1.
4.2.
4.3.
4.4. PSP (Program Segment Prefix).
4.5.

Program types: EXE, COM and Residents (TSR).

(4)

4.1. BIOS interrupts (I)

BIOS (Basic Input / Output System): This is the basic firmware
installed on the motherboard.
Provides basic hardware access routines.
Can be divided into five different groups :

Interrupts associated to the CPU (INT 0 to INT 7)
Interrupts associated with the controller of
interrupts 8259 (INT 8 to INT 0Fh)
BIOS services (INT 10h to INT 1Ah and INT 40h)
User routines (INT 1Bh and INT 1Ch)
Pointers to data tables (INT 1Dh to INT 1Fh and INT
41h)

List of Ralf Brown interrupts:

http : //http://bit.ly/1nZO3bX

(4)

4.1. Interrupts BIOS (II)

Associated with the CPU

INT 0: Division by zero

Generated by the CPU when the quotient of a division
(DIV or IDIV) is too large to be stored
] in AL or AX.
Print to the console '' Divide overflow '' and return to
DOS.

INT 1: Execution step by step

Activated when the trace flag (TF) is 1 and
] CPU has executed any instruction.
The DOS initializes the interrupt vector with a
address that contains the IRET instruction.
Debug programs DEBUG, SYMDEB, TD,
…) change the vector to a service routine that
allows the execution of the programs step by step.

(4)

4.1 . Interrupts BIOS (III)

Associated with the CPU

INT 2: Not Masked

Activates with rising edge on the NMI pin of the
CPU. The pin is connected to the parity detector of the
RAM.
Prints in the '' Parity Check 1 '' console and stops the
CPU.

INT 3: Breakpoint (19659002)

is activated when an instruction is executed with the
CCh code.
Used in debugging programs: allows the
execution of a program until that
instruction is found.
The DOS initializes the interrupt vector with a
address that contains the IRET instruction.

(4)

4.1. Interrupts BIOS (IV)

Associated with the CPU

INT 4: Overflow

Activated by the INTO instruction.
Generates an INT 4 yes flag O = 1.
DOS initializes the interrupt vector with a
address that contains the IRET instruction.

INT 5: Print screen

This interrupt prints the text that is displayed
on the screen.
Can be activated by pressing the Print-key.

INT 6, INT 7 (Not used)

(4)

4.1. BIOS interrupts (V)

Associated with the interrupt controller

Interrupts 8 to 15 (0Fh) are associated with the
hardware interrupt controller (8259A) and are
activated each time a flank occurs in its
entries IRQ0 to IRQ7.
INT 8: Timer

The system timer (8253) activates this
interrupt 18.2 times per second (every 55 ms).
The service routine increases by one the
32 bit counter located in the following BIOS addresses
(and sets it to zero every 24 hours):

0040h: 006Ch (low word)
0040h: 006Eh (high word)

The service routine also activates an INT 1Ch.

(4)

4.1. BIOS interrupts (VI)

Associated with the interrupt controller

INT 9: Keyboard

Activated each time a key is pressed or released.
The service routine saves the key code in the
keypad buffer.

INT 0Ah (Not used)
INT 0Bh: Serial port 1
INT 0Ch: Serial port 2
INT 0Dh: Hard disk (XT) or parallel port 2 (AT)
INT 0Eh: Floppy disk
INT 0Fh: Parallel port 1

(4)

4.1. BIOS interrupts (VII)

BIOS services

INT 10h: Video input / output

Various functions related to video output
according to the value of AH.

INT 11h: Checking the physical equipment

Returns in AX a description of the installed hardware
(memory banks, number of serial ports and
parallel, etc.).

INT 12h: Memory size

Returns in AX the number of 1 KB blocks of the
installed RAM memory.
INT 13h: Disk access

Various functions related to diskette access
or hard disk at sector or track level according to the value of AH

(4)

4.1. BIOS interrupts (VIII)

BIOS services

INT 14h: RS-232 serial port access
INT 15h: Cassette access
INT 16h: Keyboard input / output

Various related functions with the keyboard according to
value of AH.

INT 17h: Input / Output of printer
INT 18h: Execution of BASIC
INT 19h: Start of system

Read sector 1 of the track 0 of the boot disk and
executes the DOS boot program

INT 1Ah: Time of day

Access to the 32-bit timer counter (INT 8).

(4) [19659002] 4.1. BIOS interrupts (IX)

User routines

INT 1Bh: Keyboard break

Activates the INT 9 (keyboard) service routine
when it detects Ctrl-C (Ctrl-Break).
The BIOS initializes the interrupt vector with a
address that contains the IRET instruction.
The DOS changes the interrupt vector to the routine of
INT service 23h (Ctrl service routine) -Break)

INT 1Ch: Timer of the timer

The service routine of the INT 8 (timer) activates
The BIOS initializes the interrupt vector with a
address that contains the instruction IRET.

(4)

4.1. BIOS (X) interrupts

Data table pointers

1Dh to 1Fh and 41h interrupts are actually
parameter table addresses used by the
BIOS video and disk services.
] INT 1Dh: Video parameters
INT 1Eh: Floppy parameters
INT 1Fh: Graphics character table
INT 41h: Hard disk parameters

(4)

4.2. Interrupts DOS (I)

INT 20h: Ends program

Ends program execution returning to the interpreter of
commands. Microsoft recommends using INT instead
21h with AH = 4Ch (ends program, closing files and
freeing memory).

INT 21h: DOS Dispatcher

Executes the different DOS services according to AH.

INT 22h: Completion address

Address of the routine that is executed when the
program ends. It should not be called directly.
INT 23h: CTRL-Break service routine

Call by DOS when it detects CTRL-C (CTRL-
Break). It should not be called directly.

(4)

4.2. Interrupts DOS (II)

INT 24h: Handler of critical errors

Invoked by DOS when a critical error occurs in
access to a hardware device (disk, printer, …)

INT 27h: Ends program leaving resident

Finish execution of a program .COM (driver)
leaving it resident in memory.
To leave resident a program .EXE its used in its
place INT 21h with AH = 31h. [19659002] (4)

4.3. Execution of programs from DOS

Programs in machine code are stored
in executable files of disk.
When a program is executed, the interpreter of
commands loads the contents of its executable file
] in a free zone that reserves in RAM.
As part of the load, an area of ​​256
bytes is added that contains data related to the program
(Program Segment Prefix, PSP)
] Executable files may be in .EXE
or .COM format, with their execution having a slightly different behavior
.
When a program finishes, control is returned to the
DOS command interpreter. The memory that
occupied is released unless it is left resident.

(4)

4.4. PSP (Program Segment Prefix)

(I)

256-byte data zone that tops the
.EXE or .COM programs once they are loaded into
RAM memory for execution.
Generated by DOS through the interpreter of
commands (COMMAND.COM).
PSP most prominent fields:

Offsets 0 and 1 (2 bytes)
INT instruction 20h.
It allows to finish the program skipping to offset 0 (not
recommended).

Offsets 0Ah to 0Dh (4 bytes)

Original vector of the service routine of INT 22h
(address of program termination)
When the program ends, it is copied to the table of interrupt vectors
and skipped to that address.

(4)

4.4. PSP (Program Segment Prefix)

(II)

Offsets 0Eh to 11h (4 bytes)

Original vector of INT service routine 23h (Ctrl-
Break)
The program can change the routine of that interruption
to capture Ctrl-C / Ctrl-Break.
When the program finishes, the original routine
is restored, copying its address from this field to the table of
interrupt vectors

Offsets 12h to 15h (4 bytes)

Original vector of INT 24h service routine
(Critical error handler)
The program can change the interrupt routine
to capture critical errors.
When the program finishes, the original routine
is restored, copying its address from this field to the table of
interrupt vectors.

(4)

4.4 . PSP (Program Segment Prefix)

(III)

2Ch and 2Dh Offsets (2 bytes)

Physical segment number containing a copy of
DOS environment variables.
Allows the program to access these variables.

Offset 80h (1 byte)

Size in bytes of the parameters of the online program
of commands.

Offsets 81h to FFh (127 bytes)

ASCII codes of the parameters of the online program
of commands. It ends with code 13 (carriage return).
Allows the program to access the indicated parameters
by command line.

(4)

4.4. PSP (Program Segment Prefix)

(IV)

Example

Given the following environment variables (command
DOS SET):

COMSPEC = C: DOS60 COMMAND.COM
PROMPT = $ P $ G
TEMP = C: TEMP
PATH = C: TD; C: TASM

If the PROGRAM program is executed with the
parameters / D and C: DISCO:

C: > PROGRAM / DC: DISCO

The PSP would have the following form:

(4)

4.4. PSP (Program Segment Prefix)

(V)

Example

Address of the handler of
critical error: 103Dh: 0956

PSP 193F: 0000 CD 20 FF 9F 00 9A F0 FE – 1D F0 8E 09 3D 10 2B 0A

193F: 0010 3D 10 56 09 3D 10 2D 10 – 01 01 01 00 02 FF FF FF
193F: 0020 FF FF FF FF FF FF FF FF – FF FF FF FF 38 19 7C 8F
193F: 0030 3D 10 14 00 18 00 3F 19 – FF FF FF 00 00 00 00
193F: 0040 06 00 00 00 00 00 00 00 – 00 00 00 00 00 00 00 00
193F: 0050 CD 21 CB00 00 00 00 00 – 00 00 00 00 00 20 20 20
19

.



Source link



from Nettech Post http://bit.ly/2SdENTi

No hay comentarios:

Publicar un comentario

Slutty Japanese Babe Toyed And Creamed

Japanese hot babe with big tits gets toyed and creamed. Author: sexualbabe Added: 02/11/2021