# MACHINE INSTRUCTIONS AND PROGRAMS

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS CHAPTER OBJECTIVES In this chapter you will learn about: Machine instructions and program execution, including branching and subroutine call and return operations Number representation and addition/subtraction in the 2 s-complement system Addressing methods for accessing register and memory operands Assembly language for representing machine instructions, data, and programs Program-controlled Input/Output operations Operations on stack, queue, list, linked-list, and array data structures 25

3 2. NUMBERS, ARITHMETIC OPERATIONS, AND CHARACTERS NUMBERS, ARITHMETIC OPERATIONS, AND CHARACTERS Computers are built using logic circuits that operate on information represented by twovalued electrical signals (see Appendix A). We label the two values as and ; and we define the amount of information represented by such a signal as a bit of information, where bit stands for binary digit. The most natural way to represent a number in a computer system is by a string of bits, called a binary number. A text character can also be represented by a string of bits called a character code. We will first describe binary number representations and arithmetic operations on these numbers, and then describe character representations. 2.. NUMBER REPRESENTATION Consider an n-bit vector B = b n...b b where b i = orfor i n. This vector can represent unsigned integer values V in the range to 2 n, where V (B) = b n 2 n + +b 2 + b 2 We obviously need to represent both positive and negative numbers. Three systems are used for representing such numbers: Sign-and-magnitude s-complement 2 s-complement In all three systems, the leftmost bit is for positive numbers and for negative numbers. Figure 2. illustrates all three representations using 4-bit numbers. Positive values have identical representations in all systems, but negative values have different representations. In the sign-and-magnitude system, negative values are represented by changing the most significant bit (b 3 in Figure 2.) from to in the B vector of the corresponding positive value. For example, +5 is represented by, and 5 is represented by. In s-complement representation, negative values are obtained by complementing each bit of the corresponding positive number. Thus, the representation for 3 is obtained by complementing each bit in the vector to yield. Clearly, the same operation, bit complementing, is done in converting a negative number to the corresponding positive value. Converting either way is referred to as forming the s-complement of a given number. The operation of forming the s-complement of a given number is equivalent to subtracting that number from 2 n, that is, from in the case of the 4-bit numbers in Figure 2.. Finally, in the 2 s-complement system, forming the 2 s-complement of a number is done by subtracting that number from 2 n.

4 28 CHAPTER 2 MACHINEINSTRUCTIONS AND PROGRAMS B b 3 b 2 b b Values represented Sign and magnitude s complement 2 s complement Figure 2. Binary, signed-integer representations. Hence, the 2 s-complement of a number is obtained by adding to the s-complement of that number. Note that there are distinct representations for + and in both the sign-andmagnitude and s-complement systems, but the 2 s-complement system has only one representation for. For 4-bit numbers, the value 8 is representable in the 2 scomplement system but not in the other systems. The sign-and-magnitude system seems the most natural, because we deal with sign-and-magnitude decimal values in manual computations. The s-complement system is easily related to this system, but the 2 scomplement system seems unnatural. However, we will show in Section 2..3 that the 2 s-complement system yields the most efficient way to carry out addition and subtraction operations. It is the one most often used in computers ADDITION OF POSITIVE NUMBERS Consider adding two -bit numbers. The results are shown in Figure 2.2. Note that the sum of and requires the 2-bit vector to represent the value 2. We say that the sum is and the carry-out is. In order to add multiple-bit numbers, we use a method analogous to that used for manual computation with decimal numbers. We add bit pairs starting from the low-order (right) end of the bit vectors, propagating carries toward the high-order (left) end.

6 3 CHAPTER 2 MACHINEINSTRUCTIONS AND PROGRAMS N 2 N 2 (a) Circle representation of integers mod N (b) Mod 6 system for 2 s-complement numbers Figure 2.3 Modular number systems and the 2 s-complement system. Note that if we ignore the carry-out from the fourth bit position in this addition, we obtain the correct answer. In fact, this is always the case. Ignoring this carry-out is a natural result of using mod N arithmetic. As we move around the circle in Figure 2.3b, the value next to would normally be. Instead, we go back to the value. We now state the rules governing the addition and subtraction of n-bit signed numbers using the 2 s-complement representation system.. To add two numbers, add their n-bit representations, ignoring the carry-out signal from the most significant bit (MSB) position. The sum will be the algebraically correct value in the 2 s-complement representation as long as the answer is in the range 2 n through +2 n.

