153
WEEK 1 WHY COMPUTERS? Algorithms

Algoritmos . Conceptos Básicos

Embed Size (px)

DESCRIPTION

Algoritmos y programacionIntroduccionConceptos basicos

Citation preview

Page 1: Algoritmos . Conceptos Básicos

WEEK 1WHY COMPUTERS?

Algorithms

Page 2: Algoritmos . Conceptos Básicos

0. What is a Computer?Is a programmable machine

designed to sequentially and automatically carry out a secuence of aritmetic or logical aperations. The particular secuence of operations can be changed readily, allowing the computer to solve than one kind problem.

Page 3: Algoritmos . Conceptos Básicos

In the Beginning

ENIAC Electronic Numerical Integrator And Computer.

The first electronic digital computer developed for the U.S.

Started 1943 Programed by plugging in

cords and setting thousands of swiches.

18.000 vacuum tubes Weight 30 tons 1800 square feet 5000 additions per second It cost a fortune in

electricity to run. It was dismantled in 1955

Page 4: Algoritmos . Conceptos Básicos

Most people’s computer...Most people would be lost if all the computers in the world

went down at the same time.

Page 5: Algoritmos . Conceptos Básicos

CRT Display

Keyboard

Mouse

“The Box”CD-ROM Drive

FloppyDiskDrive

Page 6: Algoritmos . Conceptos Básicos

Inside “The Box”

Page 7: Algoritmos . Conceptos Básicos

Motherboard

Page 8: Algoritmos . Conceptos Básicos

CPU(Central Processing Unit)

Page 9: Algoritmos . Conceptos Básicos

SIMM(Single Inline Memory Module)

Page 10: Algoritmos . Conceptos Básicos

HDD(Hard Disk Drive)

Page 11: Algoritmos . Conceptos Básicos

Power Supply

Page 12: Algoritmos . Conceptos Básicos

Schematic Diagram of a Personal Computer...

Page 13: Algoritmos . Conceptos Básicos

Ports

CPU

RAM

Diskcontroller

Graphicscard

Soundcard

Networkcard

Printer

Mouse

Keyboard

Modem Monitor

Speakers

bus

Computer

Page 14: Algoritmos . Conceptos Básicos

Other Examples

Page 15: Algoritmos . Conceptos Básicos
Page 16: Algoritmos . Conceptos Básicos
Page 17: Algoritmos . Conceptos Básicos
Page 18: Algoritmos . Conceptos Básicos

Computing is Much, Much More...

Page 19: Algoritmos . Conceptos Básicos

Mobile Computing

Page 20: Algoritmos . Conceptos Básicos
Page 21: Algoritmos . Conceptos Básicos

Output Devices

Page 22: Algoritmos . Conceptos Básicos
Page 23: Algoritmos . Conceptos Básicos
Page 24: Algoritmos . Conceptos Básicos

Input Devices

Page 25: Algoritmos . Conceptos Básicos
Page 26: Algoritmos . Conceptos Básicos

Other Input

OCR – optical character recognitionBar code readersVoice/audio inputPunched cardsImages / objectsPointing devices

Page 27: Algoritmos . Conceptos Básicos

OCR

El OCR (Optical character recognition) es un software de reconocimiento de texto que saca de una imagen el texto que contiene y lo transforma en cadenas de caracteres para guardarlos en un formato que se pueda utilizar en programas de edición de texto.

Si necesitamos extraer ese texto para poder editarlo, necesitamos un programa de OCR que reconozca dicho texto y lo transforme en una cadena de caracteres (ya sea ASCII o Unicode) y posteriormente copiar esta cadena a un programa de edición para ya poder trabajar con ella, con el consiguiente ahorro de tiempo al no tener que teclear este texto.

Page 28: Algoritmos . Conceptos Básicos

OCR

Hello, world

Page of text

Optical scan 10110110…

Computer file

Page 29: Algoritmos . Conceptos Básicos

