1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.

Slides:



Advertisements
Similar presentations
Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Advertisements

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
ICS312 Set 2 Representation of Numbers and Characters.
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
Basic Concepts COE 205 Computer Organization and Assembly Language
Data Representation Computer Organization &
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Data Representation COE 205
Chapter 3 Data Representation.
Introduction to Programming with Java, for Beginners
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Data Representation ICS 233
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
Basic Concepts Computer Organization and Assembly Language.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
Codes and number systems Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken ( ) and Harris & Harris (DDCA)
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this slide show for your personal use, or for.
Programmable Logic Controllers
Computers Organization & Assembly Language
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
ACOE2511 ACOE251/AEEC335 -Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas.
Chapter 1: Basic Concepts
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ICS312 Set 1 Representation of Numbers and Characters.
Assembly Language for x86 Processors 7 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
CPU Internal memory I/O interface circuit System bus
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
1 Introduction Chapter 1 CSI 2121 Lecture Notes Written by Mario Marchand
EET 250 Number systems. Introduction to Number Systems While we live in a world where the decimal number is predominant in our lives, computers and digital.
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
ACOE2511 Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Computer Organization and Assembly Languages 2007/11/10
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
1 Chapter 1: Introduction Appendix A: Binary and Hexadecimal Tutorial Assembly Language for Intel-Based Computers, 3rd edition Kip R. Irvine.
1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.
Data Representation COE 308 Computer Architecture
Data Representation ICS 233
Lec 3: Data Representation
Assembly Language for x86 Processors 6th Edition
Data Representation.
Assembly Language (CSW 353)
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor and Assembly Language
Assembly Language for x86 Processors 6th Edition
Data Representation COE 301 Computer Organization
Chapter One: Introduction
Computer Organization and Assembly Language
Data Representation ICS 233
Part I Data Representation and 8086 Microprocessors
Data Representation COE 308 Computer Architecture
Presentation transcript:

1 Introduction Chapter 1 n What is Assembly Language? n Data Representation

2 Table 1. Software Hierarchy Levels LevelDescription Application Program Software designed for a particular class of applications High-Level Language (HLL) Programs are compiled into either assembly language or machine language. E.g. C++, Pascal, Java, Visual Basic, etc. Operating Systems Contains procedures than can be called from programs written in either high-level language or assembly language. This system may also contain an application programming interface (API). Assembly Language (ASM) Uses instruction mnemonics that have a one-to-one correspondence with machine language. Machine Language (ML) Numeric instructions and operands that can be stored in memory and directly executed by the computer processor.

3 What is Assembly Language? n A low-level processor- specific programming language design to match the processor’s machine instruction set n each assembly language instruction matches exactly one machine language instruction n we study here Intel’s 80x86 (and Pentiums)

4 Why learn Assembly Language? n To learn how high-level language code gets translated into machine language u i.e.: to learn the details hidden in HLL code n To learn the computer’s hardware u by direct access to memory, video controller, sound card, keyboard… n To speed up applications u direct access to hardware (ex: writing directly to I/O ports instead of doing a system call) u good ASM code is faster and smaller: rewrite in ASM the critical areas of code

5 Assembly Language Applications n Application programs are rarely written completely in assembly language u only time-critical parts are written in ASM F Ex: an interface subroutine (called from HLL programs) is written in ASM for direct hardware access F Ex2: device drivers (called from the OS) n ASM often used for embedded systems (programs stored in PROM chips) F computer cartridge games, microcontrollers (automobiles, industrial plants...), telecommunication equipment… n Very fast and compact but processor-specific

6 Table 2. Comparison of Assembly Language and High-Level Languages Type of ApplicationsHigh-Level LanguageAssembly Language Business application software for single platform. Formal structures make it easy to organize and maintain. No formal structure. Hardware device driver. Awkward coding techniques required. Hardware access is straightforward and simple. Business application for multiple platforms. Portable.Difficult to maintain. Embedded systems and computer games requiring direct hardware access. Produces too much executable code, and may not run efficiently. Ideal, because the executable code is small and runs quickly.

7 Machine Language n An assembler is a program that converts ASM code into machine language code:  mov al,5 (Assembly Language) u (Machine Language) F most significant byte is the opcode for “move into register AL” F the least significant byte is for the operand “5” n Directly programming in machine language offers no advantage (over Assembly)...

