Скачать презентацию Chapter 13 16 -Bit MS-DOS Programming Real-Address Скачать презентацию Chapter 13 16 -Bit MS-DOS Programming Real-Address

9024d7075713c4583d765f5d9deffe8b.ppt

  • Количество слайдов: 18

Chapter 13: 16 -Bit MS-DOS Programming Chapter 13: 16 -Bit MS-DOS Programming

Real-Address Mode • Real-address mode (16 -bit mode) programs have the following characteristics: • Real-Address Mode • Real-address mode (16 -bit mode) programs have the following characteristics: • • Max 1 megabyte addressable RAM Single tasking No memory boundary protection Offsets are 16 bits • IBM PC-DOS: first Real-address OS for IBM-PC • Derived by Microsoft from Gary Kildall's Digital Research CP/M • Later renamed to MS-DOS, owned by Microsoft 2

MS-DOS Memory Organization • • • Interrupt Vector Table BIOS & DOS data Software MS-DOS Memory Organization • • • Interrupt Vector Table BIOS & DOS data Software BIOS MS-DOS kernel Resident command processor Transient programs Video graphics & text Reserved (device controllers) ROM BIOS 3

MS-DOS Memory Map 4 MS-DOS Memory Map 4

Redirecting Input-Output (1 of 2) • Input-output devices and files are interchangeable • Three Redirecting Input-Output (1 of 2) • Input-output devices and files are interchangeable • Three primary types of I/O: • Standard input (console, keyboard) • Standard output (console, display) • Standard error (console, display) • Symbols borrowed from Unix: • < symbol: get input from • > symbol: send output to • | symbol: pipe output from one process to another • Predefined device names: • PRN, CON, LPT 1, LPT 2, NUL, COM 1, COM 2 5

Redirecting Input-Output (2 of 2) • Standard input, standard output can both be redirected Redirecting Input-Output (2 of 2) • Standard input, standard output can both be redirected • Standard error cannot be redirected • Suppose we have created a program named myprog. exe that reads from standard input and writes to standard output. Following are MS-DOS commands that demonstrate various types of redirection: myprog < infile. txt myprog > outfile. txt myprog < infile. txt > outfile. txt 6

Interrupt Basics • An Interrupt is an event that requires the CPU to suspend Interrupt Basics • An Interrupt is an event that requires the CPU to suspend normal activities, to service the event and on its completion resume normal activities. Interrupt Resume Hierarchical or Nested Interrupts Interrupt Handling or ISR • Basic Assumption: The interrupter should in no way disturb the correct working of the interrupted task. 7

Use of Interrupt • Coordinating I/O activities: Letting peripherals interact with the CPU for Use of Interrupt • Coordinating I/O activities: Letting peripherals interact with the CPU for accessing the memory. • Faster response to events that require immediate service, e. g. real time systems. • Reminding the CPU to perform routine activities, e. g. update timer, execute pre-scheduled events • Implementing Multitasking dramatic improvement in performance (I/O wait) • Implementing task scheduling, e. g. round-robin • Error & exception reporting (alarms) 8

Instruction Execution Program Counter Instruction Fetch • Operand Address Calc • Operand Fetch Instruction Instruction Execution Program Counter Instruction Fetch • Operand Address Calc • Operand Fetch Instruction Decode Instruction Execute ALU Process Interrupt Y Interrupt Present N Next Instruction Resume 9

Source of Interrupt • Programmer generated (Software Interrupt) • Hardware (external), e. g. I/O Source of Interrupt • Programmer generated (Software Interrupt) • Hardware (external), e. g. I/O devices • Software generated • • • Overflow, e. g. Divide by Zero Underflow Wrong Op. Code Addressing Exception Page Fault • Hardware (Internal) Reset or Restart • Parity Check • Bus Failure 10

INT Instruction • The INT instruction executes a software interrupt. • The code that INT Instruction • The INT instruction executes a software interrupt. • The code that handles the interrupt is called an interrupt handler. • Syntax: INT number (number = 0. . FFh) The Interrupt Vector Table (IVT) holds a 32 -bit segmentoffset address for each possible interrupt handler. Interrupt Service Routine (ISR) is another name for interrupt handler. 11

Interrupt Vectoring Process 12 Interrupt Vectoring Process 12

Common Interrupts • • • INT 10 h Video Services INT 16 h Keyboard Common Interrupts • • • INT 10 h Video Services INT 16 h Keyboard Services INT 17 h Printer Services INT 1 Ah Time of Day INT 1 Ch User Timer Interrupt INT 21 h MS-DOS Services 13

MS-DOS Function Calls (INT 21 h) • • • ASCII Control Characters Selected Output MS-DOS Function Calls (INT 21 h) • • • ASCII Control Characters Selected Output Functions Selected Input Functions Example: String Encryption Date/Time Functions 14

INT 4 Ch: Terminate Process • Ends the current process (program), returns an optional INT 4 Ch: Terminate Process • Ends the current process (program), returns an optional 8 -bit return code to the calling process. • A return code of 0 usually indicates successful completion. mov ah, 4 Ch mov al, 0 int 21 h ; terminate process ; return code ; Same as: . EXIT 0 15

Selected Output Functions • • • ASCII control characters 02 h, 06 h - Selected Output Functions • • • ASCII control characters 02 h, 06 h - Write character to standard output 05 h - Write character to default printer 09 h - Write string to standard output 40 h - Write string to file or device 16

INT 21 h Functions 02 h and 06 h: Write Character to Standard Output INT 21 h Functions 02 h and 06 h: Write Character to Standard Output Write the letter 'A' to standard output: mov ah, 02 h mov dl, ’A’ int 21 h Write a backspace to standard output: mov ah, 06 h mov dl, 08 h int 21 h Read textbook for other examples. 17

The End 18 The End 18