7 2. NUMBERS, ARITHMETIC OPERATIONS, AND CHARACTERS 3 2. To subtract two numbers X and Y, that is, to perform X Y, form the 2 scomplement of Y and then add it to X, as in rule. Again, the result will be the algebraically correct value in the 2 s-complement representation system if the answer is in the range 2 n through +2 n. Figure 2.4 shows some examples of addition and subtraction. In all these 4-bit examples, the answers fall into the representable range of 8 through +7. When answers do not fall within the representable range, we say that arithmetic overflow has occurred. The next section discusses such situations. The four addition operations (a) through (d) in Figure 2.4 follow rule, and the six subtraction operations (e) through ( j) follow rule 2. The subtraction operation requires the subtrahend (the bottom value) to be (a) + ( + 2) ( + 3) (b) + ( + 4) ( 6) ( + 5) ( 2) (c) + ( 5) ( 2) (d) + ( + 7) ( 3) ( 7) ( + 4) (e) ( 3) ( 7) + ( + 4) (f) ( + 2) ( + 4) + ( 2) (g) ( + 6) ( + 3) + ( + 3) (h) ( 7) ( 5) + ( 2) (i) ( 7) ( + ) + ( 8) (j) ( + 2) ( 3) + ( + 5) Figure s-complement add and subtract operations.

10 34 CHAPTER 2 MACHINEINSTRUCTIONS AND PROGRAMS n bits first word second word i-th word last word Figure 2.5 Memory words. 32 bits b 3 b 3 b b Sign bit: b 3 = for positive numbers b 3 = for negative numbers (a) A signed integer 8 bits 8 bits 8 bits 8 bits ASCII character ASCII character ASCII character ASCII character (b) Four characters Figure 2.6 Examples of encoded information in a 32-bit word.

14 38 CHAPTER 2 MACHINEINSTRUCTIONS AND PROGRAMS names for the addresses of memory locations may be LOC, PLACE, A, VAR2; processor register names may be R, R5; and I/O register names may be DATAIN, OUTSTATUS, and so on. The contents of a location are denoted by placing square brackets around the name of the location. Thus, the expression R [LOC] means that the contents of memory location LOC are transferred into processor register R. As another example, consider the operation that adds the contents of registers R and R2, and then places their sum into register R3. This action is indicated as R3 [R] + [R2] This type of notation is known as Register Transfer Notation (RTN). Note that the right-hand side of an RTN expression always denotes a value, and the left-hand side is the name of a location where the value is to be placed, overwriting the old contents of that location ASSEMBLY LANGUAGE NOTATION We need another type of notation to represent machine instructions and programs. For this, we use an assembly language format. For example, an instruction that causes the transfer described above, from memory location LOC to processor register R, is specified by the statement LOC,R The contents of LOC are unchanged by the execution of this instruction, but the old contents of register R are overwritten. The second example of adding two numbers contained in processor registers R and R2 and placing their sum in R3 can be specified by the assembly language statement Add R,R2,R BASIC INSTRUCTION TYPES The operation of adding two numbers is a fundamental capability in any computer. The statement C = A + B in a high-level language program is a command to the computer to add the current values of the two variables called A and B, and to assign the sum to a third variable, C. When the program containing this statement is compiled, the three variables, A, B, and C, are assigned to distinct locations in the memory. We will use the variable names to refer to the corresponding memory location addresses. The contents of these locations represent the values of the three variables. Hence, the above high-level language

17 2.4 INSTRUCTIONS AND INSTRUCTION SEQUENCING 4 processor. Because the number of registers is relatively small, only a few bits are needed to specify which register takes part in an operation. For example, for 32 registers, only 5 bits are needed. This is much less than the number of bits needed to give the address of a location in the memory. Because the use of registers allows faster processing and results in shorter instructions, registers are used to store data temporarily in the processor during processing. Let Ri represent a general-purpose register. The instructions Load A,Ri Store Ri,A and Add A,Ri are generalizations of the Load, Store, and Add instructions for the single-accumulator case, in which register Ri performs the function of the accumulator. Even in these cases, when only one memory address is directly specified in an instruction, the instruction may not fit into one word. When a processor has several general-purpose registers, many instructions involve only operands that are in the registers. In fact, in many modern processors, computations can be performed directly only on data held in processor registers. Instructions such as Add Ri,R j or Add Ri,R j,rk are of this type. In both of these instructions, the source operands are the contents of registers Ri and R j. In the first instruction, R j also serves as the destination register, whereas in the second instruction, a third register, Rk, is used as the destination. Such instructions, where only register names are contained in the instruction, will normally fit into one word. It is often necessary to transfer data between different locations. This is achieved with the instruction Source,Destination which places a copy of the contents of Source into Destination. When data are moved to or from a processor register, the instruction can be used rather than the Load or Store instructions because the order of the source and destination operands determines which operation is intended. Thus, A,Ri is the same as Load A,Ri and Ri,A

