1. Trang chủ
  2. » Công Nghệ Thông Tin

Introduction to Computing: Lecture 2 - Dr. Pham Tran Vu

42 41 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 42
Dung lượng 506,15 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Introduction to Computing: Lecture 2 - Dr. Pham Tran Vu presents about Data Representation, Character & Numeric Codes, ASCII Character Set, Structure of Main Memory, Internal Numbers, Representation of Signed Integers, Arithmetic Operations, Computer logic.

Trang 1

Introduction to Computing

Lectured by: Dr Pham Tran Vu

t.v.pham@cse.hcmut.edu.vn

Trang 3

Assignment Topics

 Web search engines: history and

development

 Online games: benefits and social issues

 Software licensing and opportunities for

open source software

 Internet in Vietnam: development history

and its social impacts

Trang 4

Lecture 2: Fundamental Concepts

(cont’)

History of computer

Number systems

Data representation

Trang 5

Data Representation

 Data processed by computers has to be in

binary form

 Main memory and external storage media,

e.g magnetic disk and tape, use

electrical/magnetic patterns representing

binary digits to record and handle data &

instructions

Trang 6

Character & Numeric Codes

 Character codes used to represent data processed

by computers and stored data

 Numeric codes used to represent numeric data for

processing purposes

 Characters may be:

 Alphabetic (upper and lower case)

 Numeric

 Special characters (apostrophe, comma, etc)

Trang 7

ASCII Character Set

 The range of characters which can be represented

by a computer system is know as character set

 ASCII – American Standard Code for Information

Interchange

 A character is represented by 7 binary digits

 Total of 128 characters in ASCII character set

 A additional bit, known as parity-bit, in left most

position, is used to detect single bit error during

data transfer

Trang 8

Examples of ASCII Characters

Char ASCII Char ASCII Char ASCII Char ASCII

Trang 9

Structure of Main Memory (1)

 Main memory is divided into locations, each of which

has a unique address

 Each location (an addressable unit) contains a

memory word

 A memory word is a group of bits in memory,

representing data or an instruction

 Memory word’s length is the number of bits can be

stored at one location

 Word’s length can be different, depending on

computer architecture (4, 8, 16, 32 or 64 bits)

Trang 10

Structure of Main Memory (2)

 Large words may be composed of smaller

units called byte, which is 8-bit length

 Example: structure of 16-bit word

High order byte Low order byte

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Trang 11

Internal Numbers

 Numbers are represented by bits

 An n-bit number has range from 0 2n – 1

 1-bit: 2 values 0 and 1

 1 byte: from 0 to 2 8 - 1(255)

 2 bytes: 0 to 216 -1 (65535)

Trang 12

Representation of Signed Integers

 Sign-magnitude

 Use the MSB as a sign bit

 The inverse of a number formed by

complementing each bit (0->1 and 1->0)

 One’s complement of a number add 1

Trang 13

Sign and Magnitude

 Used in early computers

 Sign and magnitude of

Trang 15

Two’s Complement

• N-bit two’s complement

number in the range: -2N-1

Trang 16

Arithmetic Operations: Addition

 No need for special processing

Trang 17

Arithmetic Operations: Subtraction

 Direct subtraction can be used

 Or negate the subtrahend and perform

addition

Trang 18

Arithmetic Overflow

 Overflow happens when result of an

arithmetic operation is larger than the range permitted by a word

 Can be detected by comparing the two right

most carry bits

Trang 20

Fixed-point Representation

 Fixed-point numbers use conventional formats

 The binary point can be placed any position within

a memory word by the programmer

 Not commonly used

Integer part Fractional part

Integer part Fractional part

Trang 21

Floating-point Representation

 Represented in the form: m × re

 m: mantissa, can be positive or negative

Trang 22

Storage of Floating Point Numbers

 The length of mantissa determines the precision of

a number

 The exponent determines the range, the length

usually one-third or one-half of the mantissa

 The binary point is immediately to the right of the

sign bit

sign

Mantissa (fraction) Exponent (int)

bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Trang 23

Positive and Negative Floating-point Forms – using Two’s Complement

 Positive form: the most significant digit to the right of

binary point is 1, the sign bit is 0

 Negative form: the most significant digit to the right of

binary point is 0, the sign bit is 1

 If the most significant digit and the sign-bit is the same,

the number needs to be normalised

Positive floating form

12 bits 4 bits 0.1********** ****

mantissa exponent

Negative floating form

12 bits 4 bits 1.0********** ****

mantissa exponent

Trang 24

Double Precision Numbers

 Using two contiguous memory words for

storing a number to increase precision

Trang 25

Computer Logic

 Boolean variables

 Have two values: 0 or 1

 Boolean operations

Trang 26

(Not Xor)

Trang 27

1 0

x x

Truth table

Trang 30

XOR (Exclusive OR) Operation

Trang 31

Summary

XOR OR

AND NOT

0 1

1 0

1 1

1 1

0 1

0 1

1 1

0 0

1 0

0 0

0 1

0 0

x xor y

x or y

x and y not y

y x

Trang 32

Laws of Boolean Algebra

 A Boolean expression

 A = X.Y.Z + X.Y.Z + X.Y.Z

 Laws:

 X + Y = Y + X; X.Y = Y.X

 X + (Y+Z) = (X + Y) + Z; X.(Y.Z) = (X.Y).Z

 X.(Y+Z) = X.Y + X.Z; X + Y.Z = (X+Y).(X+Z)

 (X+Y)=X.Y; X.Y = X + Y

 X + X.Y = X ; X.(X+Y) = Y

 X + X = X; X.X = X

Trang 34

Gates (2)

 Gates are basic electronic components can

be used to perform logical and arithmetic

Trang 35

Circuit Logic Using Gates

 Logic circuits can be built from gates based

directly on Boolean expressions

A

B

C

A.(B+C)

Trang 36

An Application of Logic Gates

 Half adder circuit: perform addition operation

for 2 binary digits

 Full adder circuit can add 3 binary digits

 Two numbers of larger numbers of digits

can be added by using a combination of full adder circuits

Trang 37

Half Adder Circuit

Half adder y

S C

C

1 0

1 1

0 1

0 1

0 1

1 0

0 0

0 0

C S

y x

AND XOR

AND XOR

Trang 38

Full Adder Circuit

Full adder y

S

C x

Trang 39

Mạch cộng toàn phần (tt.)

Half adder

S

Half adder y

Trang 40

Full adder (2)

1 0

1 0

1 1

1 1

1 1

1 1

0 1

1 1

0 0

1 1

1 1

0 1

1 1

0 1

0 1

0 0

0 0

1 0

1 0

0 1

1 0

1 0

0 1

0 1

1 0

0 0

0 1

0 0

1 0

1 0

0 0

0 1

0 0

1 1

0 0

0 0

0 0

0 0

0 0

0 0

S y

x

C 0

Trang 41

adder

Trang 42

Adding Multiple Bits

Full adder 1

Full adder 2

Full

x 3 x 2 x 1 x 0

C S 3 S 2 S 1 S 0

y 3 y 2 y 1 y 0 +

Ngày đăng: 30/01/2020, 14:19