Assembler Programming. Lecture 9

Size: px
Start display at page:

Download "Assembler Programming. Lecture 9"

Transcription

1 Assembler Programming Lecture 9

2 Lecture 9 Floating point coprocessor instructions. MMX instructions.

3 Math coprocessor 8087, 80287, separate chips. i486dx and above built in. Clculate many times faster then 8086-based processor: real numbers, packed BCD numbers, long integers. Has its own set of registers.

4 Math coprocessor registers R7 R6 R5 R4 R3 R2 R1 R ST(1) ST Sign Exponent Significand

5 Groups of the instructions Classical stack format. Memory. Register. Register pop.

6 Classical stack format Instructions treat registers like a stack. Only a top item can be accessed. First and sometimes second registers are assumed. ST is the source operand. ST(1) is the destination operand. Source is popped off the stack. Result is at the top of the stack.

7 Memory format Instructions treat registers like a stack. Item are pushed from memory or popped to the memory. Memory operand is always the source operand. ST is the destination operand. Result is at the top of the stack without popping the destination operand.

8 Register format Instructions treat registers like a registers. One operand is always the stack top ST. First operand is the destination. Second operand is the source. Stack position does not change.

9 Register pop format Instructions treat registers as modified stack. Source must be the ST (stack top). Destination is the other register. Result is placed into te destination register. Source (top) is popped off the stack.

10 Coprocessor instructions Loading and storing data. Doing arithmetic calculations. Controlling program flow.

11 Loading and Storing Data Copy data between memory and registers. Copy data between registers. Data in memory can be: integer, BCD number, real number. Data transferred to coprocessor is always 10- byte real number.

12 Loading and Storing Data Load commands push data onto the stack. Store commands pop data off the stack or copy the data to other register. Constants can not be operands. You can load constants like 0, 1, pi with special instructions. You can save the coprocessor status to the memory and later load the status back into registers.

13 Loading and storing data FLD, FST, FSTP - Loads and stores real numbers. FILD, FIST, FISTP - Loads and stores binary integers. FBLD - Loads BCD. FBSTP - Stores BCD. FXCH - Exchanges register values. In all istructions P means popping the ST.

14 Loading constants FLDZ - Pushes 0 into ST. FLD1 - Pushes 1 into ST. FLDPI - Pushes the value of pi into ST. FLDL2E - Pushes the value of log2e into ST. FLDL2T - Pushes log210 into ST. FLDLG2 - Pushes log102 into ST. FLDLN2 - Pushes loge2 into ST.

15 Loading and storing status FLDCW mem2byte - Loads the control word into the coprocessor F[[N]]STCW mem2byte - Stores the control word in memory FLDENV mem14byte - Loads environment from memory F[[N]]STENV mem14byte - Stores environment in memory FRSTOR mem94byte - Restores state from memory F[[N]]SAVE mem94byte - Saves state in memory

16 Loading and storing example.data m1 m1 REAL4 1.0 m2 m2 REAL4 2.0.CODE fld m1 m1 ; Push m1 m1 into first item fld st(2) ; Push third item into first fst m2 m2 ; Copy first item to to m2 m2 fxch st(2) ; Exchange first and third items fstp m1 m1 ; Pop first item into m1 m1

17 Arithmetic calculations FADD - Adds the source and destination. FSUB - Subtracts the source from the destination. FSUBR - Subtracts the destination from the source. FMUL - Multiplies the source and the destination. FDIV - Divides the destination by the source. FDIVR - Divides the source by the destination. FABS - Sets the sign of ST to positive. FCHS - Reverses the sign of ST.

18 Arithmetic calculations FRNDINT - Rounds ST to an integer. FSQRT - Replaces the contents of ST with its square root. FSCALE - Multiplies the stack-top value by 2 to the power contained in ST(1). FPREM - Calculates the remainder of ST divided by ST(1).

19 Arithmetic calculations 387 FSIN - Calculates the sine of the value in ST FCOS - Calculates the cosine of the value in ST FSINCOS - Calculates the sine and cosine of the value in ST FPTAN - Calculates the tangent of the value in ST FPATAN - Calculates the arctangent of the ratio Y/X

20 Arithmetic calculations 387 FPREM1 - Calculates the partial remainder by performing modulo division on the top two stack registers FXTRACT - Breaks a number down into its exponent and mantissa and pushes the mantissa onto the register stack F2XM1 - Calculates 2 x 1 FYL2X - Calculates Y * log 2 X FYL2XP1 - Calculates Y * log 2 (X+1)