19 2.4 INSTRUCTIONS AND INSTRUCTION SEQUENCING 43 Address Contents Begin execution here i i + 4 i + 8 Add A,R B,R R,C 3-instruction program segment A B Data for the program C Figure 2.8 A program for C [A] + [B]. Let us consider how this program is executed. The processor contains a register called the program counter (PC), which holds the address of the instruction to be executed next. To begin executing a program, the address of its first instruction (i in our example) must be placed into the PC. Then, the processor control circuits use the information in the PC to fetch and execute instructions, one at a time, in the order of increasing addresses. This is called straight-line sequencing. During the execution of each instruction, the PC is incremented by 4 to point to the next instruction. Thus, after the instruction at location i + 8 is executed, the PC contains the value i + 2, which is the address of the first instruction of the next program segment. Executing a given instruction is a two-phase procedure. In the first phase, called instruction fetch, the instruction is fetched from the memory location whose address is in the PC. This instruction is placed in the instruction register (IR) in the processor. At the start of the second phase, called instruction execute, the instruction in IR is examined to determine which operation is to be performed. The specified operation is then performed by the processor. This often involves fetching operands from the memory or from processor registers, performing an arithmetic or logic operation, and storing the result in the destination location. At some point during this two-phase procedure, the contents of the PC are advanced to point to the next instruction. When the execute phase of an instruction is completed, the PC contains the address of the next instruction, and a new instruction fetch phase can begin. In most processors, the

21 2.4 INSTRUCTIONS AND INSTRUCTION SEQUENCING 45 Program loop LOOP N,R Clear R Determine address of "Next" number and add "Next" number to R Decrement R Branch> LOOP R,SUM SUM N NUM NUM2 n NUMn Figure 2. Using a loop to add n numbers. the next list entry is determined, and that entry is fetched and added to R. The address of an operand can be specified in various ways, as will be described in Section 2.5. For now, we concentrate on how to create and control a program loop. Assume that the number of entries in the list, n, is stored in memory location N, as shown. Register R is used as a counter to determine the number of times the loop is executed. Hence, the contents of location N are loaded into register R at the beginning of the program. Then, within the body of the loop, the instruction Decrement R reduces the contents of R by each time through the loop. (A similar type of operation is performed by an Increment instruction, which adds to its operand.) Execution of the loop is repeated as long as the result of the decrement operation is greater than zero.

22 46 CHAPTER 2 MACHINEINSTRUCTIONS AND PROGRAMS We now introduce branch instructions. This type of instruction loads a new value into the program counter. As a result, the processor fetches and executes the instruction at this new address, called the branch target, instead of the instruction at the location that follows the branch instruction in sequential address order. A conditional branch instruction causes a branch only if a specified condition is satisfied. If the condition is not satisfied, the PC is incremented in the normal way, and the next instruction in sequential address order is fetched and executed. In the program in Figure 2., the instruction Branch> LOOP (branch if greater than ) is a conditional branch instruction that causes a branch to location LOOP if the result of the immediately preceding instruction, which is the decremented value in register R, is greater than zero. This means that the loop is repeated as long as there are entries in the list that are yet to be added to R. At the end of the nth pass through the loop, the Decrement instruction produces a value of zero, and, hence, branching does not occur. Instead, the instruction is fetched and executed. It moves the final result from R into memory location SUM. The capability to test conditions and subsequently choose one of a set of alternative ways to continue computation has many more applications than just loop control. Such a capability is found in the instruction sets of all computers and is fundamental to the programming of most nontrivial tasks CONDITION CODES The processor keeps track of information about the results of various operations for use by subsequent conditional branch instructions. This is accomplished by recording the required information in individual bits, often called condition code flags. These flags are usually grouped together in a special processor register called the condition code register or status register. Individual condition code flags are set to or cleared to, depending on the outcome of the operation performed. Four commonly used flags are N (negative) Set to if the result is negative; otherwise, cleared to Z (zero) Set to if the result is ; otherwise, cleared to V (overflow) Set to if arithmetic overflow occurs; otherwise, cleared to C (carry) Set to if a carry-out results from the operation; otherwise, cleared to The N and Z flags indicate whether the result of an arithmetic or logic operation is negative or zero. The N and Z flags may also be affected by instructions that transfer data, such as, Load, or Store. This makes it possible for a later conditional branch instruction to cause a branch based on the sign and value of the operand that was moved. Some computers also provide a special Test instruction that examines