Other Input

OCR – optical character recognitionBar code readersVoice/audio inputPunched cardsImages / objectsPointing devices

Page 30: Algoritmos . Conceptos Básicos

Bar Codes

An automatic identification (Auto ID) technology that streamlines identification and data collection

See http://www.digital.net/barcoder/barcode.html

Page 31: Algoritmos . Conceptos Básicos

Código de barras

El código de barras consiste en un sistema de codificación creado a través de series de líneas y espacios paralelos de distinto grosor. Generalmente se utiliza como sistema de control ya que facilita la actividad comercial del fabricante y del distribuidor, por lo que no ofrece información al consumidor, si no datos de operaciones aplicados a identificar productos, llevar control de inventarios, carga y descarga de mercancías, disminuir tiempos de atención en ventas.

Una de las principales ventajas es que los datos almacenados en un código de barras puede ser leído de manera precisa y rápida.

Page 32: Algoritmos . Conceptos Básicos

Other Input

OCR – optical character recognitionBar code readersVoice/audio inputPunched cardsImages / objectsPointing devices

Page 33: Algoritmos . Conceptos Básicos

Voice/audio Input

Input device: microphoneAudio input is “digitized” and storedProcessed in two ways

As is (no recognition) Recognized and converted to alphanumeric data

(ASCII)

Digitize

10110010…

Page 34: Algoritmos . Conceptos Básicos

Other Input

OCR – optical character recognitionBar code readersVoice/audio inputPunched cardsImages / objectsPointing devices

Page 35: Algoritmos . Conceptos Básicos

Punched Cards

Invented by Herman Hollerith (founder of IBM)

Each card holds 80 characters

Page 36: Algoritmos . Conceptos Básicos

Other Input

OCR – optical character recognitionBar code readersVoice/audio inputPunched cardsImages / objectsPointing devices

Page 37: Algoritmos . Conceptos Básicos

Images

Typically images are pictures that are optically scanned and saved as a “bit map” or in some other format

Many formats gif, jpeg, …

Page 38: Algoritmos . Conceptos Básicos

Typical “Save As” Dialog

Page 39: Algoritmos . Conceptos Básicos

Objects

Images made of geometrically definable shapes

Offer efficiency, flexibility, small size, etc.

Page 40: Algoritmos . Conceptos Básicos

Other Input

OCR – optical character recognitionBar code readersVoice/audio inputPunched cardsImages / objectsPointing devices

Page 41: Algoritmos . Conceptos Básicos

Pointing Devices

Originally used for specifying coordinates (x, y) for graphical input

Today used as general purpose device for “graphical user interfaces” (GUIs)

Page 42: Algoritmos . Conceptos Básicos

“Other” Computing

Page 43: Algoritmos . Conceptos Básicos

Roles

Busines: Computer can tabulate bills, calculate profit and loss, and predict the future of bussines. Things can be sold and bought on line, and computer are a major part of the stock marked.

Comunication: E-mail allow instant comunication all over the world. Computers save time and give you information at your fingertips. The Internet provides a fast and easy way to research any topic.

Daily life: we operate washing machines, microwave oven and many others products using software.

We can store all information about our work, appointments schedules and list of contacts.

we need to have the knowledge about all fields of the computers

Page 44: Algoritmos . Conceptos Básicos

Media

There is sofware for every kind of editing audio visual composition. Special efects rely heavily on computers.

Popular special effects seen in movies include fire, explosions, rain, snow and smoke. A number of movies also showcase effects that change the look of characters like those that make a person look older, younger or monstrous or transform into another person, creature or object.

Page 45: Algoritmos . Conceptos Básicos
Page 46: Algoritmos . Conceptos Básicos
Page 47: Algoritmos . Conceptos Básicos

Other roles

Medical science: Computers can help with

diagnosis, and there is special software wich assists doctors during surgery.

Travel and ticketing: Computers do all the

