ALU and Arithmetic Operations
|
|
- Kellie Cain
- 5 years ago
- Views:
Transcription
1 EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 6th February 2002 CLR Part IV ALU and Arithmetic Operations There are several issues connected with the use of arithmetic by computers. The first is the type of numeric data upon which arithmetic operations will be performed, and how such numbers should be represented; the second is the means by which the numbers should be manipulated; and the third is the bit/byte/word-ordering of data within memory to accommodate the representation. In the following notes, we will look at two s complement, binary-coded decimal, and floating point representations of numbers. 10 Two s Complement The most commonly found representation of integer numbers in computers is the two s complement representation. In this representation, the full range of binary numbers (2 n for n bits) is split between positive and negative numbers ( 2 n 1 to 2 n 1 1). Positive numbers are the same as their unsigned representations. To find the representation of a negative number, invert the bits of the unsigned binary representation and then add 1. Using this representation, all subtractive operations become additions with a negative number. Because the uppermost bit of a two s complement number is always 0 for positive numbers 19, and 1 for negative numbers, this bit is often referred to as the sign bit. There are two ways to implement the multiplication of two 8-bit unsigned numbers, one is by repeated addition and the other is via partial sums. These methods will not work for all combinations of two s complement numbers [Sta00, Ch. 8]. Instead Booth s algorithm, a variant of the partial sums method, must be utilised. Division is the opposite of multiplication. In it s simplest form, the divisor may be repeatedly subtracted from the dividend and the quotient incremented each time. A Booths s like partial subtraction method may be employed for signed numbers. Changing the bit width of a two s complement number can be done by sign reduction or extension i.e. removing locations which are the same as the sign bit, or copying the sign bits to any additional bit locations. In practice, representation of a number using more bits involves the use of multiple data words. Because the ALU is generally structured for single data word operations, the addition of multiple-word integer numbers i.e. 16-bit, 24-bit, etc. requires extra work. Let us look at the manipulation (addition, subtraction, multiplication, division) of numbers represented by single and multiple words 20 using the PIC16F877. The following examples assume that the relevant constants have been defined in the included.inc file, and the variables are already declared. 19 Zero is assumed to be a positive number. 20 Use the simulator, code, pencil and paper to work through each of the routines presented to ensure thorough understanding. It is important to work through these exercises in the MPLAB simulator in order to get a good idea of the operation of the PIC (and to catch all the mistakes Cathy made!). It is very difficult to learn the programming without actual hands-on experience.
2 EE25M 6th February 2002 IV 2 Decrementing a 16-bit variable Given a 16-bit variable with its low byte in countl and high byte in counth, write a routine to decrement it. Decr movf countl,f ; set the Zero flag if countl is zero btfsc STATUS,Z ; countl zero? decrement counth (next instr) decf counth,f decf countl,f ; always decrement countl Test a 16-bit variable for zero Using the same 16-bit variable as before, test it for zero. Iszero movf countl,f ; test for zero in low byte btfsc STATUS,Z ; if not, don t test high byte movf counth,f ; test high byte btfsc STATUS,Z goto Bothzero ; Zero? branch to some appropriate place bit Addition A simple work around for 16-bit numbers is to simply increment one of the numbers if the Carry is set. For example: ; This routine adds the 16-bit number in datalo and datahi, to the ; 16-bit number is resultlo and resulthi, leaving the answer in ; resultlo and resulthi Add16 movf datalo,w ; W = datalo addwf resultlo,f ; resultlo = resultlo + W movf datahi,w ; W = datahi btfsc STATUS,C ; If no carry skip incf resulthi,f ; If carry, add 1 to result addwf resulthi,f ; resulthi = resulthi + W There is a problem with this method because the Carry bit does not accurately reflect the results of the last addition. In particular, if resulthi was 0xFF and the Carry bit was set from the low bytes then after the last addition the Carry bit would be clear and it should be set. This means that this method cannot be scaled up to be used with 24-bit and larger numbers. A slightly longer, but scalable routine that correctly sets the Carry bit on termination is shown below. You should work out the sequence of operations to ensure that you understand the routine. Addgood movf datalo,w ; W = datalo addwf resultlo,f ; resultlo = resultlo + W movf datahi,w ; W = datahi btfsc STATUS,C ; If no carry... incfsz resulthi,f ; if resulthi is 0 after the increment ;... don t do the addition addwf resulthi,w movwf resulthi ; resulthi = resulthi + W
3 EE25M 6th February 2002 IV 3 16-bit Subtraction Subtraction is very similar to addition, with the inclusion of the borrow. The only difference to look out for is that the PIC16xxx treats the carry bit as a Borrow. Assume that the operation required is R = Q 1 - Q 2, where Q 1 and Q 2 are two 16-bit numbers. This can be accomplished by the following code: Subr movf Q2_lo,W subwf Q1_lo,W ; W = Q1_lo - Q2_lo movwf R_lo btfss STATUS,C ; need to borrow? decf Q1_hi,F ; get it from hi byte movf Q2_hi,W subwf Q1_hi,W ; W = Q1_hi - Q2_hi movwf R_hi Note that the carry flag at the end of the routine will not be set correctly if Q2 hi is 0. An improved routine is as follows Subrgd movf Q2_lo,W subwf Q1_lo,W ; W = Q1_lo - Q2_lo movwf R_lo movf Q2_hi,W btfss STATUS,C ; need to borrow? goto Borrow subwf Q1_hi,W ; W = Q1_hi - Q2_hi movwf R_hi goto Done Borrow subwf Q1_hi,W ; W = Q1_hi - Q2_hi movwf R_hi decf R_hi,F ; do the decrement after Done Extending bit width 8bit > 16bit the positions of the new upper byte. Extension consists of copying the relevant bit into all E8to16 movlw 255 ; make the accumulator clrf Out_hi ; clear out the upper result byte btfsc In, 7 ; if the top bit of the input byte is 1 movwf Out_hi ; put all ones in the upper result byte movf In,W ; copy the input byte to movwf Out_lo ; the lower result byte
4 EE25M 6th February 2002 IV 4 8-bit by 8-bit Unsigned Multiplication There are two ways to implement the multiplication of two 8-bit numbers, one is by repeated addition and the other is via partial sums. The first example multiplies M1 by M2 leaving the result in R hi and R lo. It loops through the addition of M2 to itself M1 times. ; 8x8 unsigned multiply routine. ; No checks made for M1 or M2 equal to zero clrf R_hi ; clear result location clrf R_lo clrw M8x8 addwf M2,W ; add M2 to itself btfsc STATUS,C ; if carry set inc R_hi,F ;... increment high byte decfsz M1,F goto M8x8 movwf R_lo This second routine, does the same thing but loops only 8 times instead of M1 times as the previous case. M1 is added to the result which is then shifted. It makes use of the fact that multiplying a number by one results in the same number so all that is required is either addition if the bit, in M2, was one or no addition if it was zero. ; 8x8 unsigned multiply routine. ; No checks made for M1 or M2 equal to zero clrf R_hi ; Clear result location clrf R_lo movlw 0x08 ; setup loop count movwf cntr movf M1,W ; initialize W with M1 Umul rrf M2,F ; rotate into carry to check bits btfsc STATUS,C ; if carry set i.e. bit was 1 addwf R_hi,F ;... we add rrf R_hi,F ; shift over for the next addition rrf R_lo,F decf cntr,f ; check the loop count btfss STATUS,Z goto Umul
5 EE25M 6th February 2002 IV 5 16-bit by 8-bit Unsigned Division ; 16-bit unsigned division ; Quot = (Div_hi, Div_lo) / Divsor clrf Quot Divide movf Divsor,W ; setup for subtraction subwf Div_lo,F ; Div_lo = Div_lo - Divisor btfss STATUS,C goto Borrow goto Div_2 Borrow movlw 0x01 subwf Div_hi,F ; use subtract instead of decf btfss STATUS,C ;... because it sets the carry goto Done ; generated a borrow so finish Div_2 incf Quot,F ; add one and loop again goto Divide Done Reducing bit width 16bit > 8bit Reduction should only occur if the bits of the upper byte all match the uppermost bit of the lower byte. R16to8 movlw 255 ; make a byte with the btfsc In_lo,7 ; inverted upper bit of the lower byte clrw xorwf In_hi,W ; xor with the upper byte to check if all bits are the same btfss STATUS,Z ; an error (non-zero W) if not the same retlw 255 ; movf In_lo,W ; otherwise truncate and movwf Out retlw 0
6 EE25M 6th February 2002 IV 6 Exercises 1. Write code to decrement a 16-bit variable and test the result for zero, branching to Bothzero if the result is zero. Can this be done using fewer lines of code and/or faster execution than simply concatenating the two routines shown previously? 2. Why does -7/3 yield a different remainder to 7/-3? 3. Design an algorithm and implement it in PIC assembly language to perform unsigned division of a 24-bit number by an 8-bit number and produce a 16-bit quotient and 8-bit remainder. 4. Design an algorithm that works more efficiently than repeated subtraction for unsigned 8-bit by 8-bit division. Implement it in PIC assembly language. 5. Implement Booth s algorithm for two signed 8 bit numbers in PIC assembly language. It is presumed that the result with by 16 bits wide. 6. Design a Booth s-like algorithm for the division of a signed 16 bit number by a signed 8 bit number, and implement it in PIC assembly language. 7. Presuming a two s complement 8-bit integer representation, write an algorithm and implement it in PIC assembly language to count the number of negative integers in a set of twenty numbers starting at address 30h. [Past Paper 2001, No. 1(c)] 8. Write an algorithm and implement it in PIC assembly language to subtract two 24-bit numbers, Q 1 and Q 2, and store the result in R. Ensure that the carry flag reflects the result of the subtraction. [Past Paper 2001, No. 2] CourseWork A - 10% Using PIC Assembly, implement Booth s algorithm for the multiplication of two 16-bit signed integers. This exercise is to be tested on the simulator, and demonstrated to the lab demonstrator in week 5 (begins 18/2/02). A report containing: the algorithm design, printout of commented code, copy of the code (*.asm; *.hex) on disk, and a set of 5 test cases and the results should be submitted by the end of week 6 (1/3/02). References [Sta00] William Stallings. Computer Architecture and Organization. Prentice-Hall, Inc., 5th edition, 2000.
7 EE25M 6th February 2002 IV 7 11 Binary Coded Decimal Binary coded decimal representation of numbers, uses a 4 bit binary number to represent the decimal digits 0-9. It is clearly an inefficient representation, as 6 of the numbers which could be represnted by 4 bits are never used. The advantage of using such a scheme lies in the fact that most human I/O involves the use of decimal numbers. The use of BCD reduces the overhead of conversion at the interface-level. The disadvantage is that mathematical operations become more complex, as the manipulation of individual binary digits may yield an invalid 4 bit BCD code. Further there is no accomodation for signed quantities. Subsequently BCD arithmetic operations are generally restricted to addition and subtraction of unsigned quantities. In packed BCD, two digits are continued within a single byte. Other representations pad the extra bits in the byte/word (i.e. leave the upper bits of the data word either unused or filled with a particular prefix) e.g. 7 bit ASCII character codes. Packed BCD Validity checking Adding 6 to a 4-bit nibble produces a carry out of that nibble if the nibble is an invalid BCD code. The following s 1 in the working register if either code in Reg are invalid. PBCDchk movlw 0x66 addf Reg,W btfsc STATUS,C retlw 1 btfsc STATUS,DC retlw 1 retlw 0 Packed BCD Addition The addition of BCD numbers involves consideration of the decimal carry. The addition plus 6 to each nibble will produce a carry exactly when the decimal addition of two digits in the operands would produce a carry, and these are the carries we are concerned with. But the digits in positions that did not produce a carry will contain an excess 6. The problem, then, is to remove the extra 6 from each digit that did not generate a carry. The following routine leaves the carry set if the upper digit overflows: PBCDadd movlw 0x66 addf RegA,W addf RegB,W rrf Out,F btfss STATUS,DC addlw -0x06 btfss Out,7 addlw -0x60 rlf Out,F movwf Out From: Scott Dattalo (
8 EE25M 6th February 2002 IV 8 Packed BCD Subtraction Similarly to two s complement arithmetic for binary number, subtraction of decimal numbers can be performed by adding the ten s complement (subtract from all nines and add 1) e.g Note that 0 to 99 represents the numbers +49 to -50 in ten s complement notation. The following code produces the ten s complement of a packed BCD number: PBCDCmp movlw 0x99 ; movwf Out ; movf In ; subwf Out,F ; Out=0x99-In incf Out,F Packed BCD Single Digit extraction mask may be used: To extract a single digit from a BCD number, a bit PBCDext movlw 0xF0 andwf In,W movf Nibble_hi movlw 0x0F andwf In,W movf Nibble_lo Conversion BCD to unsigned binary To convert from BCD to an unsigned binary, multiply the upper nibble by ten and add the lower nibble. This can be done by shifting the upper nibble right 3 places (multiply by 8), adding the upper nibble shifted 1 place (multiply by 2) and adding the lower nibble. PBCDbin rrf In,W andlw 0x78 ; movwf Out bcf STATUS,C rrf Out,F rrf Out,F addwf Out,F movlw In andlw 0x0F addwf Out,F
9 EE25M 6th February 2002 IV 9 Conversion unsigned binary to BCD To convert binary to BCD, check that the 7th bit is not used, and set the carry if the number exceeds 99(i.e. between 99 and 128). BinPBCD btfss In,7 ; check if > 128 retlw 1 ; an error clrf Out movlw 156 ; Check if the number will overflow addwf In,W ; rrf Out,F ; Store the Carry in Out movlw 100 ; subtract 100 if needed btfss Out,7 ; subwf In,W ; iorwf Out,F ; Store the reduced number swapf Out,W ; sort out the bottom bits addwf Out,W andlw 0x0F btfsc STATUS,DC ; correct for the DC addlw 0x10 btfsc Out,4 ; correct for bit 4 addlw 0x06 btfsc Out,7 ; correct for the Carry stored in bit 8 sublw 0x08 addlw 6 ; make sure lower nibble is 0-9 btfss STATUS,DC addlw -6 btfsc Out,6 ; now the upper bits addlw 0x60 ; If the 64 bit is on store BCD 60 btfsc Out,5 addlw 0x30 ; If the 32 bit is on add BCD 30 btfsc Out,4 addlw 0x10 ; If the 16 bit is on add BCD 10 rlf Out,F movwf Out ; restore the carry, set Out and
10 EE25M 6th February 2002 IV 10 Exercises 1. Many CPU s provide logic for performing arithmetic on packed decimal numbers. Although he rules for decimal arithmetic are similar to those for binary operations, the decimal results may require some corrections to the individual digits if binary logic is used. Consider the decimal addition of two unsigned numbers. If each number consists of N digits, then there are 4N bits in each number. The two numbers are to be added using a binary adder. Suggest a simple rule for correcting the result. Perform addition in this fashion on the numbers 1698 and [Sta00, 9.1] 2. The tens complement of the decimal number X is defined to be 10N X, where N is the number of digits in the number. Describe the use of tens complement representation to perform decimal subtraction. Illustrate the procedure by subtracting (0326) 10 from (0736) 10. [Sta00, 9.2] What purpose does ten s complement arithmetic serve in BCD arithmetic? 3. BCD is not the only means of representing decimal numbers. The ASCII 21 character set defines a representation of characters as 7 bit numbers. The digit characters 0 through 9 are represented as thru Using this information write routines to correctly add and subtract two ASCII digits. (Note: The carry flag should be set for overflow, or no borrow respectively) References [Sta00] William Stallings. Computer Architecture and Organization. Prentice-Hall, Inc., 5th edition, American Standard Code for Information Interchange
16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution
16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationSOLUTIONS!! DO NOT DISTRIBUTE!!
THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF FEBRUARY MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: Date and Time: Duration: One Hour INSTRUCTIONS TO CANDIDATES:
More informationChapter 4 Sections 1 4, 10 Dr. Iyad Jafar
Starting to Program Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar Outline Introduction Program Development Process The PIC 16F84A Instruction Set Examples The PIC 16F84A Instruction Encoding Assembler Details
More informationInstuction set
Instuction set http://www.piclist.com/images/www/hobby_elec/e_pic3_1.htm#1 In PIC16 series, RISC(Reduced Instruction Set Computer) is adopted and the number of the instructions to use is 35 kinds. When
More informationAssembly Language Instructions
Assembly Language Instructions Content: Assembly language instructions of PIC16F887. Programming by assembly language. Prepared By- Mohammed Abdul kader Assistant Professor, EEE, IIUC Assembly Language
More informationEECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution
For each of the following complex operations, write a sequence of PIC 16F1829 instructions that performs an equivalent operation. Assume that X, Y, and Z are 16-bit values split into individual bytes as
More informationCENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006
CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2006 Recitation 01 21.02.2006 CEng336 1 OUTLINE LAB & Recitation Program PIC Architecture Overview PIC Instruction Set PIC Assembly Code Structure 21.02.2006
More information16.317: Microprocessor-Based Systems I Summer 2012
16.317: Microprocessor-Based Systems I Summer 2012 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationTOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010
TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010 E4160 Microprocessor & Microcontroller System Learning Outcomes 2 At the end of this topic, students should
More informationLecture (04) PIC16F84A (3)
Lecture (04) PIC16F84A (3) By: Dr. Ahmed ElShafee ١ Central Processing Unit Central processing unit (CPU) is the brain of a microcontroller responsible for finding and fetching the right instruction which
More informationPIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS
PIC6F87X 3.0 INSTRUCTION SET SUMMARY Each PIC6F87X instruction is a 4bit word, divided into an OPCODE which specifies the instruction type and one or more operands which further specify the operation of
More informationChapter 5 Sections 1 6 Dr. Iyad Jafar
Building Assembler Programs Chapter 5 Sections 1 6 Dr. Iyad Jafar Outline Building Structured Programs Conditional Branching Subroutines Generating Time Delays Dealing with Data Example Programs 2 Building
More information16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:
16.317: Microprocessor Systems Design I Fall 2014 Exam 3 December 15, 2014 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices
More informationLesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)
Lesson 14 Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27) Name and affiliation of the author: N W K Jayatissa Department of Physics,
More informationArithmetic,logic Instruction and Programs
Arithmetic,logic Instruction and Programs 1 Define the range of numbers possible in PIC unsigned data Code addition and subtraction instructions for unsigned data Perform addition of BCD Code PIC unsigned
More informationChapter 13. PIC Family Microcontroller
Chapter 13 PIC Family Microcontroller Lesson 15 Instruction Set Most instructions execution Time One instruction cycle If XTAL frequency = 20 MHz, then instruction cycle time is 0.2 s or 200 ns (= 4/20
More information16.317: Microprocessor-Based Systems I Spring 2012
16.317: Microprocessor-Based Systems I Spring 2012 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationECE Test #1: Name
ECE 376 - Test #1: Name Closed Book, Closed Notes. Calculators Permitted. September 23, 2016 20 15 10 5 0
More informationPIC 16F84A programming (II)
Lecture (05) PIC 16F84A programming (II) Dr. Ahmed M. ElShafee ١ Introduction to 16F84 ٣ PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Program memory (FLASH) EEPROM RAM PORTA
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design
Year: IV DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EE6008 Microcontroller based system design Semester : VII UNIT I Introduction to PIC Microcontroller
More informationLAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work
LAB WORK 1 We are studying with PIC16F84A Microcontroller. We are responsible for writing assembly codes for the microcontroller. For the code, we are using MPLAB IDE software. After opening the software,
More informationEEM336 Microprocessors I. Arithmetic and Logic Instructions
EEM336 Microprocessors I Arithmetic and Logic Instructions Introduction We examine the arithmetic and logic instructions. The arithmetic instructions include addition, subtraction, multiplication, division,
More informationPerformance & Applications
EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 15th March 2002 CLR Part VI Performance & Applications It is possible to predict the execution time of code, on the basis
More information16.317: Microprocessor Systems Design I Fall 2015
16.317: Microprocessor Systems Design I Fall 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More information/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10
16.317: Microprocessor-Based Systems I Summer 2012 Exam 3 August 13, 2012 Name: ID #: Section: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic
More informationEEE111A/B Microprocessors
EEE111A/B Microprocessors Revision Notes Lecture 1: What s it all About? Covers the basic principles of digital signals. The intelligence of virtually all communications, control and electronic devices
More informationWeek1. EEE305 Microcontroller Key Points
Week1 Harvard Architecture Fig. 3.2 Separate Program store and Data (File) stores with separate Data and Address buses. Program store Has a 14-bit Data bus and 13-bit Address bus. Thus up to 2 13 (8K)
More informationEmbedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester
Embedded Systems PIC16F84A Sample Programs Eng. Anis Nazer First Semester 2017-2018 Development cycle (1) Write code (2) Assemble / compile (3) Simulate (4) Download to MCU (5) Test Inputs / Outputs PIC16F84A
More information16.317: Microprocessor-Based Systems I Fall 2012
16.317: Microprocessor-Based Systems I Fall 2012 Exam 2 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationArithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan
Arithmetic and Logic Instructions Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan chanhl@mail.cgu.edu.tw Find the sum of the values from 40H to 43H. Put the sum in filereg locations
More informationModule 2: Computer Arithmetic
Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N
More informationSOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!
THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF APRIL MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: MidTerm Date and Time: Thursday April 14th 2005 8AM Duration:
More informationDivide: Paper & Pencil
Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or
More informationBINARY SYSTEM. Binary system is used in digital systems because it is:
CHAPTER 2 CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System
More information16.317: Microprocessor Systems Design I Spring 2015
16.317: Microprocessor Systems Design I Spring 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by
More informationInterfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling
Interfacing PIC Microcontrollers ADC8BIT2 Schematic This application demonstrates analogue input sampling A manually adjusted test voltage 0-5V is provided at AN0 input A reference voltage of 2.56V is
More informationCOMPUTER ARITHMETIC (Part 1)
Eastern Mediterranean University School of Computing and Technology ITEC255 Computer Organization & Architecture COMPUTER ARITHMETIC (Part 1) Introduction The two principal concerns for computer arithmetic
More informationKinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other
Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers
More informationUNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours
UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J1 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions
More information/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10
16.317: Microprocessor Systems Design I Fall 2014 Exam 2 November 5, 2014 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices (e.g.,
More informationUNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours
UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 Semester 2 Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J2 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions
More informationPIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS
PI6F84A 7.0 INSTRUTION SET SUMMARY Each PI6XX instruction is a 4bit word, divided into an OPODE which specifies the instruction type and one or more operands which further specify the operation of the
More informationUNIT-II. Part-2: CENTRAL PROCESSING UNIT
Page1 UNIT-II Part-2: CENTRAL PROCESSING UNIT Stack Organization Instruction Formats Addressing Modes Data Transfer And Manipulation Program Control Reduced Instruction Set Computer (RISC) Introduction:
More informationQ1: Multiple choice / 20 Q2: Protected mode memory accesses. / 40 Q3: Reading PIC. / 40 assembly language TOTAL SCORE / 100
16.317: Microprocessor-Based Systems I Fall 2012 Exam 2 November 7, 2012 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices (e.g.,
More informationLecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C
More informationChapter 10 - Computer Arithmetic
Chapter 10 - Computer Arithmetic Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 10 - Computer Arithmetic 1 / 126 1 Motivation 2 Arithmetic and Logic Unit 3 Integer representation
More informationThe University of Texas at Arlington Lecture 7
The University of Texas at Arlington Lecture 7 CSE 3442/5442 Agenda HW 2 due today Begin Chapter 5 In class assignment. Reading Assignment for Tuesday, Continue Reading Chapter 6. Assignment 3 and 4 due
More informationCONNECT TO THE PIC. A Simple Development Board
CONNECT TO THE PIC A Simple Development Board Ok, so you have now got your programmer, and you have a PIC or two. It is all very well knowing how to program the PIC in theory, but the real learning comes
More informationENE 334 Microprocessors
Page 1 ENE 334 Microprocessors Lecture 10: MCS-51: Logical and Arithmetic : Dejwoot KHAWPARISUTH http://webstaff.kmutt.ac.th/~dejwoot.kha/ ENE 334 MCS-51 Logical & Arithmetic Page 2 Logical: Objectives
More information2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).
2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode
More informationCHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS Addition of Unsigned Numbers The instruction ADD is used to add two operands Destination operand is always in register A Source operand can be a register,
More informationCOMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)
Computer Arithmetic Data is manipulated by using the arithmetic instructions in digital computers. Data is manipulated to produce results necessary to give solution for the computation problems. The Addition,
More informationDIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM
COURSE / CODE DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) NUMBER SYSTEM A considerable subset of digital systems deals with arithmetic operations. To understand the
More information16.317: Microprocessor Systems Design I Fall 2014
16.317: Microprocessor Systems Design I Fall 2014 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationNUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah
NUMBER OPERATIONS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 3810: Computer Organization Overview Homework 4 is due tonight Verify your uploaded file before the
More informationComputer Organisation CS303
Computer Organisation CS303 Module Period Assignments 1 Day 1 to Day 6 1. Write a program to evaluate the arithmetic statement: X=(A-B + C * (D * E-F))/G + H*K a. Using a general register computer with
More informationCHW 261: Logic Design
CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER
More informationPIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.
PIC PROGRAMMING You have been introduced to PIC chips and the assembly language used to program them in the past number of lectures. The following is a revision of the ideas and concepts covered to date.
More informationArithmetic Logic Unit
Arithmetic Logic Unit A.R. Hurson Department of Computer Science Missouri University of Science & Technology A.R. Hurson 1 Arithmetic Logic Unit It is a functional bo designed to perform "basic" arithmetic,
More information4.5.1) The Label Field ) The Mnemonic Field. 4.5) Assembly Language Program Structure A PIC18 ALP consists of 3 type of statements:
4.5) Assembly Language Program Structure A PIC18 ALP consists of 3 type of statements: 1) Assembler Directives To control the assembler: its input, output, and data allocation. Must be terminated with
More informationPositional Number System
Positional Number System A number is represented by a string of digits where each digit position has an associated weight. The weight is based on the radix of the number system. Some common radices: Decimal.
More informationET355 Microprocessors Thursday 6:00 pm 10:20 pm
ITT Technical Institute ET355 Microprocessors Thursday 6:00 pm 10:20 pm Unit 4 Chapter 6, pp. 139-174 Chapter 7, pp. 181-188 Unit 4 Objectives Lecture: BCD Programming Examples of the 805x Microprocessor
More informationChapter 2 Data Representations
Computer Engineering Chapter 2 Data Representations Hiroaki Kobayashi 4/21/2008 4/21/2008 1 Agenda in Chapter 2 Translation between binary numbers and decimal numbers Data Representations for Integers
More informationUNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS
UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and
More information361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division
361 div.1 Computer Architecture EECS 361 Lecture 7: ALU Design : Division Outline of Today s Lecture Introduction to Today s Lecture Divide Questions and Administrative Matters Introduction to Single cycle
More informationData Representations & Arithmetic Operations
Data Representations & Arithmetic Operations Hiroaki Kobayashi 7/13/2011 7/13/2011 Computer Science 1 Agenda Translation between binary numbers and decimal numbers Data Representations for Integers Negative
More informationMIPS Integer ALU Requirements
MIPS Integer ALU Requirements Add, AddU, Sub, SubU, AddI, AddIU: 2 s complement adder/sub with overflow detection. And, Or, Andi, Ori, Xor, Xori, Nor: Logical AND, logical OR, XOR, nor. SLTI, SLTIU (set
More informationDigital Fundamentals
Digital Fundamentals Tenth Edition Floyd Chapter 2 2009 Pearson Education, Upper 2008 Pearson Saddle River, Education NJ 07458. All Rights Reserved Decimal Numbers The position of each digit in a weighted
More informationCS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq
CS 121 Digital Logic Design Chapter 1 Teacher Assistant Hadeel Al-Ateeq Announcement DON T forgot to SIGN your schedule OR you will not be allowed to attend next lecture. Communication Office hours (8
More informationNumber Systems and Computer Arithmetic
Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text
More informationAdding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit
Part 5 Adding Binary Integers Arithmetic Logic Unit = Adding Binary Integers Adding Base Numbers Computer's add binary numbers the same way that we do with decimal Columns are aligned, added, and "'s"
More informationSection 31. Instruction Set
31 HIGHLIGHTS Section 31. Instruction Set Instruction Set This section of the manual contains the following major topics: 31.1 Introduction... 31-2 31.2 Data Memory Map... 31-3 31.3 Instruction Formats...
More informationELEG3923 Microprocessor Ch.6 Arithmetic and Logics
Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.6 Arithmetic and Logics Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Arithmetic instructions Signed number operations Logic
More informationLesson 7 Multiple Precision Arithmetic
Elmer 160 Lesson 7 Overview Lesson 7 In this section The PIC stores data as 8-bit bytes. Up until now, we have only used values of 8 bits or less. But what if we have a greater range of values? In this
More informationFortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.
Fortune 1 R2F module and 3 13 LCD driver. Data Sheet TD-0410001 Rev. 1.2 This manual contains new product information. Fortune reserves the rights to modify the product specification without further notice.
More informationChapter 5 : Computer Arithmetic
Chapter 5 Computer Arithmetic Integer Representation: (Fixedpoint representation): An eight bit word can be represented the numbers from zero to 255 including = 1 = 1 11111111 = 255 In general if an nbit
More informationPTK8756B 8 Bit Micro-controller Data Sheet
PTK8756B 8 Bit Micro-controller DEC 15, 2008 Ver1.1 普泰半導體股份有限公司 PORTEK Technology Corporation 公司地址 : 臺北縣新店市寶橋路 235 巷 120 號 4 樓 聯絡電話 : 886-2-89121055 傳真號碼 : 886-2-89121473 公司網址 : www.portek.com.tw Page1
More informationPrinciple and Interface Techniques of Microcontroller
Principle and Interface Techniques of Microcontroller --8051 Microcontroller and Embedded Systems Using Assembly and C LI, Guang ( 李光 ) Prof. PhD, DIC, MIET WANG, You ( 王酉 ) PhD, MIET 杭州 浙江大学 2011 Chapter
More informationCOMP 303 Computer Architecture Lecture 6
COMP 303 Computer Architecture Lecture 6 MULTIPLY (unsigned) Paper and pencil example (unsigned): Multiplicand 1000 = 8 Multiplier x 1001 = 9 1000 0000 0000 1000 Product 01001000 = 72 n bits x n bits =
More informationNumber representations
Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or
More informationDLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR
UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error
More information(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)
COMPUTER ARITHMETIC 1. Addition and Subtraction of Unsigned Numbers The direct method of subtraction taught in elementary schools uses the borrowconcept. In this method we borrow a 1 from a higher significant
More informationFinal Labs and Tutors
ICT106 Fundamentals of Computer Systems - Topic 2 REPRESENTATION AND STORAGE OF INFORMATION Reading: Linux Assembly Programming Language, Ch 2.4-2.9 and 3.6-3.8 Final Labs and Tutors Venue and time South
More informationIntroduction to Computers and Programming. Numeric Values
Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 5 Reading: B pp. 47-71 Sept 1 003 Numeric Values Storing the value of 5 10 using ASCII: 00110010 00110101 Binary notation: 00000000
More informationNumber Systems. Both numbers are positive
Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of
More informationPART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP
EPE PIC TUTORIAL V2 JOHN BECKER PART TWO Quite simply the easiest low-cost way to learn about using PIC Microcontrollers! EPE PIC TUTORIAL In this part we play with switches, make noises, count times,
More informationCPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS
CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:
More informationCPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS
CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:
More informationLecture 2: Number Systems
Lecture 2: Number Systems Syed M. Mahmud, Ph.D ECE Department Wayne State University Original Source: Prof. Russell Tessier of University of Massachusetts Aby George of Wayne State University Contents
More informationComputer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2
Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up
More information10.1. Unit 10. Signed Representation Systems Binary Arithmetic
0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system
More informationD:\PICstuff\PartCounter\PartCounter.asm
1 ;********************************************************************** 2 ; This file is a basic code template for assembly code generation * 3 ; on the PICmicro PIC16F84A. This file contains the basic
More informationAPPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller
Maxim/Dallas > App Notes > REAL-TIME CLOCKS Keywords: DS1305, SPI, PIC, real time clock, RTC, spi interface, pic microcontroller Aug 20, 2003 APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with
More informationcarry in carry 1101 carry carry
Chapter Binary arithmetic Arithmetic is the process of applying a mathematical operator (such as negation or addition) to one or more operands (the values being operated upon). Binary arithmetic works
More informationChapter 4. Operations on Data
Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations
More informationAdding Binary Integers. Part 4. Negative Binary. Integers. Adding Base 10 Numbers. Adding Binary Example = 10. Arithmetic Logic Unit
Part 4 Adding Binary Integers Arithmetic Logic Unit = Adding Binary Integers Adding Base Numbers Computer's add binary numbers the same way that we do with decimal Columns are aligned, added, and "'s"
More informationChapter 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
More informationHardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed
EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 18th February 2002 CLR Part V Hardware Interfacing There are several features of computers/microcontrollers which have not
More informationCPE300: Digital System Architecture and Design
CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Arithmetic Unit 10122011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Recap Fixed Point Arithmetic Addition/Subtraction
More informationBits, Words, and Integers
Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are
More information