24 48 CHAPTER 2 MACHINEINSTRUCTIONS AND PROGRAMS 2.5 ADDRESSING MODES We have now seen some simple examples of assembly language programs. In general, a program operates on data that reside in the computer s memory. These data can be organized in a variety of ways. If we want to keep track of students names, we can write them in a list. If we want to associate information with each name, for example to record telephone numbers or marks in various courses, we may organize this information in the form of a table. Programmers use organizations called data structures to represent the data used in computations. These include lists, linked lists, arrays, queues, and so on. Programs are normally written in a high-level language, which enables the programmer to use constants, local and global variables, pointers, and arrays. When translating a high-level language program into assembly language, the compiler must be able to implement these constructs using the facilities provided in the instruction set of the computer in which the program will be run. The different ways in which the location of an operand is specified in an instruction are referred to as addressing modes. In this section we present the most important addressing modes found in modern processors. A summary is provided in Table 2.. Table 2. Generic addressing modes Name Assembler syntax Addressing function Immediate #Value Operand = Value Register Ri EA = Ri Absolute (Direct) LOC EA = LOC Indirect (Ri) EA = [Ri] (LOC) EA = [LOC] Index X(Ri) EA = [Ri] + X Base with index (Ri,R j) EA = [Ri] + [R j] Base with index X(Ri,R j) EA = [Ri] + [R j] + X and offset Relative X(PC) EA = [PC] + X Autoincrement (Ri)+ EA = [Ri]; Increment Ri Autodecrement (Ri) Decrement Ri; EA = [Ri] EA = effective address Value = a signed number