work of plane and train reservation. It shows the data for vacant and reserved seats and also saves the record for reservation

Sports: Computers can help

referees and umpire make decisions. Also, simulation software can help and atletic improve his or her skills.

Weather: Super computers take

data from observations and give meteorologist “models” to help them predict weather.

Page 48: Algoritmos . Conceptos Básicos
Page 49: Algoritmos . Conceptos Básicos
Page 50: Algoritmos . Conceptos Básicos
Page 51: Algoritmos . Conceptos Básicos
Page 52: Algoritmos . Conceptos Básicos
Page 53: Algoritmos . Conceptos Básicos
Page 54: Algoritmos . Conceptos Básicos

1. Number Systems

Page 55: Algoritmos . Conceptos Básicos

Common Number Systems

System Base SymbolsUsed by humans?

Used in computers?

Decimal 10 0, 1, … 9 Yes No

Binary 2 0, 1 No Yes

Octal 8 0, 1, … 7 No No

Hexa-decimal

16 0, 1, … 9,A, B, … F

No No

Page 56: Algoritmos . Conceptos Básicos

Quantities/Counting (1 of 3)

Decimal Binary OctalHexa-

decimal

0 0 0 0

1 1 1 1

2 10 2 2

3 11 3 3

4 100 4 4

5 101 5 5

6 110 6 6

7 111 7 7

Page 57: Algoritmos . Conceptos Básicos

Quantities/Counting (2 of 3)

Decimal Binary OctalHexa-

decimal

8 1000 10 8

9 1001 11 9

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

Page 58: Algoritmos . Conceptos Básicos

Quantities/Counting (3 of 3)

Decimal Binary OctalHexa-

decimal

16 10000 20 10

17 10001 21 11

18 10010 22 12

19 10011 23 13

20 10100 24 14

21 10101 25 15

22 10110 26 16

23 10111 27 17 Etc.

Page 59: Algoritmos . Conceptos Básicos

Conversion Among Bases

The possibilities:

Hexadecimal

Decimal Octal

Binary

Page 60: Algoritmos . Conceptos Básicos

Quick Example

2510 = 110012 = 318 = 1916

Base

Page 61: Algoritmos . Conceptos Básicos

Decimal to Decimal (just for fun)

Hexadecimal

Decimal Octal

Binary

Next slide…

Page 62: Algoritmos . Conceptos Básicos

12510 => 5 x 100 = 52 x 101 = 201 x 102 = 100

125

Base

Weight

Page 63: Algoritmos . Conceptos Básicos

Binary to Decimal

Hexadecimal

Decimal Octal

Binary

Page 64: Algoritmos . Conceptos Básicos

Binary to Decimal

Technique Multiply each bit by 2n, where n is the “weight” of the

bit The weight is the position of the bit, starting from 0

on the right Add the results

Page 65: Algoritmos . Conceptos Básicos

Example

1010112 => 1 x 20 = 11 x 21 =

20 x 22 =

01 x 23 =

80 x 24 =

01 x 25 =

32

4310

Bit “0”

Page 66: Algoritmos . Conceptos Básicos

Octal to Decimal

Hexadecimal

Decimal Octal

Binary

Page 67: Algoritmos . Conceptos Básicos

Octal to Decimal

Technique Multiply each bit by 8n, where n is the “weight” of the

bit The weight is the position of the bit, starting from 0

on the right Add the results

Page 68: Algoritmos . Conceptos Básicos

Example

7248 => 4 x 80 = 42 x 81 = 167 x 82 = 448

46810

Page 69: Algoritmos . Conceptos Básicos

Hexadecimal to Decimal

Hexadecimal

Decimal Octal

Binary

Page 70: Algoritmos . Conceptos Básicos

Hexadecimal to Decimal

Technique Multiply each bit by 16n, where n is the “weight” of

the bit The weight is the position of the bit, starting from 0

on the right Add the results

Page 71: Algoritmos . Conceptos Básicos

Example

ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560

