Computer Organization and Assembly Language. Lab Session 01

Similar documents
ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

Course Syllabus [1/2]

ALT-Assembly Language Tutorial

Computer Organization and Assembly Language CSC-210

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Chapter 1 Preliminaries

MACHINE LEVEL REPRESENTATION OF DATA

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

2.2 THE MARIE Instruction Set Architecture

Number representations

Number System. Introduction. Decimal Numbers

BINARY SYSTEM. Binary system is used in digital systems because it is:

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

LAB WORK NO. 3 TURBO DEBUGGER ENVIRONMENT

Module 1: Information Representation I -- Number Systems

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

Memory Addressing, Binary, and Hexadecimal Review

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Basic Concepts COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

Objectives. Connecting with Computer Science 2

SECTION 3 ASSEMBLY LANGUAGE PROGRAMMING

Computer Organization

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

EXPERIMENT 1. FAMILIARITY WITH DEBUG, x86 REGISTERS and MACHINE INSTRUCTIONS

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

COMP Overview of Tutorial #2

EXPERIMENT NO: 01. Write a program to convert decimal number to binary and vice versa.

Modesto Junior College Course Outline of Record CMPSC 241

Computer Organization and Assembly Language. Lab Session 3

Final Labs and Tutors

Internal Data Representation

CS & IT Conversions. Magnitude 10,000 1,

Chapter 2 Number System

Chapter 12. Microcontroller Application Development Tools

Harry H. Porter, 2006

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine

Assembler Language "Boot Camp" Part 1 - Numbers and Basic Arithmetic SHARE in San Francisco August 18-23, 2002 Session 8181

The type of all data used in a C++ program must be specified

LAB WORK NO. 2 THE INTERNAL DATA REPRESENTATION

2010 Summer Answers [OS I]

Agenda EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 1: Introduction. Go over the syllabus 3/31/2010

Ethical Hacking. Assembly Language Tutorial

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

Assembler Language "Boot Camp" Part 1 - Numbers and Basic Arithmetic. SHARE 117 in Orlando Session 9210 August 8, 2011

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Level ISA3: Information Representation

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Assembler Language "Boot Camp" Part 1 - Numbers and Basic Arithmetic SHARE 115 in Boston August 1-5, 2010

Run time environment of a MIPS program

Digital Computers and Machine Representation of Data

Introduction to Numbering Systems

EE292: Fundamentals of ECE

Fundamentals of Programming Session 2

Week 1. Introduction to Microcomputers and Microprocessors, Computer Codes, Programming, and Operating Systems

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

Information Science 1

IBM PC Hardware CPU 8088, Pentium... ALU (Arithmetic and Logic Unit) Registers. CU (Control Unit) IP.

Constants and Expressions. Lecture 7: Assembly Language Programs. Constants and Expressions (cont.) Statements. Names. Assembly Directives

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

User. Application program. Interfaces. Operating system. Hardware

ENE 334 Microprocessors

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Numbers and Representations

Computer Organization and Assembly Language. Lab Session 4

Assembly Language programming (1)

Lab 2: Introduction to Assembly Language Programming

Number Systems. Both numbers are positive

Ms Sandhya Rani Dash UNIT 2: NUMBER SYSTEM AND CODES. 1.1 Introduction

EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

ORG ; TWO. Assembly Language Programming

Internal architecture of 8086

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Chapter 4: Computer Codes. In this chapter you will learn about:

THE LOGIC OF COMPOUND STATEMENTS

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

History of Computing. Ahmed Sallam 11/28/2014 1

Chapter 1. Hardware. Introduction to Computers and Programming. Chapter 1.2

CS311 Lecture: The Architecture of a Simple Computer

COS 140: Foundations of Computer Science

1. Introduction to Assembly Language

Introduction to Computer Science (I1100) With 1 coin 2 possibilities: Head / Tail or 0/1

Beyond Base 10: Non-decimal Based Number Systems

11. A Computing Machine

Basic data types. Building blocks of computation

Transcription:

Objective: Lab Session 01 Introduction to Assembly Language Tools and Familiarization with Emu8086 environment To be able to understand Data Representation and perform conversions from one system to another Theory: Introduction to Assembly Language Tools Software tools are used for editing, assembling, linking, and debugging assembly language programming. You will need an assembler, a linker, a debugger, and an editor. These tools are briefly explained below. Assembler An assembler is a program that converts source-code programs written in assembly language into object files in machine language. Popular assemblers have emerged over the years for the Intel family of processors. These include MASM (Macro Assembler from Microsoft), TASM (Turbo Assembler from Borland), NASM (Netwide Assembler for both Windows and Linux), and GNU assembler distributed by the free software foundation. Linker A linker is a program that combines your program's object file created by the assembler with other object files and link libraries, and produces a single executable program. Debugger A debugger is a program that allows you to trace the execution of a program and examine the content of registers and memory. Editor You need a text editor to create assembly language source files. You can use NotePad, or any other editor that produces plain ASCII text files. Emu8086 Emu8086 combines an advanced source editor, assembler, disassemble and software emulator (Virtual PC) with debugger. It compiles the source code and executes it on emulator step by step. Visual interface is very easy to work with. You can watch registers, flags and memory while your program executes. Arithmetic & Logical Unit (ALU) shows the internal work of the central processor unit (CPU). Emulator runs programs on a Virtual PC, this completely blocks your program from accessing real hardware, such as hard-drives and memory, since your assembly code runs on a virtual machine, this makes debugging much easier. 8086 machine code is fully compatible with all next generations of Intel's microprocessors, including Pentium II and Pentium 4. This makes 8086 code very portable, since it runs both on ancient and on the modern computer systems. Another advantage of 8086 instruction set is that it is much smaller, and thus easier to learn. EMU8086 Source Editor The source editor of EMU86 is a special purpose editor which identifies the 8086