8 Binary Numbers/Storage Size n are used to store both code and data n On Intel’s x86: u byte = 8 bits (smallest addressable unit) u word = 2 bytes u doubleword = 2 words u quadword = 2 doublewords

9 Data Representation n Even if we know that a block of memory contains data, to obtain its value we need to choose an interpretation n Ex: memory content “ ” can either represent: u the number 2^{6} + 1 = 65 u or the ASCII code of character “A”

10 Data Representation n Number Systems u Binary/Octal/Decimal/Hexadecimal u Converting between various number systems n Signed/Unsigned Interpretation u Two’s Complement n Addition/Subtraction n Character Storage

11 Number Systems n A written number is meaningful only with respect to a base n To tell the assembler which base we use: u Hexadecimal 25 is written as 25h u Octal 25 is written as 25o or 25q u Binary 1010 is written as 1010b u Decimal 1010 is written as 1010 or 1010d n You are supposed to know how to convert from one base to another (see appendix A)

12 Binary Numbers n Digits are 1 and 0 u 1 = true u 0 = false n MSB – most significant bit n LSB – least significant bit n Bit numbering:

13 Converting between various number systems n Converting Binary to Decimal n Converting Decimal to Binary n Converting Binary to Hexadecimal n Converting Hexadecimal to Decimal

14 Signed and Unsigned Interpretation n When a memory block contains a number, to obtain its value we must choose either: u the signed interpretation: in that case the most significant bit (msb) represents the sign F Positive number (or zero) if msb = 0 F Negative number if msb = 1 u the unsigned interpretation: in that case all the bits are used to represent a magnitude (ie: positive number, or zero)

15 Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive If the highest digit of a hexadecimal integer is > 7, the value is negative. Examples: 8A, C5, A2, 9D

16 Two’s Complement Notation n Used to represent negative numbers n The twos complement of a positive number X, denoted by NEG(X), is obtained by complementing all its bits and adding +1 n NEG(X) = NOT(X) + 1 u Ex: NEG(10) = NOT(10) + 1 u = NOT( b) + 1 u = ( b) + 1 = b = NEG(10) = -10 n It follows that X + NEG(X) = 0

17 Forming the Two's Complement n Negative numbers are stored in two's complement notation n Represents the additive Inverse Note that =

18 Binary Subtraction n To perform the difference X - Y: u the machine executes the addition X + NEG(Y) – Practice: Subtract 0101 from 1001.

19 Maximum and Minimum Values n The msb of a signed number is used for its sign u fewer bits are left for its magnitude n Ex: for a signed byte u smallest positive = b u largest positive = b = 127 u largest negative = -1 = b u smallest negative = b = -128

20 Ranges of Unsigned Integers What is the largest unsigned integer that may be stored in 20 bits? Standard sizes:

21 Ranges of Signed Integers The highest bit is reserved for the sign. This limits the range: Practice: What is the largest positive value that may be stored in 20 bits?

22 Signed/Unsigned Interpretation (again) n To obtain the value of a number we need to chose an interpretation n Ex: memory content can either represent: u -1 if a signed interpretation is used u 255 if an unsigned interpretation is used n Only the programmer can provide an interpretation of the content of memory

23 Character Storage Systems n Character sets u Standard ASCII (0 – 127) u Extended ASCII (0 – 255) u ANSI (0 – 255) u Unicode (0 – 65,535) n Null-terminated String u Array of characters followed by a null byte

24 ASCII vs Extended ASCII n The ASCII code (from 00h to 7Fh) u Only codes from 20h to 7Eh represent printable characters. The rest are control codes (used for printing, transmission…). n Extended ASCII character set (codes 80h to FFh) u Varies from one system to another F MS-DOS usage: for accentuated characters, Greek symbols and some graphic characters

25 The ASCII character set n CR = “carriage return” (MSDOS: move to beginning of line) n LF = “line feed” (MSDOS: move directly one line below) n SPC = “blank space”

26 Text Files n These are files containing only ASCII characters n But different conventions are used for indicating an “end-of line” u MS-DOS: + u UNIX: u MAC: n This is at the origin of many problems encountered during transfers of text files from one system to another

27 Strings and numbers n A strings is stored as an array of characters n A 1-byte ASCII code is stored for each char n Hence, we can either store the number 123 in numerical form or as the string “123” u The string form is best for display u The numerical form is best for computations