274810

Page 72: Algoritmos . Conceptos Básicos

Decimal to Binary

Hexadecimal

Decimal Octal

Binary

Page 73: Algoritmos . Conceptos Básicos

Decimal to Binary

Technique Divide by two, keep track of the remainder First remainder is bit 0 (LSB, least-significant bit) Second remainder is bit 1 Etc.

Page 74: Algoritmos . Conceptos Básicos

Example

12510 = ?22 125 62 12 31 02 15 12 7 12 3 12 1 12 0 1

12510 = 11111012

Page 75: Algoritmos . Conceptos Básicos

Octal to Binary

Hexadecimal

Decimal Octal

Binary

Page 76: Algoritmos . Conceptos Básicos

Octal to Binary

Technique Convert each octal digit to a 3-bit equivalent binary

representation

Page 77: Algoritmos . Conceptos Básicos

Example

7058 = ?2

7 0 5

111 000 101

7058 = 1110001012

Page 78: Algoritmos . Conceptos Básicos

Hexadecimal to Binary

Hexadecimal

Decimal Octal

Binary

Page 79: Algoritmos . Conceptos Básicos

Hexadecimal to Binary

Technique Convert each hexadecimal digit to a 4-bit equivalent

binary representation

Page 80: Algoritmos . Conceptos Básicos

Example

10AF16 = ?2

1 0 A F

0001 0000 1010 1111

10AF16 = 00010000101011112

Page 81: Algoritmos . Conceptos Básicos

Decimal to Octal

Hexadecimal

Decimal Octal

Binary

Page 82: Algoritmos . Conceptos Básicos

Decimal to Octal

Technique Divide by 8 Keep track of the remainder

Page 83: Algoritmos . Conceptos Básicos

Example

123410 = ?8

8 1234 154 28 19 28 2 38 0 2

123410 = 23228

Page 84: Algoritmos . Conceptos Básicos

Decimal to Hexadecimal

Hexadecimal

Decimal Octal

Binary

Page 85: Algoritmos . Conceptos Básicos

Decimal to Hexadecimal

Technique Divide by 16 Keep track of the remainder

Page 86: Algoritmos . Conceptos Básicos

Example

123410 = ?16

123410 = 4D216

16 1234 77 216 4 13 = D16 0 4

Page 87: Algoritmos . Conceptos Básicos

Binary to Octal

Hexadecimal

Decimal Octal

Binary

Page 88: Algoritmos . Conceptos Básicos

Binary to Octal

Technique Group bits in threes, starting on right Convert to octal digits

Page 89: Algoritmos . Conceptos Básicos

Example

10110101112 = ?8

1 011 010 111

1 3 2 7

10110101112 = 13278

Page 90: Algoritmos . Conceptos Básicos

Binary to Hexadecimal

Hexadecimal

Decimal Octal

Binary

Page 91: Algoritmos . Conceptos Básicos

Binary to Hexadecimal

Technique Group bits in fours, starting on right Convert to hexadecimal digits

Page 92: Algoritmos . Conceptos Básicos

Example

10101110112 = ?16

10 1011 1011

2 B B

10101110112 = 2BB16

Page 93: Algoritmos . Conceptos Básicos

Octal to Hexadecimal

Hexadecimal

Decimal Octal

Binary

Page 94: Algoritmos . Conceptos Básicos

Octal to Hexadecimal

Technique Use binary as an intermediary

Page 95: Algoritmos . Conceptos Básicos

Example

10768 = ?16

1 0 7 6

001 000 111 110

2 3 E

10768 = 23E16

Page 96: Algoritmos . Conceptos Básicos

Hexadecimal to Octal

Hexadecimal

Decimal Octal

Binary

Page 97: Algoritmos . Conceptos Básicos

Hexadecimal to Octal

Technique Use binary as an intermediary

Page 98: Algoritmos . Conceptos Básicos

Example

1F0C16 = ?8

1 F 0 C