21 Arithmetic calculations 387 F[[N]]INIT - Resets the coprocessor and restores all the default conditions in the control and status words F[[N]]CLEX - Clears all exception flags and the busy flag of the status word FINCSTP - Adds 1 to the stack pointer in the status word FDECSTP - Subtracts 1 from the stack pointer in the status word FFREE - Marks the specified register as empty

22 Arithmetic calculations - Example.DATA a REAL b REAL cc cc REAL posx REAL negx REAL CODE. ; Solve quadratic equation - no no error checking ; The The formula is: is: -b -b +/- +/- squareroot(b2-4ac) / (2a) fld1 ; Get Get constants 2 and and 4 fadd st,st ; 2 at at bottom fld fld st st ; Copy it it fmul a ; = 2a 2a fmul st(1),st ; = 4a 4a fxch ; Exchange st st and and st(1) fmul cc cc ; = 4ac 4ac

23 fld fld b ; Load b fmul st,st ; = b2 b2 fsubr ; = b2 b2-4ac 4ac ; Negative value here produces error fsqrt ; = square root(b2-4ac) fld fld b ; Load b fchs ; Make it it negative fxch ; Exchange fld fld st st ; Copy square root fadd st,st(2) ; Plus version = -b -b + root(b2-4ac) fxch ; Exchange fsubp st(2),st ; Minus version = -b -b - root(b2-4ac) fdiv st,st(2) ; Divide plus version fstp posx ; Store it it fdivr ; Divide minus version fstp negx ; Store it it

24 Invalid operation Denormalized Zero divide Overflow Underflow Precision Stack fault Exception flag Condition codes Top of stack Reserved Status Word register SW C3 C2 C1 C0 Exception flags

25 Controlling program flow Status word can be stored: intothememory, into the AX register (80287 and above). Coprocessor have instructions for: comparing operands, testing control flags. These instructions compare the ST to: specified source operand, ST(1) if not specified.

26 Controlling program flow FCOM - Compares the stack top to the source. The source and destination are unaffected by the comparison. FTST - Compares ST to 0. FCOMP - Compares the stack top to the source and then pops the stack. FUCOM, FUCOMP, FUCOMPP - Compares the source to ST and sets the condition codes of the status word according to the result (80386/486 only). F[[N]]STSW mem2byte - Stores the status word in memory. FXAM - Sets the value of the control flags based on the type of the number in ST.

27 Controlling program flow FPREM - Finds a correct remainder for large operands. It uses the C2 flag to indicate whether the remainder returned is partial (C2 is set) or complete (C2 is clear). FNOP - Copies the stack top onto itself without having any effect on registers or memory. FDISI, FNDISI, FENI, FNENI - Enables or disables interrupts (8087 only). FSETPM - Sets protected mode. Requires a.286p or.386p directive (80287, 80387, and only).

28 Controlling the flow - Example.DATA down REAL ; Sides of of a rectangle across REAL diamtr REAL ; Diameter of of a circle status WORD? P287 EQU EQU (@Cpu AND AND 00111y).CODE ; Get Get area of of rectangle fld fld across ; Load one one side fmul down ; Multiply by by the the other ; Get Get area of of circle: Area = PI PI * (D/2)2 fld1 ; Load one one and and fadd st, st, st st ; double it it to to get get constant 2 fdivr diamtr ; Divide diameter to to get get radius fmul st, st, st st ; Square radius fldpi ; Load pi pi fmul ; Multiply it it

29 ; Compare area of of circle and and rectangle fcompp ; Compare and and throw both away IF IF p287 fstsw ax ax ; (For 287+, skip memory) ELSE fnstsw status ; Load from coprocessor to to memory mov mov ax, ax, status ; Transfer memory to to register ENDIF sahf ; Transfer AH AH to to flags register jp jp nocomp ; If If parity set, can't compare jz jz same ; If If zero set, they're the the same jc jc rectangle ; If If carry set, rect. is is bigger jmp jmp circle ; else circle is is bigger nocomp: same: rectangle: circle: ; Error handler ; Both equal ; Rectangle bigger ; Circle bigger

30 Program flow new mechanism Available beginning with the P6 family processors. New instructions: FCOMI, FCOMIP, FUCOMI, FUCOMIP, compare and set ZF, PF, and CF flags in the EFLAGS register directly. New conditional transfer instructions: FCMOVcc, conditionally moves floating point values eliminates branches.

31 Memory access When using the coprocessor, follow these three steps: Load data from memory to coprocessor registers. Process the data. Store the data from coprocessor registers back to memory. Processing the data, can occur while the main processor is handling other tasks. Loading and storing data must be coordinated

