Online Book Reader

Home Category

Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [116]

By Root 1623 0
A,DFh

The ANI instruction is an AND Immediate. It performs a bitwise AND operation between the value in the accumulator and the value DFh, which is 11011111 in binary. By bitwise, I mean that the instruction performs an AND operation between each pair of corresponding bits that make up the two numbers. This AND operation preserves all the bits in A except the third from the left, which is set to 0. Setting that bit to 0 also effectively converts an ASCII lowercase letter to uppercase.

The 95 codes shown above are said to refer to graphic characters because they have a visual representation. ASCII also includes 33 control characters that have no visual representation but instead perform certain functions. For the sake of completeness, here are the 33 ASCII control characters, but don't worry if they seem mostly incomprehensible. At the time ASCII was developed, it was intended mostly for teletypewriters, and many of these codes are currently obscure.

Hex Code

Acronym

Control Character Name

00

NUL

Null (Nothing)

01

SOH

Start of Heading

02

STX

Start of Text

03

ETX

End of Text

04

EOT

End of Transmission

05

ENQ

Enquiry (i.e., Inquiry)

06

ACK

Acknowledge

07

BEL

Bell

08

BS

Backspace

09

HT

Horizontal Tabulation

0A

LF

Line Feed

0B

VT

Vertical Tabulation

0C

FF

Form Feed

0D

CR

Carriage Return

0E

SO

Shift-Out

0F

SI

Shift-In

10

DLE

Data Link Escape

11

DC1

Device Control 1

12

DC2

Device Control 2

13

DC3

Device Control 3

14

DC4

Device Control 4

15

NAK

Negative Acknowledge

16

SYN

Synchronous Idle

17

ETB

End of Transmission Block

18

CAN

Cancel

19

EM

End of Medium

1A

SUB

Substitute Character

1B

ESC

Escape

1C

FS

File Separator or Information Separator 4

1D

GS

Group Separator or Information Separator 3

1E

RS

Record Separator or Information Separator 2

1F

US

Unit Separator or Information Separator 1

7F

DEL

Delete

The idea here is that control characters can be intermixed with graphic characters to do some rudimentary formatting of the text. This is easiest to understand if you think of a device—such as a teletypewriter or a simple printer—that types characters on a page in response to a stream of ASCII codes. The device's printing head normally responds to character codes by printing a character and moving one space to the right. The most important control characters alter this normal behavior.

For example, consider the hexadecimal character string

41 09 42 09 43 09

The 09 character is a Horizontal Tabulation code, or Tab for short. If you think of all the horizontal character positions on the printer page as being numbered starting with 0, the Tab code usually means to print the next character at the next horizontal position that's a multiple of 8, like this:

A B C

This is a handy way to keep text lined up in columns.

Even today, many computer printers respond to a Form Feed code (12h) by ejecting the current page and starting a new page.

The Backspace code can be used for printing composite characters on some old printers. For example, suppose the computer controlling the teletypewriter wanted to display a lowercase e with a grave accent mark, like so: è. This could be achieved by using the hexadecimal codes 65 08 60.

By far the most important control codes are Carriage Return and Line Feed, which have the same meaning as the similar Baudot codes. On a printer, the Carriage Return code moves the printing head to the left side of the page, and the Line Feed code moves the printing head one line down. Both codes are generally required to go to a new line. A Carriage Return can be used by itself to print over an existing line, and a Line Feed can be used by itself to skip to the next line without moving to the left margin.

Although ASCII is the dominant standard in the computing world, it isn't used on many of IBM's larger computer systems. In connection with the System/360, IBM developed its own 8-bit character code known as the Extended BCD Interchange Code, or

Return Main Page Previous Page Next Page

®Online Book Reader