0001 1111 0000 1100

1 7 4 1 4

1F0C16 = 174148

Page 99: Algoritmos . Conceptos Básicos

Exercise – Convert ...

Don’t use a calculator!

Decimal Binary OctalHexa-

decimal

33

1110101

703

1AF

Skip answer Answer

Page 100: Algoritmos . Conceptos Básicos

Exercise – Convert …

Decimal Binary OctalHexa-

decimal

33 100001 41 21

117 1110101 165 75

451 111000011 703 1C3

431 110101111 657 1AF

Answer

Page 101: Algoritmos . Conceptos Básicos

Common Powers (1 of 2)

Base 10Power Preface Symbol

10-12 pico p

10-9 nano n

10-6 micro

10-3 milli m

103 kilo k

106 mega M

109 giga G

1012 tera T

Value

.000000000001

.000000001

.000001

.001

1000

1000000

1000000000

1000000000000

Page 102: Algoritmos . Conceptos Básicos

Common Powers (2 of 2)

Base 2Power Preface Symbol

210 kilo k

220 mega M

230 Giga G

Value

1.024

1.048.576

1.073.741.824

• What is the value of “k”, “M”, and “G”?• In computing, particularly w.r.t. memory, the base-2 interpretation generally applies

Page 103: Algoritmos . Conceptos Básicos

Example

/ 230 =

In the lab…1. Double click on My Computer2. Right click on C:3. Click on Properties

Page 104: Algoritmos . Conceptos Básicos

Exercise – Free Space

Determine the “free space” on all drives on your computer

DriveFree space

Bytes GB

A:

C:

D:

E:

etc.

Page 105: Algoritmos . Conceptos Básicos

Review – multiplying powers

For common bases, add powers

26 210 = 216 = 65,536

or…

26 210 = 64 210 = 64k

ab ac = ab+c

Page 106: Algoritmos . Conceptos Básicos

Binary Addition (1 of 2)

Two 1-bit values

A B A + B0 0 00 1 11 0 11 1 10

“two”

Page 107: Algoritmos . Conceptos Básicos

Binary Addition (2 of 2)

Two n-bit values Add individual bits Propagate carries E.g.,

10101 21+ 11001 + 25 101110 46

11

Page 108: Algoritmos . Conceptos Básicos

Multiplication (1 of 3)

Decimal (just for fun)

35x 105 175 000 35 3675

Page 109: Algoritmos . Conceptos Básicos

Multiplication (2 of 3)

Binary, two 1-bit values

A B A B0 0 00 1 01 0 01 1 1

Page 110: Algoritmos . Conceptos Básicos

Multiplication (3 of 3)

Binary, two n-bit values As with decimal values E.g.,

1110 x 1011 1110 1110 0000 111010011010

Page 111: Algoritmos . Conceptos Básicos

Fractions

Decimal to decimal (just for fun)

3.14 => 4 x 10-2 = 0.041 x 10-1 = 0.1

3 x 100 = 3 3.14

Page 112: Algoritmos . Conceptos Básicos

Fractions

Binary to decimal

10.1011 => 1 x 2-4 = 0.06251 x 2-3 = 0.1250 x 2-2 = 0.251 x 2-1 = 0.50 x 20 = 0.01 x 21 = 2.0 2.6875

Page 113: Algoritmos . Conceptos Básicos

Fractions

Decimal to binary3.14579

.14579x 20.29158x 20.58316x 21.16632x 20.33264x 20.66528x 21.33056

etc.11.001001...

Page 114: Algoritmos . Conceptos Básicos

Exercise – Convert ...

Don’t use a calculator!

Decimal Binary OctalHexa-

decimal

29.8

101.1101

3.07

C.82

Skip answer Answer

Page 115: Algoritmos . Conceptos Básicos

Exercise – Convert …

Decimal Binary OctalHexa-

decimal

29.8 11101.110011… 35.63… 1D.CC…