32 Memory access Coprocessor instruction follows a processor instruction: assembler coordinates this conflict automatically for 8086, processor coordnates it automatically on and above processors. ; Processor instruction first - No No wait needed mov mov WORD PTR PTR mem32[0], ax ax ; Load memory mov mov WORD PTR PTR mem32[2], dx dx fild mem32 ; Load to to register

33 Memory access Processor instruction follows a coprocessor instruction: synchronization is not automatic, You must include WAIT or FWAIT instruction. ; Coprocessor instruction first - Wait needed fist mem32 ; Store to to memory fwait ; Wait until ; coprocessor is is done mov mov ax, ax, WORD PTR PTR mem32[0] ; Move to to register mov mov dx, dx, WORD PTR PTR mem32[2]

34 Coprocessor example ; counting average of of table elements count DW DW average REAL mov mov cx,count mov mov si,table fld fld qword ptr ptr [si] ; load first element to to the the ST ST dec dec cx cx sum: add add si,8 ; index of of next element fld fld qword ptr ptr [si] ; load next element to to the the ST ST fadd ; add add ST(1) to to ST ST loop sum sum fidiv count ; divide sum sum in in ST ST / count fstp average ; store the the result

35 MMX Introduced in the Pentium MMX. SIMD Single Instruction Multiple Data. Handles 64-bit packed integer data. Works on 8 new 64-bit registers. Three new packed data types: 64-bit packed byte integers (signed and unsigned). 64-bit packed word integers (signed and unsigned). 64-bit packed doubleword integers (signed and unsigned). 47 new instructions.

36 MMX registers 80-bit math coprocessor registers R MM7 R6 R5 R4 R3 R2 R1 MM6 MM5 MM4 MM3 MM2 MM1 R0 MM0 64-bit MMX registers

37 MMX data types Packed byte Byte Byte Byte Byte Byte Byte Byte Byte Packed word Word Word Word Word Packed doubleword Doubleword Doubleword 63 0

38 SIMD instructions Source operand Word Word Word Word Packed word PADDSW Source operand Word Word Word Word Packed word = = = = Destination Word Word Word Word Packed word

39 Wraparound Source operand 0000 FFFF 8000 FFFF Packed word PADDW Source operand FFFF Packed word = = = = Destination FFFE Packed word

40 Signed saturation Source operand 0000 FFFF 8000 FFFF Packed word PADDSW Source operand FFFF Packed word = = = = Destination FFFE Packed word

41 Unsigned saturation Source operand 0000 FFFF 8000 FFFF Packed word PADDUSW Source operand FFFF Packed word = = = = Destination 0001 FFFF FFFF FFFF Packed word

42 MMX instructions Data transfer Arithmetic Comparison Conversion Unpacking Logical Shift Empty MMX state instruction (EMMS)

43 Data transfer MOVD moves 32 bits between MMX register and memory, or general purpose register. MOVQ - moves 64 bits between MMX register and memory, or between MMX registers.

44 Arithmetic instructions PADDB, PADDW, PADDD add packed integers with wraparound. PSUBB, PSUBW, PSUBD subtract packed integers with wraparound. PADDSB, PADDSW add packed signed integers with signed saturation. PSUBSB, PSUBSW subtract packed signed integers with signed saturation PADDUSB, PADDUSW add packed unsigned integers with unsigned saturation PSUBUSB, PSUBUSW subtract packed unsigned integers with unsigned saturation

45 Arithmetic instructions PMULHW multiply packed signed integers and store high result. PMULLW multiply packed signed integers and store low result. PMADDWD multiply and add packed integers.

46 Comparison instructions PCMPEQB, PCMPEQW, PCMPEQD compare packed data for equal. PCMPGTB, PCMPGTW, PCMPGTD compare packet signed data for greater than.

47 Conversion instructions PACKSSWB pack words into bytes with signed saturation. PACKSSDW pack doublewords into words with signed saturation. PACKUSWB pack words into bytes with unsigned saturation.

48 Unpack instructions PUNPCKHBW, PUNPCKHWD, PUNPCKHDQ unpack high-order data elements. PUNPCKLBW, PUNPCKLWD, PUNPCKLDQ unpack low-order data elements.

49 Logical instructions PAND bitwise logical AND. PANDN bitwise logical AND NOT. POR bitwise logical OR. PXOR bitwise logical exclusive OR.

50 Shift instructions PSLLW, PSLLD, PSLLQ shift packed data left logical. PSRLW, PSRLD, PSRLQ shift packed data right logical. PSRAW, PSRAD shift packed data right arithmetic.

51 EMMS instruction Indicates math coprocessor registers as empty. Must be executed at the end of MMX routine.

