Top Banner
Skill Area 311 Part A
25

Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Dec 30, 2015

Download

Documents

Anne Strickland
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Skill Area 311 Part A

Page 2: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Lecture Overview• Binary Numbers• Binary Arithmetic• ASCII Code• Machine Code• Instruction Format• Advantages and disadvantages

of machine code

Page 3: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

BINARY NUMBERS

Page 4: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

What is “Binary”?• A coding system using binary

digits 0 and 1• Represent a letter, digit or other

character in a computer or other electronic devices

0 1OFF ON

Page 5: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

You Do The MathWhen we talk numbers, we use a base-10 system, because we use ten characters to write out all of our numbers. • Computers using

binary language operate on a base-2 number system, because the two numbers they use are “0” and “1”.

0 1 2 3 4 5 6 7 8 9

0 1

Each is a binary digit or “bit”Each bit represents a power of two (22, 23, 24,etc)

Page 6: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Alphabet

Our class uses the English language consisting of 26 characters, arranged together in a variety of ways, to communicate. • Computers use

binary language consisting of 2 characters, arranged together in groups of eight, to communicate.

Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll MmNn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz

Aa = 01000001 01100001Zz = 01011010 01111010

8 bits = 1 byte

Page 7: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

The Byte Scale

Page 8: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Binary Arithmetic• Binary to Decimal(denary):

Binary 1 0 1 1 0

Power of Two 24 23 22 21 20

16 8 4 2 1

Binary x Power of Two

16 0 4 2 0

Result 16+0+4+2+0

= 22

Page 9: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Binary Arithmetic• Decimal (denary) to Binary:

Number Divide By Result Remainder

23 2 11 1

11 2 5 1

5 2 2 1

2 2 1 0

1 2 0 1

Read from bottom to top

Result =10111

Page 10: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Binary Arithmetic• Decimal Addition

• Binary Addition

22+ 23 45

10110 + 10111 101101 • 0 plus 0 produces 0

• 0 plus 1 produces 1• 1 plus 1 produces 0 with a ‘carry’ of 1

into the next most significant place• 1 plus 1 plus 1 produces 1 with a

‘carry’ of 1 into the next most significant place

Page 11: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Binary Arithmetic• Decimal Multiplication

• Binary Multiplication

5× 3 15

101 × 011 101 101 000 000 001111

Page 12: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Alphanumeric Codes• Beside Numbers, we have to

represent other types of information:– Letter of alphabet, mathematical

symbols

• American Standard Code for Information Interchange (ASCII) - 1968

Page 13: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

ASCII Code• Uses 7 bits to encode 128 characters• 7 bits of ASCII Code

– (b6 b5 b4 b3 b2 b1 b0)2

• One ASCII character is stored using a byte• One unused bit can be used for other

purposes such as representing Greek alphabet, italic type font, etc.

• The eighth bit can be used for error-detection

Page 14: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

ASCII Code• 128 different characters

– 26 + 26 + 10 = 62 (letters and decimal digits)

– 32 special printable characters %, *, $

– 34 special control characters (non-printable): BS, CR, etc.

• Example:

– A 65 = (1000001),…, a 97 = (1100001) – 0 48 = (0110000), …,9 57 = (0111001)

Page 15: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

ASCII Code

Page 16: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

ASCII Code - Extended

Page 17: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

MACHINE CODEOR

MACHINE LANGUAGE

Page 18: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

What is a “Machine Code”?• The lowest and most elementary

level of Programming Language.• 1st type of PL to be developed.• Represented inside the computer by

a String of binary digits (bits) 0 and 1.• The symbol 0 stands for the absence

of Electric Pulse and 1 for the presence of an electric pulse.

Page 19: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Why “Machine Code”?• Their order tells the computer

what to do.• All other kinds of software need

to be translated into machine code before they can be used.

Page 20: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Instruction Format• Each instruction is a number

that combines:– An operation code (opcode) that

picks a hardware function– One or two input operands (where

input comes from)– One output operand (where result

goes)

Page 21: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Opcode and operand• An opcode identifies which basic

computer operation in the instruction set is to be performed. It tells the computer to do something.

• Operands are typically memory or registry addresses.

• Opcode is like a verb in a sentence, operands are like the subject in a sentence.

Page 22: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Machine Code Instruction

LD, A, numberLoad A with

number. A stands for “accumulator” and LD is short for “load”

Load A with number. A stands for “accumulator” and LD is short for “load”

Opcodes and operands are separated by commas

Opcodes and operands are separated by commas

Page 23: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Advantages of Machine Code• Makes fast and efficient use of

the computer• Requires no translator to

translate the code i.e. directly understood by the computer

Page 24: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Disadvantages of Machine Code• All operations codes have to be

remembered• All memory addresses have to be

remembered• It is hard to amend or find errors in

a program written in the machine language

• These languages are machine dependent

Page 25: Skill Area 311 Part A. Lecture Overview Binary Numbers Binary Arithmetic ASCII Code Machine Code Instruction Format Advantages and disadvantages of machine.

Summary• Binary Numbers:

– Binary digits 0 and 1– 8 bits = 1 byte

• ASCII:– 7 bits– 128 characters, 255 with extended

• Machine Code• Opcode and operand