5.8125 101.1101 5.64 5.D

3.109375 11.000111 3.07 3.1C

12.5078125 1100.10000010 14.404 C.82

Answer

Page 116: Algoritmos . Conceptos Básicos

2. Data Formats

Page 117: Algoritmos . Conceptos Básicos

Introduction

ExamplesReal World

Data

Computer

DataInput device

Dear Mom: Keyboard 10110010…

Digitalcamera

10110010…

Page 118: Algoritmos . Conceptos Básicos

Format must be appropriate

The internal representation must be appropriate for the type of processing to take place (e.g., text, images, sound)

Page 119: Algoritmos . Conceptos Básicos

Standards Organizations

ISO – International Standards OrganizationCSA – Canadian Standards AssociationANSI – American National Standards

InstituteIEEE – Institute for Electrical and Electronics

EngineersEtc.

Page 120: Algoritmos . Conceptos Básicos

Examples of Standards

Type of Data Standards

Alphanumeric ASCII, EBCDIC, Unicode

Image JPEG, GIF, PCX, TIFF

Motion picture MPEG-2, Quick Time

Sound Sound Blaster, WAV, AU

Outline graphics/fonts PostScript, TrueType, PDF

Page 121: Algoritmos . Conceptos Básicos

Why Standards?

Standard are “arbitrary”They exist because they are

Convenient Efficient Flexible Appropriate Etc.

Page 122: Algoritmos . Conceptos Básicos

Alphanumeric Data

Problem: Distinguishing between the number 123 (one hundred and twenty-three) and the characters “123” (one, two, three)

Four standards for representing letters (alpha) and numbers BCD – Binary-coded decimal ASCII – American standard code for information

interchange EBCDIC – Extended binary-coded decimal

interchange code Unicode

Page 123: Algoritmos . Conceptos Básicos

Next 2 slides

Standard Alphanumeric Formats

BCDASCIIEBCDICUnicode

Page 124: Algoritmos . Conceptos Básicos

Binary-Coded Decimal (BCD)

Four bits per digit Digit Bit pattern

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

8 1000

9 1001

Note: the following bit patterns are not used:

101010111100110111101111

Page 125: Algoritmos . Conceptos Básicos

Example

709310 = ? (in BCD)

7 0 9 3

0111 0000 1001 0011

Page 126: Algoritmos . Conceptos Básicos

Next 22 slides

Standard Alphanumeric Formats

BCDASCIIEBCDICUnicode

Page 127: Algoritmos . Conceptos Básicos

The Problem

Representing text strings, such as “Hello, world”, in a computer

Page 128: Algoritmos . Conceptos Básicos

Codes and Characters

Each character is coded as a byteMost common coding system is ASCII

(Pronounced ass-key)ASCII = American National Standard Code

for Information InterchangeDefined in ANSI document X3.4-1977

Page 129: Algoritmos . Conceptos Básicos

ASCII Features

7-bit code8th bit is unused (or used for a parity bit)27 = 128 codesTwo general types of codes:

95 are “Graphic” codes (displayable on a console) 33 are “Control” codes (control features of the console

or communications channel)

Page 130: Algoritmos . Conceptos Básicos

ASCII Chart

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 131: Algoritmos . Conceptos Básicos

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 132: Algoritmos . Conceptos Básicos

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Most significant bit

Least significant bit

Page 133: Algoritmos . Conceptos Básicos

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

e.g., ‘a’ = 1100001

Page 134: Algoritmos . Conceptos Básicos

95 Graphic codes

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 135: Algoritmos . Conceptos Básicos

33 Control codes

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 136: Algoritmos . Conceptos Básicos

Alphabetic codes

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 137: Algoritmos . Conceptos Básicos

Numeric codes

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 138: Algoritmos . Conceptos Básicos

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Punctuation, etc.

Page 139: Algoritmos . Conceptos Básicos

“Hello, world” Example

============