Programming With the x87 Floating- Point Unit

Programming With the x87 Floating- Point Unit Programming With the x87 Floating- Point Unit 8 CHAPTER 8 PROGRAMMING WITH THE X87 FPU The x87 Floating-Point Unit (FPU) provides high-performance floating-point processing capabilities for use in graphics

More information

Instruction Set Summary 30

Instruction Set Summary 30 30 This chapter lists all the instructions in the Intel Architecture instruction set, divided into three functional groups: integer, floating-point, and system. It also briefly describes each of the integer

More information

IA-32 Intel Architecture Software Developer s Manual

IA-32 Intel Architecture Software Developer s Manual IA-32 Intel Architecture Software Developer s Manual Volume 2B: Instruction Set Reference, N-Z NOTE: The IA-32 Intel Architecture Software Developer s Manual consists of four volumes: Basic Architecture,

More information

High-speed image processing algorithms using MMX hardware

High-speed image processing algorithms using MMX hardware High-speed image processing algorithms using MMX hardware J. W. V. Miller and J. Wood The University of Michigan-Dearborn ABSTRACT Low-cost PC-based machine vision systems have become more common due to

More information

SIMD Programming Manual for Linux and Windows

SIMD Programming Manual for Linux and Windows Paul Cockshott and Kenneth Renfrew SIMD Programming Manual for Linux and Windows Springer Contents List of Tables List of Figures List of Algorithms Introduction xvii xix xxiii xxv I SIMD Programming 1

More information

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1 Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

More information

Intel 64 and IA-32 Architectures Software Developer s Manual

Intel 64 and IA-32 Architectures Software Developer s Manual Intel 64 and IA-32 Architectures Software Developer s Manual Volume 1: Basic Architecture NOTE: The Intel 64 and IA-32 Architectures Software Developer's Manual consists of seven volumes: Basic Architecture,

More information

Using MMX Instructions to Convert RGB To YUV Color Conversion

Using MMX Instructions to Convert RGB To YUV Color Conversion Using MMX Instructions to Convert RGB To YUV Color Conversion Information for Developers and ISVs From Intel Developer Services www.intel.com/ids Information in this document is provided in connection

More information

Faculty of Engineering Student Number:

Faculty of Engineering Student Number: Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, First Semester: 2012/2013 Course Title: Microprocessors Date: 17/01//2013 Course No:

More information

IA-32 Intel Architecture Software Developer s Manual

IA-32 Intel Architecture Software Developer s Manual IA-32 Intel Architecture Software Developer s Manual Volume 1: Basic Architecture NOTE: The IA-32 Intel Architecture Software Developer s Manual consists of three volumes: Basic Architecture, Order Number

More information

Intel Architecture Software Developer s Manual

Intel Architecture Software Developer s Manual Intel Architecture Software Developer s Manual Volume 1: Basic Architecture NOTE: The Intel Architecture Software Developer s Manual consists of three volumes: Basic Architecture, Order Number 243190;

More information

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example BCD (ASCII) Arithmetic We will first look at unpacked BCD which means strings that look like '4567'. Bytes then look like 34h 35h 36h 37h OR: 04h 05h 06h 07h x86 processors also have instructions for packed

More information

PROBLEMS (Cap. 4 - Istruzioni macchina)

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

More information

8085 INSTRUCTION SET

8085 INSTRUCTION SET DATA TRANSFER INSTRUCTIONS Opcode Operand Description 8085 INSTRUCTION SET INSTRUCTION DETAILS Copy from source to destination OV Rd, Rs This instruction copies the contents of the source, Rs register

More information

Floating Point Arithmetic Chapter 14

Floating Point Arithmetic Chapter 14 Thi d t t d ith F M k 4 0 2 Floating Point Arithmetic Chapter 14 Although integers provide an exact representation for numeric values, they suffer from two major drawbacks: the inability to represent fractional

More information

PART B QUESTIONS AND ANSWERS UNIT I

PART B QUESTIONS AND ANSWERS UNIT I PART B QUESTIONS AND ANSWERS UNIT I 1. Explain the architecture of 8085 microprocessor? Logic pin out of 8085 microprocessor Address bus: unidirectional bus, used as high order bus Data bus: bi-directional

More information

5.14. EXCEPTION AND INTERRUPT REFERENCE

5.14. EXCEPTION AND INTERRUPT REFERENCE 5.14. EXCEPTION AND INTERRUPT REFERENCE The following sections describe conditions which generate exceptions and interrupts. They are arranged in the order of vector numbers. The information contained

More information

İSTANBUL AYDIN UNIVERSITY