25 2.5 ADDRESSING MODES IMPLEMENTATION OF VARIABLES AND CONSTANTS Variables and constants are the simplest data types and are found in almost every computer program. In assembly language, a variable is represented by allocating a register or a memory location to hold its value. Thus, the value can be changed as needed using appropriate instructions. The programs in Section 2.4 used only two addressing modes to access variables. We accessed an operand by specifying the name of the register or the address of the memory location where the operand is located. The precise definitions of these two modes are: Register mode The operand is the contents of a processor register; the name (address) of the register is given in the instruction. Absolute mode The operand is in a memory location; the address of this location is given explicitly in the instruction. (In some assembly languages, this mode is called Direct.) The instruction LOC,R2 uses these two modes. Processor registers are used as temporary storage locations where the data in a register are accessed using the Register mode. The Absolute mode can represent global variables in a program. A declaration such as Integer A, B; in a high-level language program will cause the compiler to allocate a memory location to each of the variables A and B. Whenever they are referenced later in the program, the compiler can generate assembly language instructions that use the Absolute mode to access these variables. Next, let us consider the representation of constants. Address and data constants can be represented in assembly language using the Immediate mode. Immediate mode The operand is given explicitly in the instruction. For example, the instruction 2 immediate, R places the value 2 in register R. Clearly, the Immediate mode is only used to specify the value of a source operand. Using a subscript to denote the Immediate mode is not appropriate in assembly languages. A common convention is to use the sharp sign (#) in front of the value to indicate that this value is to be used as an immediate operand. Hence, we write the instruction above in the form #2,R Constant values are used frequently in high-level language programs. For example, the statement A = B + 6

### PROBLEMS (Cap. 4 - Istruzioni macchina)

98 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS PROBLEMS (Cap. 4 - Istruzioni macchina) 2.1 Represent the decimal values 5, 2, 14, 10, 26, 19, 51, and 43, as signed, 7-bit numbers in the following binary

### Unit 5 Central Processing Unit (CPU)

Unit 5 Central Processing Unit (CPU) Introduction Part of the computer that performs the bulk of data-processing operations is called the central processing unit (CPU). It consists of 3 major parts: Register

### Here 4 is the least significant digit (LSD) and 2 is the most significant digit (MSD).

Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

### Data Types and Addressing Modes 29

29 This section describes data types and addressing modes available to programmers of the Intel Architecture processors. 29.1 Fundamental Data Types The fundamental data types of the Intel Architecture

### PART OF THE PICTURE: Computer Architecture

PART OF THE PICTURE: Computer Architecture 1 PART OF THE PICTURE: Computer Architecture BY WILLIAM STALLINGS At a top level, a computer consists of processor, memory, and I/O components, with one or more

### Number Representation

Number Representation COMP375 Computer Organization and darchitecture t How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of

### Introduction Number Systems and Conversion

UNIT 1 Introduction Number Systems and Conversion Objectives 1. Introduction The first part of this unit introduces the material to be studied later. In addition to getting an overview of the material

### Data Representation. Representing Data

Data Representation COMP 1002/1402 Representing Data A computer s basic unit of information is: a bit (Binary digit) An addressable memory cell is a byte (8 bits) Capable of storing one character 10101010

### 1.3 Data Representation

8628-28 r4 vs.fm Page 9 Thursday, January 2, 2 2:4 PM.3 Data Representation 9 appears at Level 3, uses short mnemonics such as ADD, SUB, and MOV, which are easily translated to the ISA level. Assembly

### Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of

### Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine

### CPU- Internal Structure

ESD-1 Elettronica dei Sistemi Digitali 1 CPU- Internal Structure Lesson 12 CPU Structure&Function Instruction Sets Addressing Modes Read Stallings s chapters: 11, 9, 10 esd-1-9:10:11-2002 1 esd-1-9:10:11-2002

### Programming the Basic Computer. lecture 8

Programming the Basic Computer lecture 8 Programming the Basic Computer A computer system includes both hardware and software. Hardware consist of the physical components. Software refers to computer programs.

### The largest has a 0 in the sign position and 0's in all other positions:

10.2 Sign Magnitude Representation Sign Magnitude is straight-forward method for representing both positive and negative integers. It uses the most significant digit of the digit string to indicate the

### By the end of the lecture, you should be able to:

Extra Lecture: Number Systems Objectives - To understand: Base of number systems: decimal, binary, octal and hexadecimal Textual information stored as ASCII Binary addition/subtraction, multiplication

### Chapter 2: Number Systems

Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

### NUMBERING SYSTEMS C HAPTER 1.0 INTRODUCTION 1.1 A REVIEW OF THE DECIMAL SYSTEM 1.2 BINARY NUMBERING SYSTEM

12 Digital Principles Switching Theory C HAPTER 1 NUMBERING SYSTEMS 1.0 INTRODUCTION Inside today s computers, data is represented as 1 s and 0 s. These 1 s and 0 s might be stored magnetically on a disk,

### 1 Basic Computing Concepts (4) Data Representations

1 Basic Computing Concepts (4) Data Representations The Binary System 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. The

### MICROPROCESSOR AND MICROCOMPUTER BASICS

Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit

### CS 16: Assembly Language Programming for the IBM PC and Compatibles

CS 16: Assembly Language Programming for the IBM PC and Compatibles First, a little about you Your name Have you ever worked with/used/played with assembly language? If so, talk about it Why are you taking

### Chapter II Binary Data Representation

Chapter II Binary Data Representation The atomic unit of data in computer systems is the bit, which is actually an acronym that stands for BInary digit. It can hold only 2 values or states: 0 or 1, true

### COMPUTER ARCHITECTURE. ALU (2) - Integer Arithmetic

HUMBOLDT-UNIVERSITÄT ZU BERLIN INSTITUT FÜR INFORMATIK COMPUTER ARCHITECTURE Lecture 11 ALU (2) - Integer Arithmetic Sommersemester 21 Leitung: Prof. Dr. Miroslaw Malek www.informatik.hu-berlin.de/rok/ca

### Number Representation and Arithmetic in Various Numeral Systems

1 Number Representation and Arithmetic in Various Numeral Systems Computer Organization and Assembly Language Programming 203.8002 Adapted by Yousef Shajrawi, licensed by Huong Nguyen under the Creative

### In this chapter we are concerned with basic architecture and the. different operations related to explain the proper functioning of the

CHAPTER I CONTENTS: 1.1 INTRODUCTION 1.2 STORED PROGRAM ORGANIZATION 1.3 INDIRECT ADDRESS 1.4 COMPUTER REGISTERS 1.5 COMMON BUS SYSTEM SUMMARY SELF ASSESSMENT OBJECTIVE: In this chapter we are concerned

### A Closer Look at Instruction Set Architectures

00068_CH05_Null.qxd 10/13/10 1:30 PM Page 269 Every program has at least one bug and can be shortened by at least one instruction from which, by induction, one can deduce that every program can be reduced

### 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.

Digital Logic 1 Data Representations 1.1 The Binary System 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. The system we

### Binary Representation and Computer Arithmetic

Binary Representation and Computer Arithmetic The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 4. Since it involved the use of fingers

### Data types. lecture 4

Data types lecture 4 Information in digital computers is represented using binary number system. The base, i.e. radix, of the binary system is 2. Other common number systems: octal (base 8), decimal (base

### MICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1

MICROPROCESSOR A microprocessor incorporates the functions of a computer s central processing unit (CPU) on a single Integrated (IC), or at most a few integrated circuit. It is a multipurpose, programmable

### Chapter 3 DATA REPRESENTATION. 3.1 Character Representation

Chapter 3 DATA REPRESENTATION Binary codes are used to represent both characters and numbers inside computers. Moreover, the binary codes used to represent numbers must be consistent with the arithmetic

### The Assembly Language Level

The Assembly Language Level Translators can be divided into two groups. When the source language is essentially a symbolic representation for a numerical machine language, the translator is called an assembler,

### 8051 Programming. The 8051 may be programmed using a low-level or a high-level programming language.

8051 Programming The 8051 may be programmed using a low-level or a high-level programming language. Low-Level Programming Assembly language programming writes statements that the microcontroller directly

### Feature of 8086 Microprocessor

8086 Microprocessor Introduction 8086 is the first 16 bit microprocessor which has 40 pin IC and operate on 5volt power supply. which has twenty address limes and works on two modes minimum mode and maximum.

### P A R T DIGITAL TECHNOLOGY

P A R T A DIGITAL TECHNOLOGY 1 CHAPTER NUMBERING SYSTEMS 1.0 INTRODUCTION This chapter discusses several important concepts including the binary, octal and hexadecimal numbering systems, binary data organization

### appendix a The LC-3 ISA

A.1 Overview The Instruction Set Architecture (ISA) of the LC-3 is defined as follows: Memory address space 16 bits, corresponding to 2 16 locations, each containing one word (16 bits). Addresses are numbered

### Chapter 1 Basic Concepts

Chapter 1 Basic Concepts 1.1 Welcome to Assembly Language 1 1.1.1 Good Questions to Ask 2 1.1.2 Assembly language Applications 5 1.1.3 Section Review 6 1.2 Virtual Machine Concept 7 1.2.1 History of PC

### Part 1 Theory Fundamentals

Part 1 Theory Fundamentals 2 Chapter 1 Information Representation Learning objectives By the end of this chapter you should be able to: show understanding of the basis of different number systems show

### CPE 323 Data Types and Number Representations

CPE 323 Data Types and Number Representations Aleksandar Milenkovic Numeral Systems: Decimal, binary, hexadecimal, and octal We ordinarily represent numbers using decimal numeral system that has 10 as

### الدكتور المھندس عادل مانع داخل

الدكتور المھندس عادل مانع داخل / میسان جامعة / كلیة الھندسة قسم الھندسة الكھرباي یة Chapter 1: Digital Systems Discrete Data Examples: 26 letters of the alphabet (A, B etc) 10 decimal digits (0, 1, 2 etc)

### CHAPTER 3 Number System and Codes

CHAPTER 3 Number System and Codes 3.1 Introduction On hearing the word number, we immediately think of familiar decimal number system with its 10 digits; 0,1, 2,3,4,5,6, 7, 8 and 9. these numbers are called

### 1 Number System (Lecture 1 and 2 supplement)

1 Number System (Lecture 1 and 2 supplement) By Dr. Taek Kwon Many different number systems perhaps from the prehistoric era have been developed and evolved. Among them, binary number system is one of

### Number Systems and. Data Representation

Number Systems and Data Representation 1 Lecture Outline Number Systems Binary, Octal, Hexadecimal Representation of characters using codes Representation of Numbers Integer, Floating Point, Binary Coded

### Chapter 5 Instructor's Manual

The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 5 Instructor's Manual Chapter Objectives Chapter 5, A Closer Look at Instruction

### Decimal Numbers: Base 10 Integer Numbers & Arithmetic

Decimal Numbers: Base 10 Integer Numbers & Arithmetic Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 )+(1x10 0 ) Ward 1 Ward 2 Numbers: positional notation Number

### Number Systems, Base Conversions, and Computer Data Representation

, Base Conversions, and Computer Data Representation Decimal and Binary Numbers When we write decimal (base 10) numbers, we use a positional notation system. Each digit is multiplied by an appropriate

### The string of digits 101101 in the binary number system represents the quantity

Data Representation Section 3.1 Data Types Registers contain either data or control information Control information is a bit or group of bits used to specify the sequence of command signals needed for

### A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc

### Central Processing Unit

Central Processing Unit General Register Organization Stack Organization Instruction Formats Addressing Modes Data Transfer and Manipulation Micro Programmed Control Reduced Instruction Set Computer Parallel

### Numbers represented using groups of bits (1s and 0s) are said to be BINARY NUMBERS. Binary numbers are said to be in base 2.

DATA REPRESENTATION All data used by computers is in code form, based on the two digits 0 and 1. This is so, in order to reflect the two-state components of which these digital systems are made. Numbers

### 1 / 40. Data Representation. January 9 14, 2013

1 / 40 Data Representation January 9 14, 2013 Quick logistical notes In class exercises Bring paper and pencil (or laptop) to each lecture! Goals: break up lectures, keep you engaged chance to work through

### Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Chapter 3 Data Storage Objectives After studying this chapter, students should be able to: List five different data types used in a computer. Describe how integers are stored in a computer. Describe how

### Chapter 5. Processing Unit Design

Chapter 5 Processing Unit Design 5.1 CPU Basics A typical CPU has three major components: Register Set, Arithmetic Logic Unit, and Control Unit (CU). The register set is usually a combination of general-purpose

### Computer is a binary digital system. Data. Unsigned Integers (cont.) Unsigned Integers. Binary (base two) system: Has two states: 0 and 1

Computer Programming Programming Language Is telling the computer how to do something Wikipedia Definition: Applies specific programming languages to solve specific computational problems with solutions

### 2) Write in detail the issues in the design of code generator.

COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage

### MACHINE ARCHITECTURE & LANGUAGE

in the name of God the compassionate, the merciful notes on MACHINE ARCHITECTURE & LANGUAGE compiled by Jumong Chap. 9 Microprocessor Fundamentals A system designer should consider a microprocessor-based

### Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

### Unit 2: Number Systems, Codes and Logic Functions

Unit 2: Number Systems, Codes and Logic Functions Introduction A digital computer manipulates discrete elements of data and that these elements are represented in the binary forms. Operands used for calculations

### Lecture 2. Binary and Hexadecimal Numbers

Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations

### Digital Electronics. 1.0 Introduction to Number Systems. Module

Module 1 www.learnabout-electronics.org Digital Electronics 1.0 Introduction to What you ll learn in Module 1 Section 1.0. Recognise different number systems and their uses. Section 1.1 in Electronics.

### CHAPTER TWO. 2.1 Unsigned Binary Counting. Numbering Systems

CHAPTER TWO Numbering Systems Chapter one discussed how computers remember numbers using transistors, tiny devices that act like switches with only two positions, on or off. A single transistor, therefore,

### CSC 1103: Digital Logic. Lecture Six: Data Representation

CSC 1103: Digital Logic Lecture Six: Data Representation Martin Ngobye mngobye@must.ac.ug Mbarara University of Science and Technology MAN (MUST) CSC 1103 1 / 32 Outline 1 Digital Computers 2 Number Systems

### Chapter 1: Digital Systems and Binary Numbers

Chapter 1: Digital Systems and Binary Numbers Digital age and information age Digital computers general purposes many scientific, industrial and commercial applications Digital systems telephone switching

### Solution for Homework 2

Solution for Homework 2 Problem 1 a. What is the minimum number of bits that are required to uniquely represent the characters of English alphabet? (Consider upper case characters alone) The number of

### SIT102 Introduction to Programming

SIT102 Introduction to Programming After working through this session you should: Understand the relationships between operating systems, their user interfaces, and programs; Understand the difference

### Chapter 2 : Central Processing Unit

Chapter 2 Central Processing Unit The part of the computer that performs the bulk of data processing operations is called the Central Processing Unit (CPU) and is the central component of a digital computer.

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

CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. Part 5: Processors Our goal: understand basics of processors and CPU understand the architecture of MARIE, a model computer a close look at the instruction

### Data Representation in Computers

Chapter 3 Data Representation in Computers After studying this chapter the student will be able to: *Learn about binary, octal, decimal and hexadecimal number systems *Learn conversions between two different

### Number Representation

Number Representation Number System :: The Basics We are accustomed to using the so-called decimal number system Ten digits ::,,,3,4,5,6,7,8,9 Every digit position has a weight which is a power of Base

### The8086 Processor Architecture

Chapter 2 : The 8086 Processor Architecture By Electrical Engineering Department College of Engineering King Saud University 1431-1432 2.1. Introduction to Microprocessor Architecture 2.2. Elements of

### Presented By: Ms. Poonam Anand

Presented By: Ms. Poonam Anand Know the different types of numbers Describe positional notation Convert numbers in other bases to base 10 Convert base 10 numbers into numbers of other bases Describe the

### Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 INTRODUCTION TO DIGITAL LOGIC

Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 1 Number Systems Representation Positive radix, positional number systems A number with radix r is represented by a string of digits: A n

### a. Chapter 1: Exercises: =>

Selected Solutions to Problem-Set #1 COE608: Computer Organization and Architecture Introduction, Instruction Set Architecture and Computer Arithmetic Chapters 1, 2 and 3 a. Chapter 1: Exercises: 1.1.1

### Chapter 4 ARM Instruction Sets. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Chapter 4 ARM Instruction Sets Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan Outline Registers, Memory Access, and Data Transfer Arithmetic and Logic Instructions

### COMP2121: Microprocessors and Interfacing

Interfacing Lecture 3: Number Systems (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2005 Overview Positional notation Decimal, hexadecimal and binary One complement Two s complement

### Traditional IBM Mainframe Operating Principles

C H A P T E R 1 7 Traditional IBM Mainframe Operating Principles WHEN YOU FINISH READING THIS CHAPTER YOU SHOULD BE ABLE TO: Distinguish between an absolute address and a relative address. Briefly explain

### 3D1 / Microprocessor Systems I. Binary Arithmetic. Binary Arithmetic. Addition

3D / Microprocessor Systems I Addition 7 6 33 22 Carry 3D / Microprocessor Systems I What happens if we run out of digits? Adding two numbers each stored in byte (8 bits) may produce a 9-bit result 8 bits

### 612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS 11.1 How is conditional execution of ARM instructions (see Part I of Chapter 3) related to predicated execution

### PIPELINING CHAPTER OBJECTIVES

CHAPTER 8 PIPELINING CHAPTER OBJECTIVES In this chapter you will learn about: Pipelining as a means for executing machine instructions concurrently Various hazards that cause performance degradation in

### An Overview of Stack Architecture and the PSC 1000 Microprocessor

An Overview of Stack Architecture and the PSC 1000 Microprocessor Introduction A stack is an important data handling structure used in computing. Specifically, a stack is a dynamic set of elements in which

### Digital Computers and Information

Introduction to Digital Logic Prof. Nizamettin AYDIN naydin@yildiz.edu.tr naydin@ieee.org Course Outline. Digital Computers, Number Systems, Arithmetic Operations, Decimal, Alphanumeric, and s. Logic,

### Basic Computer Organization and Design

Ted Borys - CSI 404 3/2/2004 Page 5-1 Section 5 Basic Computer Organization and Design Mano s Basic Computer Memory unit with 4096 16-bit words Registers: AR, PC, DR, AC, IR, TR, OUTR, INPR, SC Flip-flops:

### 13. NUMBERS AND DATA 13.1 INTRODUCTION

13. NUMBERS AND DATA 13.1 INTRODUCTION Base 10 (decimal) numbers developed naturally because the original developers (probably) had ten fingers, or 10 digits. Now consider logical systems that only have

### Computer Number Systems

Computer Number Systems Thorne, Edition 2 : Section 1.3, Appendix I (Irvine, Edition VI : Section 1.3) SYSC3006 1 Starting from What We Already Know Decimal Numbers Based Number Systems : 1. Base defines

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

Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 1: Basic Concepts Slides prepared by Kip R. Irvine Revision date: 10/27/2002 Chapter corrections (Web) Printing a slide show

### To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Binary Numbers In computer science we deal almost exclusively with binary numbers. it will be very helpful to memorize some binary constants and their decimal and English equivalents. By English equivalents

### EE 261 Introduction to Logic Circuits. Module #2 Number Systems

EE 261 Introduction to Logic Circuits Module #2 Number Systems Topics A. Number System Formation B. Base Conversions C. Binary Arithmetic D. Signed Numbers E. Signed Arithmetic F. Binary Codes Textbook

### Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Today Binary addition Representing negative numbers 2 Binary Addition Consider the following binary numbers: 0 0 1 0 0 1 1 0 0 0 1 0 1 0 1 1 How do we add these numbers? 3 Binary Addition 0 0 1 0 0 1 1

### Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Chapter 4 Register Transfer and Microoperations Section 4.1 Register Transfer Language Digital systems are composed of modules that are constructed from digital components, such as registers, decoders,

### (Refer Slide Time: 00:01:16 min)

Digital Computer Organization Prof. P. K. Biswas Department of Electronic & Electrical Communication Engineering Indian Institute of Technology, Kharagpur Lecture No. # 04 CPU Design: Tirning & Control

### BINARY-CODED DECIMAL (BCD)

BINARY-CODED DECIMAL (BCD) Definition The binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. Basics In computing and electronic

### Lecture 2: MC68000 architecture

Lecture 2: MC68000 architecture g General information g Programmer s model g Memory organization g Instruction format g Our first assembly program g The sim68k simulator g Machine translation 1 MC68000

### Processing Unit Design

&CHAPTER 5 Processing Unit Design In previous chapters, we studied the history of computer systems and the fundamental issues related to memory locations, addressing modes, assembly language, and computer

### Encoding Systems: Combining Bits to form Bytes

Encoding Systems: Combining Bits to form Bytes Alphanumeric characters are represented in computer storage by combining strings of bits to form unique bit configuration for each character, also called

### CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 47 2.2 Positional Numbering Systems 48 2.3 Converting Between Bases 48 2.3.1 Converting Unsigned Whole Numbers 49 2.3.2 Converting Fractions

### CHAPTER 4 MARIE: An Introduction to a Simple Computer

CHAPTER 4 MARIE: An Introduction to a Simple Computer 4.1 Introduction 145 4.1.1 CPU Basics and Organization 145 4.1.2 The Bus 147 4.1.3 Clocks 151 4.1.4 The Input/Output Subsystem 153 4.1.5 Memory Organization

### Digital Fundamentals

Digital Fundamentals with PLD Programming Floyd Chapter 2 29 Pearson Education Decimal Numbers The position of each digit in a weighted number system is assigned a weight based on the base or radix of

### Representation of Data

Representation of Data In contrast with higher-level programming languages, C does not provide strong abstractions for representing data. Indeed, while languages like Racket has a rich notion of data type

### Introduction to C Programming

Introduction to C Programming C HOW TO PROGRAM, 6/E 1992-2010 by Pearson Education, Inc. All Rights Reserved. 2.1 Introduction The C language facilitates a structured and disciplined approach to computer