Binary010010000110010101101100011011000110111100101100001000000111011101100111011100100110110001100100

Hexadecimal48656C6C6F2C207767726C64

Decimal72

1011081081114432

119103114108100

Hello, world

============

============

Page 140: Algoritmos . Conceptos Básicos

Common Control Codes

CR 0D carriage returnLF 0A line feedHT 09 horizontal tabDEL 7F deleteNULL 00 null

Hexadecimal code

Page 141: Algoritmos . Conceptos Básicos

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 142: Algoritmos . Conceptos Básicos

Terminology

Learn the names of the special symbols [ ] brackets { } braces ( ) parentheses @ commercial ‘at’ sign & ampersand ~ tilde

Page 143: Algoritmos . Conceptos Básicos

000 001 010 011 100 101 110 1110000 NULL DLE 0 @ P ` p0001 SOH DC1 ! 1 A Q a q0010 STX DC2 " 2 B R b r0011 ETX DC3 # 3 C S c s0100 EDT DC4 $ 4 D T d t0101 ENQ NAK % 5 E U e u0110 ACK SYN & 6 F V f v0111 BEL ETB ' 7 G W g w1000 BS CAN ( 8 H X h x1001 HT EM ) 9 I Y i y1010 LF SUB * : J Z j z1011 VT ESC + ; K [ k {1100 FF FS , < L \ l |1101 CR GS - = M ] m }1110 SO RS . > N ^ n ~1111 SI US / ? O _ o DEL

Page 144: Algoritmos . Conceptos Básicos

Escape Sequences

Extend the capability of the ASCII code setFor controlling terminals and formatting

outputDefined by ANSI in documents X3.41-1974

and X3.64-1977The escape code is ESC = 1B16

An escape sequence begins with two codes:

ESC [ 1B1

6

5B1

6

Page 145: Algoritmos . Conceptos Básicos

Next 1 slides

Standard Alphanumeric Formats

BCDASCIIEBCDICUnicode

Page 146: Algoritmos . Conceptos Básicos

EBCDIC

Extended BCD Interchange Code (pronounced ebb’-se-dick)

8-bit codeDeveloped by IBMRarely used todayIBM mainframes only

Page 147: Algoritmos . Conceptos Básicos

Next 2 slides

Standard Alphanumeric Formats

BCDASCIIEBCDICUnicode

Page 148: Algoritmos . Conceptos Básicos

Unicode

16-bit standardDeveloped by a consortiaIntended to supercede older 7- and 8-bit

codes

Unicode provides a unique number for every character,

no matter what the platform,no matter what the program,no matter what the language.

Page 149: Algoritmos . Conceptos Básicos

Unicode Version 2.1

1998Improves on version 2.0 Includes the Euro sign (20AC16 = ) From the standard:

…contains 38,887 distinct coded characters derived from the supported scripts. These characters cover the principal written languages of the Americas, Europe, the Middle East, Africa, India, Asia, and Pacifica.

http://www.unicode.org

Page 150: Algoritmos . Conceptos Básicos

Keyboard Input

Key (“scan”) codes are converted to ASCIIASCII code sent to host computerReceived by the host as a “stream” of dataStored in bufferProcessedEtc.

Page 151: Algoritmos . Conceptos Básicos

Shift Key

inhibits bit 5 in the ASCII code

Key(s)ASCII code

6 5 4 3 2 1 0 Character

1 1 0 0 0 0 1

1 0 0 0 0 0 1

a

A

a

aShift

Page 152: Algoritmos . Conceptos Básicos

Control Key

inhibits bits 5 & 6 in the ASCII code

Key(s)ASCII code

6 5 4 3 2 1 0 Character

1 1 0 0 0 1 1

0 0 0 0 0 1 1

c

ETX

c

cCtrl

Controlcode

Page 153: Algoritmos . Conceptos Básicos

Thank you

Tomado de Universidad de Nueva York

http://www.cse.yorku.ca/~mack/1011/