İSTANBUL AYDIN UNIVERSITY İSTANBUL AYDIN UNIVERSITY FACULTY OF ENGİNEERİNG SOFTWARE ENGINEERING THE PROJECT OF THE INSTRUCTION SET COMPUTER ORGANIZATION GÖZDE ARAS B1205.090015 Instructor: Prof. Dr. HASAN HÜSEYİN BALIK DECEMBER

More information

Zero: If P is a polynomial and if c is a number such that P (c) = 0 then c is a zero of P.

Zero: If P is a polynomial and if c is a number such that P (c) = 0 then c is a zero of P. MATH 11011 FINDING REAL ZEROS KSU OF A POLYNOMIAL Definitions: Polynomial: is a function of the form P (x) = a n x n + a n 1 x n 1 + + a x + a 1 x + a 0. The numbers a n, a n 1,..., a 1, a 0 are called

More information

D.1 Introduction D-2 D.2 80x86 Registers and Data Addressing Modes D-3 D.3 80x86 Integer Operations D-6 D.4 80x86 Floating-Point Operations D-10 D.

D.1 Introduction D-2 D.2 80x86 Registers and Data Addressing Modes D-3 D.3 80x86 Integer Operations D-6 D.4 80x86 Floating-Point Operations D-10 D. D.1 Introduction D-2 D.2 80x86 Registers and Data Addressing Modes D-3 D.3 80x86 Integer Operations D-6 D.4 80x86 Floating-Point Operations D-10 D.5 80x86 Instruction Encoding D-12 D.6 Putting It All Together:

More information

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

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

More information

IA-32 Intel Architecture Software Developer s Manual

IA-32 Intel Architecture Software Developer s Manual IA-32 Intel Architecture Software Developer s Manual Volume 1: Basic Architecture NOTE: The IA-32 Intel Architecture Software Developer s Manual consists of three volumes: Basic Architecture, Order Number

More information

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology LSN 2 Number Systems Department of Engineering Technology LSN 2 Decimal Number System Decimal number system has 10 digits (0-9) Base 10 weighting system... 10 5 10 4 10 3 10 2 10 1 10 0. 10-1 10-2 10-3

More information

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

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

More information

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD BCD (ASCII) Arithmetic The Intel Instruction set can handle both packed (two digits per byte) and unpacked BCD (one decimal digit per byte) We will first look at unpacked BCD Unpacked BCD can be either

More information

Using the RDTSC Instruction for Performance Monitoring

Using the RDTSC Instruction for Performance Monitoring Using the Instruction for Performance Monitoring http://developer.intel.com/drg/pentiumii/appnotes/pm1.htm Using the Instruction for Performance Monitoring Information in this document is provided in connection

More information

Complete 8086 instruction set

Complete 8086 instruction set Page 1 of 53 Complete 8086 instruction set Quick reference: AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD CLI CMC CMP CMPSB CMPSW CWD DAA DAS DEC DIV HLT IDIV IMUL IN INC INT INTO I JA JAE JB JBE JC JCXZ

More information

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8 ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: -Our standard number system is base, also

More information

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s)

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s) Addressing The problem Objectives:- When & Where do we encounter Data? The concept of addressing data' in computations The implications for our machine design(s) Introducing the stack-machine concept Slide

More information

CPU performance monitoring using the Time-Stamp Counter register

CPU performance monitoring using the Time-Stamp Counter register CPU performance monitoring using the Time-Stamp Counter register This laboratory work introduces basic information on the Time-Stamp Counter CPU register, which is used for performance monitoring. The

More information

Computer Organization and Architecture

Computer Organization and Architecture Computer Organization and Architecture Chapter 11 Instruction Sets: Addressing Modes and Formats Instruction Set Design One goal of instruction set design is to minimize instruction length Another goal

More information

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30)); Introduction to Embedded Microcomputer Systems Lecture 5.1 2.9. Conversions ASCII to binary n = 100*(Data[0]-0x30) + 10*(Data[1]-0x30) + (Data[2]-0x30); This 3-digit ASCII string could also be calculated

More information

Computer Organization. and Instruction Execution. August 22