mnemonics, hexadecimal numbers and labels by different colors as seen in Figure 1. Figure:1 The compile button on the taskbar starts assembling and linking of the source file. A report window is opened after the assembling process is completed. Figure 2 shows the emulator of 8086 which gets opened by clicking on emulate button. Figure 2 Data Representation Before going into the details of assembly language programming, it is important that you master skills and develop fluency about data representation. Computer data can be represented in a variety of ways. We will examine the content of memory and registers at the machine level. We will use the binary, decimal, and hexadecimal number systems. Decimal System Most people today use decimal representation to count. In the decimal system there are 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 These digits can represent any value, for example: 754.

The value is formed by the sum of each digit, multiplied by the base (in this case it is 10 because there are 10 digits indecimal system) in power of digit position (counting from zero): Position of each digit is very important! for example if you place "7" to the end: 547 it will be another value: Important note: any number in power of zero is 1, even zero in power of zero is 1: Binary System Computers are not as smart as humans are (or not yet), it's easy to make an electronic machine with two states: on and off, or 1 and 0. Computers use binary system, binary system uses 2 digits: 0, 1 And thus the base is 2. Each digit in a binary number is called a BIT, 4 bits form a NIBBLE, 8 bits form a BYTE, two bytes form a WORD, two words form a DOUBLE WORD (rarely used): There is a convention to add "b" in the end of a binary number, this way we can determine that 101b is a binary number with decimal value of 5. The binary number 10100101b equals to decimal value of 165:

Hexadecimal System Hexadecimal System uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F And thus the base is 16. Hexadecimal numbers are compact and easy to read. There is a convention to add "h" in the end of a hexadecimal number, this way we can determine that 5Fh is a hexadecimal number with decimal value of 95. We also add "0" (zero) in the beginning of hexadecimal numbers that begin with a letter (A..F), for example 0E120h. The hexadecimal number 1234h is equal to decimal value of 4660: It is very easy to convert numbers from binary system to hexadecimal system and vice-versa, every nibble (4 bits) can be converted to a hexadecimal digit using this table:

Signed Integers: 2 s Complement Notation In mathematics, the negative of a number n is the value when added to n produces zero. For example: 3 + ( 3) = 0. Programs often include both subtraction and addition operations. However, the CPU only performs addition internally. When subtracting A B, the CPU performs A + (-B). For example, to subtract 6 4, the CPU does 6 + (-4). When working with binary numbers, how does the CPU compute the negative of a number? The answer is that the CPU computes the 2 s complement. The 2 s complement is the negative of a number. For example, consider the following 8-bit binary number: 00010110, which is equal to 22 in decimal. The 2 s complement is obtained by reversing each bit of a binary number (called the 1 s complement) and then adding 1. For example, 2 s complement of 00010110 = 11101001 (1 s complement) + 1 = 11101010 The carry is 1, but it is ignored, since we are representing the number in 8 bits Since 00010110 in binary = 22 in decimal, then 11101010 in binary = -22 in decimal Procedure: (a) Use Emu8086 to make the following calculations: 10100101b =? d 1234h =? d 39d =? h 1. Start Emu8086 by selecting its icon from the start menu, or by running Emu8086.exe 3. Choose Math and specify Base Convertor in emu8086. 4. Enter one of the numbers like in the Figure below

5. Do the calculations manually and compare with the results produced by base converter. (b) Find out the largest positive 8-bit value in binary, hexadecimal, and decimal? (c) Find out the smallest negative 8-bit value in binary, hexadecimal, and decimal? (d) Find out the largest positive 16-bit value in binary, hexadecimal, and decimal? (e) Find out the smallest negative 16-bit value in binary, hexadecimal, and decimal? --------------------------------------------------------------------------------------------------------------------------- Exercise: 1. Name four software tools used for assembly language programming.

2. What is an Emulator? 3. Convert the following numbers using Base Converter: a) 10110011b (binary to hexadecimal) b) 455d (decimal to binary) c) 2AFh (hexadecimal to binary) d) 0A1h (hexadecimal to binary) Do all the calculations manually and compare with the results obtained using base converter. 4. Write each of the following Integers in 8-bit 2 s Complement Notation: a) -1 = d) -62 = b) -17 = e) +127 = c) -19 = f) -128 = 5. Write each of the following 8-bit Signed Binary Integers in Decimal: a) 01011100 = d) 01111110 = b) 11011100 = e) 10010001 = c) 10001111 = f) 10000000 = 6. Indicate the sign for each of the following 16-bit signed hex integers: a) 7FB9 c) 8123 b) D000 d) 6FFF