Applications com or exe files DOS Your exe

  • Slides: 38
Download presentation
Applications (. com or. exe files) DOS Your. exe file (under debugging) BIOS Hardware

Applications (. com or. exe files) DOS Your. exe file (under debugging) BIOS Hardware system BIOS functions DOS functions

7. 2 Using the Keyboard DOS INT 21, function 01 H: Wait for Keyboard

7. 2 Using the Keyboard DOS INT 21, function 01 H: Wait for Keyboard Input Specification: waits for the user to press a key on the keyboard and returns the ASCII Input: AH = 01 (function code) Output: AL = ASCII code of the pressed key. The character is echoed to the video d Constrain: doesn’t return the control to the main program until a key is pressed. If the key correspond to an extended ASCII code, AL returns 00. The next INT 21, function 01 returns in AL the extended ASCII code. DOS INT 21, function 08 H: Console Input without Echo Specification: similar to function 01 but no echo on video display. BIOS INT 16, function 00 H: Read keyboard Input Specification: similar to INT 21 function 01 but if the pressed key correspond to an extended ASCII code, AL returns 00 and AH returns the extended ASCII code. No echo to. BIOS display. INT 16, function 01 H: Read keyboard status Specification: doesn’t wait. If the keyboard buffer is empty, ZF is set to 1. If not, returns the first ASCII code from buffer in the same way like function 00, and clear ZF. BIOS INT 16, function 02 H: Return Shift Flag Status Specification: waits for the user to press a key on the keyboard and returns the ASCII Input: AH = 02 (function code) Output: AL = Status of the special function keys: B 7=Insert, B 6=Caps Lock, B 5=Num Lock, B 4=Scroll Lock (active bit=1 => function B 3=Alt, B 2=Ctrl, B 1=Left Shift, B 0=Right Shift (active bit=1 => button pressed )

7. 3 Controlling the Video Display DOS INT 21, function 02 H: Display Output

7. 3 Controlling the Video Display DOS INT 21, function 02 H: Display Output Specification: writes a single character to the display screen, at the current cursor posi Input: AH = 02 (function code), DL = ASCII character to be sent to display. Control characters perform their specific action (0 DH = Carriage Return, 0 AH = Line Feed, 08 H = Backspace, etc. ). DOS INT 21, function 09 H: Display String Specification: Send to display a string in the current data segment. The string ends with ’$’ character (not displayed). Input: AH = 09 (function code), DX = The offset of the first character in the string. BIOS INT 10, function 00 H: Set Video Mode Specification: set video mode of the display (ex: mode 1 = 25 lines. X 40 characters, mode 3 = 25 lines. X 80 characters). Input: AH = 00 (function code), AL = The desired video mode. BIOS INT 10, function 0 FH: Read Current Video Mode Specification: returns video mode of the display. Input: AH = 0 F (function code) Output: AL = The current video mode. BIOS INT 10, function 02 H: Set Cursor Position Specification: moves the cursor to specified position (in text mode). Input: AH = 02 (function code), DH = the row (0 -24), DL column (0 -79), BH = page ( BIOS INT 10, function 03 H: Read the Current Cursor Position Input: AH = 02 (function code), BH = page (0) Output: DH = the row (0 -24), DL column (0 -79)

7. 3 Controlling the Video Display BIOS INT 10, function 0 AH: Write Character

7. 3 Controlling the Video Display BIOS INT 10, function 0 AH: Write Character to Screen Specification: write multiple times a character to screen at current cursor position. Input: AH = 0 A (function code), AL = ASCII code, BH = page number, CX = repeat v BIOS INT 10, function 09 H: Write Character/Attribute to Screen Specification: write multiple times a character to screen at current cursor position. Specify the video attribute of the character: B 7 = blink, (B 6 = red, B 5 = green, B 4 = blue)=background, B 3 = intensity, (B 2 = red, B 1 = green, B 0 = blue)=foreground Input: AH = 09 (function code), AL = ASCII code, BH = page number, BL = character’s attribute, CX = repeat value. BIOS INT 10, function 08 H: Read Character/Attribute from Screen Input: AH = 08 (function code), BH = display page (0) Output: AL = The Character code at the current cursor position, AH = the attribute b BIOS INT 10, function 06 H: Scroll Current Page Up Input: AH = 06 (function code) AL = Number of rows to scroll up (0 for entire region) BH = attribute for scrolled region CH = Row number at top of region CL = Column number at left of the region DH = Row number at bottom of region DL = Column number at right of the region Examples: in the textbook!

7. 1 Introduction • INT 10 Video services • INT 13 Disk Services •

7. 1 Introduction • INT 10 Video services • INT 13 Disk Services • INT 16 Keyboard functions • INT 17 Parallel printer functions • keyboard • display • printer functions • INT 21 • disk (Disk • date/time Operating • memory System) management • program control BIOS function s (Basic Reserved Input/ INTs Output System) DOS

Number Systems • Octal and hex are a convenient way to represent binary numbers,

Number Systems • Octal and hex are a convenient way to represent binary numbers, as used by computers. • Computer mechanics often need to write out binary quantities, but in practice writing out a binary number such as

Other Number Systems • 1001001101010001 is tedious, and prone to errors. • Therefore, binary

Other Number Systems • 1001001101010001 is tedious, and prone to errors. • Therefore, binary quantities are written in a base -8 ("octal") or, much more commonly, a base-16 ("hexadecimal" or "hex") number format.

Octal Number Systems • Base = 8 or ‘o’ or ‘Oct’ • 8 symbols:

Octal Number Systems • Base = 8 or ‘o’ or ‘Oct’ • 8 symbols: { 0, 1, 2, 3, 4, 5, 6, 7} • Example 123, 567, 7654 etc 987 This is incorrect why? • How to represent a Decimal Number using a Octal Number System ?

Octal Number Systems • Repeated Division by 8 • Example 21310 = ( )8

Octal Number Systems • Repeated Division by 8 • Example 21310 = ( )8 ? Divide-by -8 213 / 8 26 / 8 3/8 Quotient 26 3 0 Answer = 3258 Remainder 5 2 3 Octal digit Lower digit = 5 Second digit =2 Third digit =3

Octal Number Systems • How to convert 3258 back to Decimal ? • Use

Octal Number Systems • How to convert 3258 back to Decimal ? • Use this table and multiply the digits with the position values Digit 8 Digit 7 Digit 6 Digit 5 Digit 4 Digit 3 Digit 2 Digit 1 87 86 85 84 83 82 81 80 …… …… 32768 4096 512 64 8 1

Octal Number Systems • How to convert 3258 back to Decimal ? • Consider

Octal Number Systems • How to convert 3258 back to Decimal ? • Consider the above number Digit 1 3 2 5 (8) Digit 3 Digit 2 3 x 82 + 2 x 81 + 5 x 80 = 3 x 64 + 2 x 8 + 5 x 1 = 192 +16 + 5 = 213

Octal Number Systems • Example Convert 6118 • Consider the above number Digit 1

Octal Number Systems • Example Convert 6118 • Consider the above number Digit 1 6 1 1 (8) Digit 3 Digit 2 6 x 82 + 1 x 81 + 1 x 80 = 6 x 64 + 1 x 8 + 1 x 1 = 384 + 8 + 1 = 393

Octal Number Systems • Convert 393 to octal Divide-by -8 393 / 8 49

Octal Number Systems • Convert 393 to octal Divide-by -8 393 / 8 49 / 8 6/8 Quotient 49 6 0 Answer = 6118 Remainder 1 1 6 Octal digit Lower digit = 1 Second digit =1 Third digit =6

Hexadecimal Number Systems • Base = 16 or ‘H’ or ‘Hex’ 16 symbols: {

Hexadecimal Number Systems • Base = 16 or ‘H’ or ‘Hex’ 16 symbols: { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } { 10=A, 11=B, 12=C, 13=D, 14=E, 15= F}

Hexadecimal Number Systems • {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

Hexadecimal Number Systems • {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} It uses 6 Letters ! • Example AB 12, 876 F, FFFF etc • How to represent a Decimal Number using a Hexadecimal Number System ?

Hex Number Systems • Repeated Division by 16 • Example 21310 = ( )16

Hex Number Systems • Repeated Division by 16 • Example 21310 = ( )16 ? Divide-by -16 213 / 16 Quotient 13 0 Answer = D 516 Remainder 5 13 Hex digit Lower digit = 5 Second digit =D

Hex Number Systems • How to convert D 516 back to Decimal ? •

Hex Number Systems • How to convert D 516 back to Decimal ? • Use this table and multiply the digits with the position values Digit 8 Digit 7 Digit 6 Digit 5 Digit 4 Digit 3 Digit 2 Digit 1 167 166 165 164 163 162 161 160 …… …… …. . …… 4096 256 16 1

Hex Number Systems • How to convert D 516 back to Decimal ? •

Hex Number Systems • How to convert D 516 back to Decimal ? • Consider the above number Digit 1 D 5 (16) Digit 2 D x 161 + 5 x 160 = 13 x 16 + 5 x 1 = 208 + 5 = 213

Binary Number Systems • A single bit can represent two states: 0 1 •

Binary Number Systems • A single bit can represent two states: 0 1 • Therefore, if you take two bits, you can use them to represent four unique states: 00, 01, 10, & 11 • And, if you have three bits, then you can use them to represent eight unique states: 000, 001, 010, 011, 100, 101, 110, & 111

Binary Number Systems • And, if you have three bits, then you can use

Binary Number Systems • And, if you have three bits, then you can use them to represent eight unique states: These have a perfect correspondence to Octal 000 = Octal 0 100 = Octal 4 001 = Octal 1 101 = Octal 5 010 = Octal 2 110 = Octal 6 011 = Octal 3 111 = Octal 7

Binary Number Systems • With every bit you add, you double the number of

Binary Number Systems • With every bit you add, you double the number of states you can represent. Therefore, the expression for the number of states with n bits is 2 n. Most computers operate on information in groups of 8 bits,

Binary Number Systems • A unit of four bits, or half an octet, is

Binary Number Systems • A unit of four bits, or half an octet, is often called a nibble (or nybble). It can encode 16 different values, such as the numbers 0 to 15. Any arbitrary sequence of bits could be used in principle,

Binary Number Systems , but in practice the most common scheme is: 0000 =

Binary Number Systems , but in practice the most common scheme is: 0000 = decimal 00 hex 0 1000 = decimal 08 hex 8 0001 = decimal 01 hex 1 1001 = decimal 09 hex 9 0010 = decimal 02 hex 2 1010 = decimal 10 hex A 0011 = decimal 03 hex 3 1011 = decimal 11 hex B 0100 = decimal 04 hex 4 1100 = decimal 12 hex C 0101 = decimal 05 hex 5 1101 = decimal 13 hex D 0110 = decimal 06 hex 6 1110 = decimal 14 hex E 0111 = decimal 07 hex 7 1111 = decimal 15 hex F These have perfect correspondence to Hex

Convert Binary to Hex • • Group into 4's starting at least significant symbol

Convert Binary to Hex • • Group into 4's starting at least significant symbol (if the number of bits is not evenly divisible by 4, then add 0's at the most significant end) write 1 hex digit for each group

Convert Binary to Hex Example: Convert 1001 1110 0111 0000 to Hex After grouping

Convert Binary to Hex Example: Convert 1001 1110 0111 0000 to Hex After grouping follow the procedure as discussed in the previous section use the symbols of Hex number system like 13=E 1001 1110 9 E 0111 0000 7 0

Convert Binary to Hex Example: Convert 100 1010 011 0000 to Hex 10 0101

Convert Binary to Hex Example: Convert 100 1010 011 0000 to Hex 10 0101 0011 0000 This group has only two bits, to make it a group of 4 bits add zeros in MSB position 0010 2 0101 5 0011 0000 3 0

Convert Hex to Binary • • For each of the Hex digit write its

Convert Hex to Binary • • For each of the Hex digit write its binary equivalent (use 4 bits to represent) Example Convert 25 A 0 to binary 0010 0101 1010 0000

Convert Binary to Octal • • Group into 3's starting at least significant symbol

Convert Binary to Octal • • Group into 3's starting at least significant symbol (if the number of bits is not evenly divisible by 3, then add 0's at the most significant end) write 1 octal digit for each group

Convert Binary to Octal Example: Convert 1001 1110 0111 0000 to Oct After grouping

Convert Binary to Octal Example: Convert 1001 1110 0111 0000 to Oct After grouping follow the procedure as discussed in the previous section use the symbols of Oct number system like add two zeros here 001 111 001 110 000 1 1 7 1 6 0 Answer = 1171608

Convert Octal to Binary • • For each of the Octal digit write its

Convert Octal to Binary • • For each of the Octal digit write its binary equivalent Example Convert 2570 to binary 010 101 111 000

TOPICS • Information Representation • Characters and Images

TOPICS • Information Representation • Characters and Images

Information Representation • All information must be rendered into binary in order to be

Information Representation • All information must be rendered into binary in order to be stored on a computer. • Besides numbers, almost all applications must store characters and string information. • Images are pervasive in today’s internet world and must be rendered in binary to be handled by internet browsers.

Character Representation • ASCII – PC workstations • EBCDIC – IBM Mainframes • Unicode

Character Representation • ASCII – PC workstations • EBCDIC – IBM Mainframes • Unicode – International Character sets

ASCII • Expanded name American Standard Code for Information Interchange • Area covered 7

ASCII • Expanded name American Standard Code for Information Interchange • Area covered 7 -bit coded character set for information interchange • Characteristics/description Specifies coding of space and a set of 94 characters (letters, digits and punctuation or mathematical symbols) suitable for the interchange of basic English language documents. Forms the basis for most computer code sets

ASCII

ASCII

EBCDIC • Expanded name Extended Binary Coded Decimal Interchange Code • Proprietary specification developed

EBCDIC • Expanded name Extended Binary Coded Decimal Interchange Code • Proprietary specification developed by IBM • Characteristics/description A set of national character sets for interchange of documents between IBM mainframes. Most EBCDIC character sets do not contain all of the characters defined in the ASCII code

EBCDIC • EBCDIC • Usage Not much used outside of IBM and similar mainframe

EBCDIC • EBCDIC • Usage Not much used outside of IBM and similar mainframe environments. When transmitting EBCDIC files between systems care needs to be taken to ensure that the systems are set up for the relevant national code set.

EBCDIC

EBCDIC