Computer Organization. and Instruction Execution. August 22 Computer Organization and Instruction Execution August 22 CSC201 Section 002 Fall, 2000 The Main Parts of a Computer CSC201 Section Copyright 2000, Douglas Reeves 2 I/O and Storage Devices (lots of devices,

More information

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes: Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes: An 8 or 16 bit microprocessor (CPU). A small amount of RAM. Programmable ROM and/or flash memory.

More information

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

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

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

An Introduction to the ARM 7 Architecture

An Introduction to the ARM 7 Architecture An Introduction to the ARM 7 Architecture Trevor Martin CEng, MIEE Technical Director This article gives an overview of the ARM 7 architecture and a description of its major features for a developer new

More information

CHAPTER 5 Round-off errors

CHAPTER 5 Round-off errors CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any

More information

Z80 Instruction Set. Z80 Assembly Language

Z80 Instruction Set. Z80 Assembly Language 75 Z80 Assembly Language The assembly language allows the user to write a program without concern for memory addresses or machine instruction formats. It uses symbolic addresses to identify memory locations

More information

MACHINE ARCHITECTURE & LANGUAGE

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

More information

1 The Java Virtual Machine

1 The Java Virtual Machine 1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This

More information

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified)

More information

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture

More information

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

More information

The 80x86 Instruction Set

The 80x86 Instruction Set Thi d t t d ith F M k 4 0 2 The 80x86 Instruction Set Chapter Six Until now, there has been little discussion of the instructions available on the 80x86 microprocessor. This chapter rectifies this situation.

More information

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX Overview CISC Developments Over Twenty Years Classic CISC design: Digital VAX VAXÕs RISC successor: PRISM/Alpha IntelÕs ubiquitous 80x86 architecture Ð 8086 through the Pentium Pro (P6) RJS 2/3/97 Philosophy

More information

Attention: This material is copyright 1995-1997 Chris Hecker. All rights reserved.

Attention: This material is copyright 1995-1997 Chris Hecker. All rights reserved. Attention: This material is copyright 1995-1997 Chris Hecker. All rights reserved. You have permission to read this article for your own education. You do not have permission to put it on your website

More information

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 January 22, 2013 Name: Grade /10 Introduction: In this lab you will write, test, and execute a number of simple PDP-8

More information

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture

More information

x64 Cheat Sheet Fall 2015

x64 Cheat Sheet Fall 2015 CS 33 Intro Computer Systems Doeppner x64 Cheat Sheet Fall 2015 1 x64 Registers x64 assembly code uses sixteen 64-bit registers. Additionally, the lower bytes of some of these registers may be accessed

More information

Systems I: Computer Organization and Architecture

Systems I: Computer Organization and Architecture Systems I: Computer Organization and Architecture Lecture 2: Number Systems and Arithmetic Number Systems - Base The number system that we use is base : 734 = + 7 + 3 + 4 = x + 7x + 3x + 4x = x 3 + 7x

More information

How To Write A Hexadecimal Program

How To Write A Hexadecimal Program The mathematics of RAID-6 H. Peter Anvin First version 20 January 2004 Last updated 20 December 2011 RAID-6 supports losing any two drives. syndromes, generally referred P and Q. The way

More information

FLOATING-POINT ARITHMETIC IN AMD PROCESSORS MICHAEL SCHULTE AMD RESEARCH JUNE 2015

FLOATING-POINT ARITHMETIC IN AMD PROCESSORS MICHAEL SCHULTE AMD RESEARCH JUNE 2015 FLOATING-POINT ARITHMETIC IN AMD PROCESSORS MICHAEL SCHULTE AMD RESEARCH JUNE 2015 AGENDA The Kaveri Accelerated Processing Unit (APU) The Graphics Core Next Architecture and its Floating-Point Arithmetic

More information

DNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk

DNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk DNA Data and Program Representation Alexandre David 1.2.05 adavid@cs.aau.dk Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued

More information

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers This Unit: Floating Point Arithmetic CIS 371 Computer Organization and Design Unit 7: Floating Point App App App System software Mem CPU I/O Formats Precision and range IEEE 754 standard Operations Addition

More information

150127-Microprocessor & Assembly Language

150127-Microprocessor & Assembly Language Chapter 3 Z80 Microprocessor Architecture The Z 80 is one of the most talented 8 bit microprocessors, and many microprocessor-based systems are designed around the Z80. The Z80 microprocessor needs an

More information

Instruction Set Architecture

Instruction Set Architecture Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)

More information

Computer Organization and Assembly Language

Computer Organization and Assembly Language Computer Organization and Assembly Language Lecture 8 - Strings and Arrays Introduction We already know that assembly code will execute significantly faster than code written in a higher-level language

More information

Application Note 195. ARM11 performance monitor unit. Document number: ARM DAI 195B Issued: 15th February, 2008 Copyright ARM Limited 2007

Application Note 195. ARM11 performance monitor unit. Document number: ARM DAI 195B Issued: 15th February, 2008 Copyright ARM Limited 2007 Application Note 195 ARM11 performance monitor unit Document number: ARM DAI 195B Issued: 15th February, 2008 Copyright ARM Limited 2007 Copyright 2007 ARM Limited. All rights reserved. Application Note

More information

A Tiny Guide to Programming in 32-bit x86 Assembly Language

A Tiny Guide to Programming in 32-bit x86 Assembly Language CS308, Spring 1999 A Tiny Guide to Programming in 32-bit x86 Assembly Language by Adam Ferrari, ferrari@virginia.edu (with changes by Alan Batson, batson@virginia.edu and Mike Lack, mnl3j@virginia.edu)

More information

Keil C51 Cross Compiler

Keil C51 Cross Compiler Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation

More information

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until

More information

Numerical Matrix Analysis

Numerical Matrix Analysis Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research

More information

X86-64 Architecture Guide

X86-64 Architecture Guide X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int

More information

1 Classical Universal Computer 3

1 Classical Universal Computer 3 Chapter 6: Machine Language and Assembler Christian Jacob 1 Classical Universal Computer 3 1.1 Von Neumann Architecture 3 1.2 CPU and RAM 5 1.3 Arithmetic Logical Unit (ALU) 6 1.4 Arithmetic Logical Unit

More information

LSN 2 Computer Processors

LSN 2 Computer Processors LSN 2 Computer Processors Department of Engineering Technology LSN 2 Computer Processors Microprocessors Design Instruction set Processor organization Processor performance Bandwidth Clock speed LSN 2

More information

Lecture 2. Binary and Hexadecimal Numbers

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

More information

CHAPTER 7: The CPU and Memory

CHAPTER 7: The CPU and Memory CHAPTER 7: The CPU and Memory The Architecture of Computer Hardware, Systems Software & Networking: An Information Technology Approach 4th Edition, Irv Englander John Wiley and Sons 2010 PowerPoint slides

More information

8051 hardware summary

8051 hardware summary 8051 hardware summary 8051 block diagram 8051 pinouts + 5V ports port 0 port 1 port 2 port 3 : dual-purpose (general-purpose, external memory address and data) : dedicated (interfacing to external devices)

More information

Systems Design & Programming Data Movement Instructions. Intel Assembly

Systems Design & Programming Data Movement Instructions. Intel Assembly Intel Assembly Data Movement Instruction: mov (covered already) push, pop lea (mov and offset) lds, les, lfs, lgs, lss movs, lods, stos ins, outs xchg, xlat lahf, sahf (not covered) in, out movsx, movzx

More information

ModuMath Basic Math Basic Math 1.1 - Naming Whole Numbers Basic Math 1.2 - The Number Line Basic Math 1.3 - Addition of Whole Numbers, Part I

ModuMath Basic Math Basic Math 1.1 - Naming Whole Numbers Basic Math 1.2 - The Number Line Basic Math 1.3 - Addition of Whole Numbers, Part I ModuMath Basic Math Basic Math 1.1 - Naming Whole Numbers 1) Read whole numbers. 2) Write whole numbers in words. 3) Change whole numbers stated in words into decimal numeral form. 4) Write numerals in

More information

CSC 2405: Computer Systems II

CSC 2405: Computer Systems II CSC 2405: Computer Systems II Spring 2013 (TR 8:30-9:45 in G86) Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Introductions Mirela Damian Room 167A in the Mendel Science Building mirela.damian@villanova.edu

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

The mathematics of RAID-6

The mathematics of RAID-6 The mathematics of RAID-6 H. Peter Anvin 1 December 2004 RAID-6 supports losing any two drives. The way this is done is by computing two syndromes, generally referred P and Q. 1 A quick

More information

The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition

The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition Online Instructor s Manual to accompany The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition Muhammad Ali Mazidi Janice Gillispie Mazidi Danny Causey Prentice Hall Boston Columbus Indianapolis

More information

CHAPTER 4 MARIE: An Introduction to a Simple Computer

CHAPTER 4 MARIE: An Introduction to a Simple Computer CHAPTER 4 MARIE: An Introduction to a Simple Computer 4.1 Introduction 195 4.2 CPU Basics and Organization 195 4.2.1 The Registers 196 4.2.2 The ALU 197 4.2.3 The Control Unit 197 4.3 The Bus 197 4.4 Clocks

More information

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left. The verbal answers to all of the following questions should be memorized before completion of pre-algebra. Answers that are not memorized will hinder your ability to succeed in algebra 1. Number Basics

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

An Introduction to Assembly Programming with the ARM 32-bit Processor Family An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2

More information

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis 1 1 Table of Contents 1 Table of Contents... 3 2 Overview... 5 3 Installation... 7 4 The CPU

More information

HC12 Assembly Language Programming

HC12 Assembly Language Programming HC12 Assembly Language Programming Programming Model Addressing Modes Assembler Directives HC12 Instructions Flow Charts 1 Assembler Directives In order to write an assembly language program it is necessary

More information

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will: 6 Objectives After completing this lab you will: know how to do integer arithmetic in MIPS know how to do floating point arithmetic in MIPS know about conversion from integer to floating point and from

More information

SAT Subject Math Level 2 Facts & Formulas

SAT Subject Math Level 2 Facts & Formulas Numbers, Sequences, Factors Integers:..., -3, -2, -1, 0, 1, 2, 3,... Reals: integers plus fractions, decimals, and irrationals ( 2, 3, π, etc.) Order Of Operations: Arithmetic Sequences: PEMDAS (Parentheses

More information

Traditional IBM Mainframe Operating Principles

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

More information

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9. Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables

More information

7.1 Our Current Model

7.1 Our Current Model Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.

More information

Chapter 5 Instructor's Manual

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

More information

EC 362 Problem Set #2

EC 362 Problem Set #2 EC 362 Problem Set #2 1) Using Single Precision IEEE 754, what is FF28 0000? 2) Suppose the fraction enhanced of a processor is 40% and the speedup of the enhancement was tenfold. What is the overall speedup?

More information

CS201: Architecture and Assembly Language

CS201: Architecture and Assembly Language CS201: Architecture and Assembly Language Lecture Three Brendan Burns CS201: Lecture Three p.1/27 Arithmetic for computers Previously we saw how we could represent unsigned numbers in binary and how binary

More information

Assembly Language Tutorial

Assembly Language Tutorial Assembly Language Tutorial ASSEMBLY LANGUAGE TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Assembly Programming Tutorial Assembly language is a low-level programming language for

More information

Instruction Set Design

Instruction Set Design Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,

More information

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC Chapter 2 Topics 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC See Appendix C for Assembly language information. 2.4

More information

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

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

More information

Introduction to Microcontrollers

Introduction to Microcontrollers Introduction to Microcontrollers Motorola M68HC11 Specs Assembly Programming Language BUFFALO Topics of Discussion Microcontrollers M68HC11 Package & Pinouts Accumulators Index Registers Special Registers

More information

Computer Science 281 Binary and Hexadecimal Review

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

More information

How To Hack The Steam Voip On Pc Orchesterian Moonstone 2.5 (Windows) On Pc/Robert Kruber (Windows 2) On Linux 2.2.2 (Windows 3.5) On A Pc

How To Hack The Steam Voip On Pc Orchesterian Moonstone 2.5 (Windows) On Pc/Robert Kruber (Windows 2) On Linux 2.2.2 (Windows 3.5) On A Pc ReVuln Ltd. http://revuln.com @revuln info@revuln.com Revision 3 STEAM VOIP SECURITY BY LUIGI AURIEMMA Overview and details about the security issues found in the Steam voice framework. TABLE OF CONTENTS

More information

Quick Reference ebook

Quick Reference ebook This file is distributed FREE OF CHARGE by the publisher Quick Reference Handbooks and the author. Quick Reference ebook Click on Contents or Index in the left panel to locate a topic. The math facts listed

More information

EE361: Digital Computer Organization Course Syllabus

EE361: Digital Computer Organization Course Syllabus EE361: Digital Computer Organization Course Syllabus Dr. Mohammad H. Awedh Spring 2014 Course Objectives Simply, a computer is a set of components (Processor, Memory and Storage, Input/Output Devices)

More information

Expression. Variable Equation Polynomial Monomial Add. Area. Volume Surface Space Length Width. Probability. Chance Random Likely Possibility Odds

Expression. Variable Equation Polynomial Monomial Add. Area. Volume Surface Space Length Width. Probability. Chance Random Likely Possibility Odds Isosceles Triangle Congruent Leg Side Expression Equation Polynomial Monomial Radical Square Root Check Times Itself Function Relation One Domain Range Area Volume Surface Space Length Width Quantitative

More information

Fast Arithmetic Coding (FastAC) Implementations

Fast Arithmetic Coding (FastAC) Implementations Fast Arithmetic Coding (FastAC) Implementations Amir Said 1 Introduction This document describes our fast implementations of arithmetic coding, which achieve optimal compression and higher throughput by

More information

Math 115 Spring 2011 Written Homework 5 Solutions

Math 115 Spring 2011 Written Homework 5 Solutions . Evaluate each series. a) 4 7 0... 55 Math 5 Spring 0 Written Homework 5 Solutions Solution: We note that the associated sequence, 4, 7, 0,..., 55 appears to be an arithmetic sequence. If the sequence

More information