The Art of Assembly Language

Size: px
Start display at page:

Download "The Art of Assembly Language"

Transcription

1 Hello, World of Assembly Language The Art of Assembly Language (Full Contents) The Art of Assembly Language Programming is going hard. In early 2003 this text will be available in published form from No Starch Press ( Please check out their website for more details. 1.1 Foreword to the HLA Version of The Art of Assembly Intended Audience Teaching From This Text Copyright Notice How to Get a Hard Copy of This Text Obtaining Program Source Listings and Other Materials in This Text Where to Get Help Other Materials You Will Need (Windows Version) Other Materials You Will Need (Linux Version) Chapter Overview Installing the HLA Distribution Package Installation Under Windows Installation Under Linux Installing Art of Assembly Related Files The Anatomy of an HLA Program Some Basic HLA Data Declarations Boolean Values Character Values An Introduction to the Intel 80x86 CPU Family Some Basic Machine Instructions Some Basic HLA Control Structures Boolean Expressions in HLA Statements The HLA IF..THEN..ELSEIF..ELSE..ENDIF Statement The WHILE..ENDWHILE Statement The FOR..ENDFOR Statement The REPEAT..UNTIL Statement The BREAK and BREAKIF Statements The FOREVER..ENDFOR Statement The TRY..EXCEPTION..ENDTRY Statement Introduction to the HLA Standard Library Predefined Constants in the STDIO Module Standard In and Standard Out The stdout.newln Routine Beta Draft - Do not distribute 2001, By Randall Hyde Page 1

2 AoATOC.fm The stdout.putix Routines The stdout.putixsize Routines The stdout.put Routine The stdin.getc Routine The stdin.getix Routines The stdin.readln and stdin.flushinput Routines The stdin.get Macro Putting It All Together Sample Programs Powers of Two Table Generation Checkerboard Program Fibonacci Number Generation Chapter Overview Numbering Systems A Review of the Decimal System The Binary Numbering System Binary Formats Data Organization Bits Nibbles Bytes Words Double Words The Hexadecimal Numbering System Arithmetic Operations on Binary and Hexadecimal Numbers A Note About Numbers vs. Representation Logical Operations on Bits Logical Operations on Binary Numbers and Bit Strings Signed and Unsigned Numbers Sign Extension, Zero Extension, Contraction, and Saturation Shifts and Rotates Bit Fields and Packed Data Putting It All Together Chapter Overview An Introduction to Floating Point Arithmetic IEEE Floating Point Formats HLA Support for Floating Point Values Binary Coded Decimal (BCD) Representation Characters The ASCII Character Encoding HLA Support for ASCII Characters The ASCII Character Set The UNICODE Character Set Other Data Representations Page , By Randall Hyde Beta Draft - Do not distribute

3 4.6.1 Representing Colors on a Video Display Representing Audio Information Representing Musical Information Representing Video Information Where to Get More Information About Data Types Putting It All Together Questions Programming Projects for Chapter Two Programming Projects for Chapter Three Programming Projects for Chapter Four Laboratory Exercises for Chapter Two A Short Note on Laboratory Exercises and Lab Reports Compiling Your First Program Compiling Other Programs Appearing in this Chapter Creating and Modifying HLA Programs Writing a New Program Correcting Errors in an HLA Program Write Your Own Sample Program Laboratory Exercises for Chapter Three and Chapter Four Data Conversion Exercises Logical Operations Exercises Sign and Zero Extension Exercises Packed Data Exercises Running this Chapter s Sample Programs Write Your Own Sample Program Chapter Overview The Basic System Components The System Bus The Data Bus The Address Bus The Control Bus The Memory Subsystem The I/O Subsystem HLA Support for Data Alignment System Timing The System Clock Memory Access and the System Clock Wait States Cache Memory Putting It All Together Chapter Overview The 80x86 Addressing Modes x86 Register Addressing Modes x86 32-bit Memory Addressing Modes The Displacement Only Addressing Mode The Register Indirect Addressing Modes Indexed Addressing Modes Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 3

4 AoATOC.fm Variations on the Indexed Addressing Mode Scaled Indexed Addressing Modes Addressing Mode Wrap-up Run-Time Memory Organization The Code Section The Static Sections The Read-Only Data Section The Storage Section Attribute The Var Section Organization of Declaration Sections Within Your Programs Address Expressions Type Coercion Register Type Coercion The Stack Segment and the Push and Pop Instructions The Basic PUSH Instruction The Basic POP Instruction Preserving Registers With the PUSH and POP Instructions The Stack is a LIFO Data Structure Other PUSH and POP Instructions Removing Data From the Stack Without Popping It Accessing Data You ve Pushed on the Stack Without Popping It Dynamic Memory Allocation and the Heap Segment The INC and DEC Instructions Obtaining the Address of a Memory Object Bonus Section: The HLA Standard Library CONSOLE Module Clearing the Screen Positioning the Cursor Locating the Cursor Text Attributes Filling a Rectangular Section of the Screen Console Direct String Output Other Console Module Routines Putting It All Together Boolean Algebra Boolean Functions and Truth Tables Algebraic Manipulation of Boolean Expressions Canonical Forms Simplification of Boolean Functions What Does This Have To Do With Computers, Anyway? Correspondence Between Electronic Circuits and Boolean Functions Combinatorial Circuits Sequential and Clocked Logic Okay, What Does It Have To Do With Programming, Then? Putting It All Together Page , By Randall Hyde Beta Draft - Do not distribute

5 4.1 Chapter Overview The History of the 80x86 CPU Family A History of Software Development for the x Basic CPU Design Decoding and Executing Instructions: Random Logic Versus Microcode RISC vs. CISC vs. VLIW Instruction Execution, Step-By-Step Parallelism the Key to Faster Processors The Prefetch Queue Using Unused Bus Cycles Pipelining Overlapping the Execution of Multiple Instructions A Typical Pipeline Stalls in a Pipeline Instruction Caches Providing Multiple Paths to Memory Hazards Superscalar Operation Executing Instructions in Parallel Out of Order Execution Register Renaming Very Long Instruction Word Architecture (VLIW) Parallel Processing Multiprocessing Putting It All Together Chapter Overview The Importance of the Design of the Instruction Set Basic Instruction Design Goals Addressing Modes on the Y Encoding Y86 Instructions Hand Encoding Instructions Using an Assembler to Encode Instructions Extending the Y86 Instruction Set Encoding 80x86 Instructions Encoding Instruction Operands Encoding the ADD Instruction: Some Examples Encoding Immediate Operands Encoding Eight, Sixteen, and Thirty-Two Bit Operands Alternate Encodings for Instructions Putting It All Together Chapter Overview The Memory Hierarchy How the Memory Hierarchy Operates Relative Performance of Memory Subsystems Cache Architecture Virtual Memory, Protection, and Paging Thrashing NUMA and Peripheral Devices Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 5

6 AoATOC.fm 6.9 Segmentation Segments and HLA Renaming Segments Under Windows User Defined Segments in HLA (Windows Only) Controlling the Placement and Attributes of Segments in Memory (Windows Only) Putting it All Together Chapter Overview Connecting a CPU to the Outside World Read-Only, Write-Only, Read/Write, and Dual I/O Ports I/O (Input/Output) Mechanisms Memory Mapped Input/Output I/O Mapped Input/Output Direct Memory Access I/O Speed Hierarchy System Busses and Data Transfer Rates The AGP Bus Handshaking Time-outs on an I/O Port Interrupts and Polled I/O Using a Circular Queue to Buffer Input Data from an ISR Using a Circular Queue to Buffer Output Data for an ISR I/O and the Cache Protected Mode Operation Device Drivers Putting It All Together Questions Programming Projects Chapters One and Two Laboratory Exercises Memory Organization Exercises Data Alignment Exercises Readonly Segment Exercises Type Coercion Exercises Dynamic Memory Allocation Exercises Chapter Three Laboratory Exercises Truth Tables and Logic Equations Exercises Canonical Logic Equations Exercises Optimization Exercises Logic Evaluation Exercises Laboratory Exercises for Chapters Four, Five, Six, and Seven The SIMY86 Program Some Simple Y86 Programs Simple I/O-Mapped Input/Output Operations Memory Mapped I/O DMA Exercises Page , By Randall Hyde Beta Draft - Do not distribute

7 8.5.5 Interrupt Driven I/O Exercises Machine Language Programming & Instruction Encoding Exercises Self Modifying Code Exercises Virtual Memory Exercise Chapter Overview Some Additional Instructions: INTMUL, BOUND, INTO The QWORD and TBYTE Data Types HLA Constant and Value Declarations Constant Types String and Character Literal Constants String and Text Constants in the CONST Section Constant Expressions Multiple CONST Sections and Their Order in an HLA Program The HLA VAL Section Modifying VAL Objects at Arbitrary Points in Your Programs The HLA TYPE Section ENUM and HLA Enumerated Data Types Pointer Data Types Using Pointers in Assembly Language Declaring Pointers in HLA Pointer Constants and Pointer Constant Expressions Pointer Variables and Dynamic Memory Allocation Common Pointer Problems Putting It All Together Chapter Overview Composite Data Types Character Strings HLA Strings Accessing the Characters Within a String The HLA String Module and Other String-Related Routines In-Memory Conversions Putting It All Together Chapter Overview The HLA Standard Library CHARS.HHF Module Character Sets Character Set Implementation in HLA HLA Character Set Constants and Character Set Expressions The IN Operator in HLA HLL Boolean Expressions Character Set Support in the HLA Standard Library Using Character Sets in Your HLA Programs Low-level Implementation of Set Operations Character Set Functions That Build Sets Traditional Set Operations Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 7

8 AoATOC.fm Testing Character Sets Putting It All Together Chapter Overview Arrays Declaring Arrays in Your HLA Programs HLA Array Constants Accessing Elements of a Single Dimension Array Sorting an Array of Values Multidimensional Arrays Row Major Ordering Column Major Ordering Allocating Storage for Multidimensional Arrays Accessing Multidimensional Array Elements in Assembly Language Large Arrays and MASM Dynamic Arrays in Assembly Language HLA Standard Library Array Support Putting It All Together Chapter Overview Records Record Constants Arrays of Records Arrays/Records as Record Fields Controlling Field Offsets Within a Record Aligning Fields Within a Record Pointers to Records Unions Anonymous Unions Variant Types Namespaces Putting It All Together Chapter Overview Dates A Brief History of the Calendar HLA Date Functions date.isvalid and date.validate Checking for Leap Years Obtaining the System Date Date to String Conversions and Date Output date.unpack and data.pack date.julian, date.fromjulian date.dateplusdays, date.dateplusmonths, and date.daysbetween date.daynumber, date.daysleft, and date.dayofweek Page , By Randall Hyde Beta Draft - Do not distribute

9 6.5 Times time.curtime time.hmstosecs and time.secstohms Time Input/Output Putting It All Together Chapter Overview File Organization Files as Lists of Records Binary vs. Text Files Sequential Files Random Access Files ISAM (Indexed Sequential Access Method) Files Truncating a File File Utility Routines Copying, Moving, and Renaming Files Computing the File Size Deleting Files Directory Operations Putting It All Together Chapter Overview Procedures Saving the State of the Machine Prematurely Returning from a Procedure Local Variables Other Local and Global Symbol Types Parameters Pass by Value Pass by Reference Functions and Function Results Returning Function Results Instruction Composition in HLA The HLA RETURNS Option in Procedures Side Effects Recursion Forward Procedures Putting It All Together Chapter Overview Managing Large Programs The #INCLUDE Directive Ignoring Duplicate Include Operations UNITs and the EXTERNAL Directive Behavior of the EXTERNAL Directive Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 9

10 AoATOC.fm Header Files in HLA Make Files Code Reuse Creating and Managing Libraries Name Space Pollution Putting It All Together Chapter Overview x86 Integer Arithmetic Instructions The MUL and IMUL Instructions The DIV and IDIV Instructions The CMP Instruction The SETcc Instructions The TEST Instruction Arithmetic Expressions Simple Assignments Simple Expressions Complex Expressions Commutative Operators Logical (Boolean) Expressions Machine and Arithmetic Idioms Multiplying without MUL, IMUL, or INTMUL Division Without DIV or IDIV Implementing Modulo-N Counters with AND Careless Use of Machine Idioms The HLA (Pseudo) Random Number Unit Putting It All Together Chapter Overview Floating Point Arithmetic FPU Registers FPU Data Registers The FPU Control Register The FPU Status Register FPU Data Types The FPU Instruction Set FPU Data Movement Instructions The FLD Instruction The FST and FSTP Instructions The FXCH Instruction Conversions The FILD Instruction The FIST and FISTP Instructions The FBLD and FBSTP Instructions Arithmetic Instructions The FADD and FADDP Instructions The FSUB, FSUBP, FSUBR, and FSUBRP Instructions The FMUL and FMULP Instructions The FDIV, FDIVP, FDIVR, and FDIVRP Instructions Page , By Randall Hyde Beta Draft - Do not distribute

11 The FSQRT Instruction The FPREM and FPREM1 Instructions The FRNDINT Instruction The FABS Instruction The FCHS Instruction Comparison Instructions The FCOM, FCOMP, and FCOMPP Instructions The FTST Instruction Constant Instructions Transcendental Instructions The F2XM1 Instruction The FSIN, FCOS, and FSINCOS Instructions The FPTAN Instruction The FPATAN Instruction The FYL2X Instruction The FYL2XP1 Instruction Miscellaneous instructions The FINIT and FNINIT Instructions The FLDCW and FSTCW Instructions The FCLEX and FNCLEX Instructions The FSTSW and FNSTSW Instructions Integer Operations Converting Floating Point Expressions to Assembly Language Converting Arithmetic Expressions to Postfix Notation Converting Postfix Notation to Assembly Language Mixed Integer and Floating Point Arithmetic HLA Standard Library Support for Floating Point Arithmetic The stdin.getf and fileio.getf Functions Trigonometric Functions in the HLA Math Library Exponential and Logarithmic Functions in the HLA Math Library Sample Program Putting It All Together Chapter Overview Tables Function Computation via Table Look-up Domain Conditioning Generating Tables High Performance Implementation of cs.rangechar Questions Programming Projects Laboratory Exercises Using the BOUND Instruction to Check Array Indices Using TEXT Constants in Your Programs Constant Expressions Lab Exercise Pointers and Pointer Constants Exercises String Exercises String and Character Set Exercises Console Array Exercise Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 11

12 AoATOC.fm Multidimensional Array Exercises Console Attributes Laboratory Exercise Records, Arrays, and Pointers Laboratory Exercise Separate Compilation Exercises The HLA (Pseudo) Random Number Unit File I/O in HLA Timing Various Arithmetic Instructions Using the RDTSC Instruction to Time a Code Sequence Timing Floating Point Instructions Table Lookup Exercise Chapter Overview Conjunction, Disjunction, and Negation in Boolean Expressions TRY..ENDTRY Nesting TRY..ENDTRY Statements The UNPROTECTED Clause in a TRY..ENDTRY Statement The ANYEXCEPTION Clause in a TRY..ENDTRY Statement Raising User-Defined Exceptions Reraising Exceptions in a TRY..ENDTRY Statement A List of the Predefined HLA Exceptions How to Handle Exceptions in Your Programs Registers and the TRY..ENDTRY Statement BEGIN..EXIT..EXITIF..END CONTINUE..CONTINUEIF SWITCH..CASE..DEFAULT..ENDSWITCH Putting It All Together Chapter Overview Low Level Control Structures Statement Labels Unconditional Transfer of Control (JMP) The Conditional Jump Instructions Medium-Level Control Structures: JT and JF Implementing Common Control Structures in Assembly Language Introduction to Decisions IF..THEN..ELSE Sequences Translating HLA IF Statements into Pure Assembly Language Implementing Complex IF Statements Using Complete Boolean Evaluation Short Circuit Boolean Evaluation Short Circuit vs. Complete Boolean Evaluation Efficient Implementation of IF Statements in Assembly Language SWITCH/CASE Statements State Machines and Indirect Jumps Spaghetti Code Loops While Loops Repeat..Until Loops FOREVER..ENDFOR Loops Page , By Randall Hyde Beta Draft - Do not distribute

13 FOR Loops The BREAK and CONTINUE Statements Register Usage and Loops Performance Improvements Moving the Termination Condition to the End of a Loop Executing the Loop Backwards Loop Invariant Computations Unraveling Loops Induction Variables Hybrid Control Structures in HLA Putting It All Together Chapter Overview Procedures and the CALL Instruction Procedures and the Stack Activation Records The Standard Entry Sequence The Standard Exit Sequence HLA Local Variables Parameters Pass by Value Pass by Reference Passing Parameters in Registers Passing Parameters in the Code Stream Passing Parameters on the Stack Accessing Value Parameters on the Stack Passing Value Parameters on the Stack Accessing Reference Parameters on the Stack Passing Reference Parameters on the Stack Passing Formal Parameters as Actual Parameters HLA Hybrid Parameter Passing Facilities Mixing Register and Stack Based Parameters Procedure Pointers Procedural Parameters Untyped Reference Parameters Iterators and the FOREACH Loop Sample Programs Generating the Fibonacci Sequence Using an Iterator Outer Product Computation with Procedural Parameters Putting It All Together Chapter Overview Multiprecision Operations Multiprecision Addition Operations Multiprecision Subtraction Operations Extended Precision Comparisons Extended Precision Multiplication Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 13

14 AoATOC.fm Extended Precision Division Extended Precision NEG Operations Extended Precision AND Operations Extended Precision OR Operations Extended Precision XOR Operations Extended Precision NOT Operations Extended Precision Shift Operations Extended Precision Rotate Operations Extended Precision I/O Extended Precision Hexadecimal Output Extended Precision Unsigned Decimal Output Extended Precision Signed Decimal Output Extended Precision Formatted I/O Extended Precision Input Routines Extended Precision Hexadecimal Input Extended Precision Unsigned Decimal Input Extended Precision Signed Decimal Input Operating on Different Sized Operands Decimal Arithmetic Literal BCD Constants The 80x86 DAA and DAS Instructions The 80x86 AAA, AAS, AAM, and AAD Instructions Packed Decimal Arithmetic Using the FPU Sample Program Putting It All Together Chapter Overview What is Bit Data, Anyway? Instructions That Manipulate Bits The Carry Flag as a Bit Accumulator Packing and Unpacking Bit Strings Coalescing Bit Sets and Distributing Bit Strings Packed Arrays of Bit Strings Searching for a Bit Counting Bits Reversing a Bit String Merging Bit Strings Extracting Bit Strings Searching for a Bit Pattern The HLA Standard Library Bits Module Putting It All Together Chapter Overview The 80x86 String Instructions How the String Instructions Operate The REP/REPE/REPZ and REPNZ/REPNE Prefixes The Direction Flag Page , By Randall Hyde Beta Draft - Do not distribute

15 6.2.4 The MOVS Instruction The CMPS Instruction The SCAS Instruction The STOS Instruction The LODS Instruction Building Complex String Functions from LODS and STOS Putting It All Together Chapter Overview Introduction to the Compile-Time Language (CTL) The #PRINT and #ERROR Statements Compile-Time Constants and Variables Compile-Time Expressions and Operators Compile-Time Functions Type Conversion Compile-time Functions Numeric Compile-Time Functions Character Classification Compile-Time Functions Compile-Time String Functions Compile-Time Pattern Matching Functions Compile-Time Symbol Information Compile-Time Expression Classification Functions Miscellaneous Compile-Time Functions Predefined Compile-Time Variables Compile-Time Type Conversions of TEXT Objects Conditional Compilation (Compile-Time Decisions) Repetitive Compilation (Compile-Time Loops) Putting It All Together Chapter Overview Macros (Compile-Time Procedures) Standard Macros Macro Parameters Standard Macro Parameter Expansion Macros with a Variable Number of Parameters Required Versus Optional Macro Parameters The "#(" and ")#" Macro Parameter Brackets Eager vs. Deferred Macro Parameter Evaluation Local Symbols in a Macro Macros as Compile-Time Procedures Multi-part (Context-Free) Macros Simulating Function Overloading with Macros Writing Compile-Time "Programs" Constructing Data Tables at Compile Time Unrolling Loops Using Macros in Different Source Files Putting It All Together Chapter Overview Introduction to DSELs in HLA Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 15

16 AoATOC.fm Implementing the Standard HLA Control Structures The FOREVER Loop The WHILE Loop The IF Statement The HLA SWITCH/CASE Statement A Modified WHILE Loop A Modified IF..ELSE..ENDIF Statement Sample Program: A Simple Expression Compiler Putting It All Together Chapter Overview General Principles Classes in HLA Objects Inheritance Overriding Virtual Methods vs. Static Procedures Writing Class Methods, Iterators, and Procedures Object Implementation Virtual Method Tables Object Representation with Inheritance Constructors and Object Initialization Dynamic Object Allocation Within the Constructor Constructors and Inheritance Constructor Parameters and Procedure Overloading Destructors HLA s _initialize_ and _finalize_ Strings Abstract Methods Run-time Type Information (RTTI) Calling Base Class Methods Sample Program Putting It All Together Chapter Overview Determining if a CPU Supports the MMX Instruction Set The MMX Programming Environment The MMX Registers The MMX Data Types The Purpose of the MMX Instruction Set Saturation Arithmetic and Wraparound Mode MMX Instruction Operands MMX Technology Instructions MMX Data Transfer Instructions MMX Conversion Instructions MMX Packed Arithmetic Instructions Page , By Randall Hyde Beta Draft - Do not distribute

17 MMX Logic Instructions MMX Comparison Instructions MMX Shift Instructions The EMMS Instruction The MMX Programming Paradigm Putting It All Together Chapter Overview Mixing HLA and MASM/Gas Code in the Same Program In-Line (MASM/Gas) Assembly Code in Your HLA Programs Linking MASM/Gas-Assembled Modules with HLA Modules Hello, World of Assembly Language 12.3 Programming in Delphi/Kylix and HLA Linking HLA Modules With Delphi Programs Register Preservation Function Results Calling Conventions Pass by Value, Reference, CONST, and OUT in Delphi Scalar Data Type Correspondence Between Delphi and HLA Passing String Data Between Delphi and HLA Code Passing Record Data Between HLA and Delphi Passing Set Data Between Delphi and HLA Passing Array Data Between HLA and Delphi Delphi Limitations When Linking with (Non-TASM) Assembly Code Referencing Delphi Objects from HLA Code Programming in C/C++ and HLA Linking HLA Modules With C/C++ Programs Register Preservation Function Results Calling Conventions Pass by Value and Reference in C/C Scalar Data Type Correspondence Between C/C++ and HLA Passing String Data Between C/C++ and HLA Code Passing Record/Structure Data Between HLA and C/C Passing Array Data Between HLA and C/C Putting It All Together Questions Programming Problems Laboratory Exercises Dynamically Nested TRY..ENDTRY Statements The TRY..ENDTRY Unprotected Section Performance of SWITCH Statement Complete Versus Short Circuit Boolean Evaluation Conversion of High Level Language Statements to Pure Assembly Activation Record Exercises Automatic Activation Record Generation and Access The _vars_ and _parms_ Constants Manually Constructing an Activation Record Reference Parameter Exercise Procedural Parameter Exercise Beta Draft - Do not distribute 2001, By Randall Hyde Page 17

18 AoATOC.fm Iterator Exercises Performance of Multiprecision Multiplication and Division Operations Performance of the Extended Precision NEG Operation Testing the Extended Precision Input Routines Illegal Decimal Operations MOVS Performance Exercise # MOVS Performance Exercise # Memory Performance Exercise The Performance of Length-Prefixed vs. Zero-Terminated Strings Introduction to Compile-Time Programs Conditional Compilation and Debug Code The Assert Macro Demonstration of Compile-Time Loops (#while) Writing a Trace Macro Overloading Multi-part Macros and RatASM (Rational Assembly) Virtual Methods vs. Static Procedures in a Class Using the _initialize_ and _finalize_ Strings in a Program Using RTTI in a Program Chapter Overview First Class Objects Thunks Initializing Thunks Manipulating Thunks Assigning Thunks Comparing Thunks Passing Thunks as Parameters Returning Thunks as Function Results Activation Record Lifetimes and Thunks Comparing Thunks and Objects An Example of a Thunk Using the Fibonacci Function Thunks and Artificial Intelligence Code Thunks as Triggers Jumping Out of a Thunk Handling Exceptions with Thunks Using Thunks in an Appropriate Manner Putting It All Together Chapter Overview Review of Iterators Implementing Iterators Using In-Line Expansion Implementing Iterators with Resume Frames Other Possible Iterator Implementations Breaking Out of a FOREACH Loop An Iterator Implementation of the Fibonacci Number Generator Iterators and Recursion Page , By Randall Hyde Beta Draft - Do not distribute

19 2.7 Calling Other Procedures Within an Iterator Iterators Within Classes Putting It Altogether Chapter Overview Coroutines Parameters and Register Values in Coroutine Calls Recursion, Reentrancy, and Variables Generators Exceptions and Coroutines Putting It All Together Chapter Overview Parameters Where You Can Pass Parameters Passing Parameters in (Integer) Registers Passing Parameters in FPU and MMX Registers Passing Parameters in Global Variables Passing Parameters on the Stack Passing Parameters in the Code Stream Passing Parameters via a Parameter Block How You Can Pass Parameters Pass by Value-Result Pass by Result Pass by Name Pass by Lazy-Evaluation Passing Parameters as Parameters to Another Procedure Passing Reference Parameters to Other Procedures Passing Value-Result and Result Parameters as Parameters Passing Name Parameters to Other Procedures Passing Lazy Evaluation Parameters as Parameters Parameter Passing Summary Variable Parameter Lists Function Results Returning Function Results in a Register Returning Function Results on the Stack Returning Function Results in Memory Locations Returning Large Function Results Putting It All Together Chapter Overview Lexical Nesting, Static Links, and Displays Scope Unit Activation, Address Binding, and Variable Lifetime Static Links Accessing Non-Local Variables Using Static Links Nesting Procedures in HLA The Display Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 19

20 AoATOC.fm The 80x86 ENTER and LEAVE Instructions Passing Variables at Different Lex Levels as Parameters Passing Parameters by Value Passing Parameters by Reference, Result, and Value-Result Passing Parameters by Name and Lazy-Evaluation in a Block Structured Language Passing Procedures as Parameters Faking Intermediate Variable Access Putting It All Together Questions Programming Problems C.1 Introduction C.1.1 Intended Audience C.1.2 Readability Metrics C.1.3 How to Achieve Readability C.1.4 How This Document is Organized C.1.5 Guidelines, Rules, Enforced Rules, and Exceptions C.1.6 Source Language Concerns C.2 Program Organization C.2.1 Library Functions C.2.2 Common Object Modules C.2.3 Local Modules C.2.4 Program Make Files C.3 Module Organization C.3.1 Module Attributes C Module Cohesion C Module Coupling C Physical Organization of Modules C Module Interface C.4 Program Unit Organization C.4.1 Routine Cohesion C.4.2 Routine Coupling C.4.3 Routine Size C.5 Statement Organization C.5.1 Writing Pure Assembly Code C.5.2 Using HLA s High Level Control Statements C.6 Comments C.6.1 What is a Bad Comment? C.6.2 What is a Good Comment? C.6.3 Endline vs. Standalone Comments C.6.4 Unfinished Code C.6.5 Cross References in Code to Other Documents C.7 Names, Instructions, Operators, and Operands C.7.1 Names C Naming Conventions C Alphabetic Case Considerations Page , By Randall Hyde Beta Draft - Do not distribute

21 C Abbreviations C The Position of Components Within an Identifier C Names to Avoid C Special Identifers C.7.2 Instructions, Directives, and Pseudo-Opcodes C Choosing the Best Instruction Sequence C Control Structures C Instruction Synonyms C.8 Data Types C.8.1 Declaring Structures in Assembly Language H.1 Conversion Functions H.2 Numeric Functions H.3 Date/Time Functions H.4 Classification Functions H.5 String and Character Set Functions H.6 Pattern Matching Functions H.6.1 String/Cset Pattern Matching Functions H.6.2 String/Character Pattern Matching Functions H.6.3 String/Case Insenstive Character Pattern Matching Functions H.6.4 String/String Pattern Matching Functions H.6.5 String/Misc Pattern Matching Functions H.7 HLA Information and Symbol Table Functions H.8 Compile-Time Variables H.9 Miscellaneous Compile-Time Functions J.1 Pseudo-Variable J.2 The Assert Macro L.1 The HLA Standard Library L.2 Compiling to MASM Code -- The Final Word L.3 The HLA if..then..endif Statement, Part I L.4 Boolean Expressions in HLA Control Structures L.5 The JT/JF Pseudo-Instructions L.6 The HLA if..then..elseif..else..endif Statement, Part II L.7 The While Statement L.8 repeat..until L.9 for..endfor L.10 forever..endfor L.11 break, breakif L.12 continue, continueif L.13 begin..end, exit, exitif L.14 foreach..endfor L.15 try..unprotect..exception..anyexception..endtry, raise Hello, World of Assembly Language Beta Draft - Do not distribute 2001, By Randall Hyde Page 21

22 AoATOC.fm Page , By Randall Hyde Beta Draft - Do not distribute

80x87 Instruction Set (x87 - Pentium)

80x87 Instruction Set (x87 - Pentium) 80x87 Instruction Set (x87 - Pentium) Legend: General: reg = floating point register, st(0), st(1)... st(7) mem = memory address mem32 = memory address of 32-bit item mem64 = memory address of 64-bit item

More information

The x87 Floating-Point Unit

The x87 Floating-Point Unit The x87 Floating-Point Unit Lecture 27 Intel Manual, Vol. 1, Chapter 8 Intel Manual, Vol. 2 Robb T. Koether Hampden-Sydney College Fri, Mar 27, 2015 Robb T. Koether (Hampden-Sydney College) The x87 Floating-Point

More information

Questions, Projects, and Labs

Questions, Projects, and Labs Volume Five Questions, Projects, and Lab Exercises Questions, Projects, and Labs Chapter Six 6.1 Questions 1) What is a First Class Object? 2) What is the difference between deferred and eager evaluation?

More information

3.1 DATA MOVEMENT INSTRUCTIONS 45

3.1 DATA MOVEMENT INSTRUCTIONS 45 3.1.1 General-Purpose Data Movement s 45 3.1.2 Stack Manipulation... 46 3.1.3 Type Conversion... 48 3.2.1 Addition and Subtraction... 51 3.1 DATA MOVEMENT INSTRUCTIONS 45 MOV (Move) transfers a byte, word,

More information

Real Arithmetic. Fractional binary numbers. Fractional binary numbers examples. Binary real numbers

Real Arithmetic. Fractional binary numbers. Fractional binary numbers examples. Binary real numbers Fractional binary numbers 2 i 2 i 1 Real Arithmetic Computer Organization and Assembly Languages g Yung-Yu Chuang 4 2 1 b i b i 1 b 2 b 1 b 0. b 1 b 2 b 3 b j Representation 1/2 1/4 1/8 2 j Bits to right

More information

Floating Point Instructions

Floating Point Instructions Floating Point Instructions Ned Nedialkov McMaster University Canada SE 3F03 March 2013 Outline Storing data Addition Subtraction Multiplication Division Comparison instructions Some more instructions

More information

MATH CO-PROCESSOR Rajiv R Bhandari

MATH CO-PROCESSOR Rajiv R Bhandari MATH CO-PROCESSOR 8087 1 Rajiv R Bhandari Compatible Processor and Coprocessor Processors 1. 8086 & 8088 2. 80286 3. 80386DX 4. 80386SX 5. 80486DX 6. 80486SX Coprocessors 1. 8087 2. 80287,80287XL 3. 80287,80387DX

More information

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

UNIT-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 information

Overview of architecture Interfacing with Data types, instructions. Programming.

Overview of architecture Interfacing with Data types, instructions. Programming. Overview of architecture 8087. Interfacing with 8086. Data types, instructions. Programming. Module 4 learning unit 10: Contents Architecture of 8087 Data types Interfacing Instructions and programming

More information

Computer Organization CS 206 T Lec# 2: Instruction Sets

Computer Organization CS 206 T Lec# 2: Instruction Sets Computer Organization CS 206 T Lec# 2: Instruction Sets Topics What is an instruction set Elements of instruction Instruction Format Instruction types Types of operations Types of operand Addressing mode

More information

COMPUTER ORGANIZATION & ARCHITECTURE

COMPUTER ORGANIZATION & ARCHITECTURE COMPUTER ORGANIZATION & ARCHITECTURE Instructions Sets Architecture Lesson 5a 1 What are Instruction Sets The complete collection of instructions that are understood by a CPU Can be considered as a functional

More information

SOME ASSEMBLY REQUIRED

SOME ASSEMBLY REQUIRED SOME ASSEMBLY REQUIRED Assembly Language Programming with the AVR Microcontroller TIMOTHY S. MARGUSH CRC Press Taylor & Francis Group CRC Press is an imprint of the Taylor & Francis Croup an Informa business

More information

UNIT 3

UNIT 3 UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

Instruction Sets: Characteristics and Functions Addressing Modes

Instruction Sets: Characteristics and Functions Addressing Modes Instruction Sets: Characteristics and Functions Addressing Modes Chapters 10 and 11, William Stallings Computer Organization and Architecture 7 th Edition What is an Instruction Set? The complete collection

More information

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation

More information

EEM336 Microprocessors I. Arithmetic and Logic Instructions

EEM336 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 information

Instruction Set extensions to X86. Floating Point SIMD instructions

Instruction Set extensions to X86. Floating Point SIMD instructions Instruction Set extensions to X86 Some extensions to x86 instruction set intended to accelerate 3D graphics AMD 3D-Now! Instructions simply accelerate floating point arithmetic. Accelerate object transformations

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 books: Basic Architecture, Order Number 243190; Instruction

More information

LAB WORK NO. 11 THE USAGE OF THE MATHEMATICAL COPROCESSOR

LAB WORK NO. 11 THE USAGE OF THE MATHEMATICAL COPROCESSOR LAB WORK NO. THE USAGE OF THE MATHEMATICAL COPROCESSOR. Object of laboratory The purpose of this lab is to familiarize the user with the mathematical coprocessor s functions, its instructions for real

More information

Real instruction set architectures. Part 2: a representative sample

Real instruction set architectures. Part 2: a representative sample Real instruction set architectures Part 2: a representative sample Some historical architectures VAX: Digital s line of midsize computers, dominant in academia in the 70s and 80s Characteristics: Variable-length

More information

HUDSON VALLEY COMMUNITY COLLEGE TROY, NEW YORK COURSE OUTLINE

HUDSON VALLEY COMMUNITY COLLEGE TROY, NEW YORK COURSE OUTLINE ACADEMIC YEAR 2017-2018 HUDSON VALLEY COMMUNITY COLLEGE TROY, NEW YORK COURSE OUTLINE COURSE TITLE: Assembly Language And Computer Architecture COURSE SUBJECT AND NUMBER: CISS 280 DEPARTMENT: Computing

More information

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309 A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48

More information

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

ASSEMBLY LANGUAGE MACHINE ORGANIZATION ASSEMBLY LANGUAGE MACHINE ORGANIZATION CHAPTER 3 1 Sub-topics The topic will cover: Microprocessor architecture CPU processing methods Pipelining Superscalar RISC Multiprocessing Instruction Cycle Instruction

More information

14 HLA Language Reference and User Manual

14 HLA Language Reference and User Manual 14 HLA Language Reference and User Manual 14.1 High Level Language Statements HLA provides several control structures that provide a high level language flavor to assembly language programming. The statements

More information

17. Instruction Sets: Characteristics and Functions

17. Instruction Sets: Characteristics and Functions 17. Instruction Sets: Characteristics and Functions Chapter 12 Spring 2016 CS430 - Computer Architecture 1 Introduction Section 12.1, 12.2, and 12.3 pp. 406-418 Computer Designer: Machine instruction set

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

CS401 - Computer Architecture and Assembly Language Programming Glossary By

CS401 - Computer Architecture and Assembly Language Programming Glossary By CS401 - Computer Architecture and Assembly Language Programming Glossary By absolute address : A virtual (not physical) address within the process address space that is computed as an absolute number.

More information

Intel 8086: Instruction Set

Intel 8086: Instruction Set IUST-EE (Chapter 6) Intel 8086: Instruction Set 1 Outline Instruction Set Data Transfer Instructions Arithmetic Instructions Bit Manipulation Instructions String Instructions Unconditional Transfer Instruction

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 five volumes: Basic Architecture,

More information

UNIT 2 PROCESSORS ORGANIZATION CONT.

UNIT 2 PROCESSORS ORGANIZATION CONT. UNIT 2 PROCESSORS ORGANIZATION CONT. Types of Operand Addresses Numbers Integer/floating point Characters ASCII etc. Logical Data Bits or flags x86 Data Types Operands in 8 bit -Byte 16 bit- word 32 bit-

More information

Contents. Preface. Introduction. Introduction to C Programming

Contents. Preface. Introduction. Introduction to C Programming c11fptoc.fm Page vii Saturday, March 23, 2013 4:15 PM Preface xv 1 Introduction 1 1.1 1.2 1.3 1.4 1.5 Introduction The C Programming Language C Standard Library C++ and Other C-Based Languages Typical

More information

Main Points of the Computer Organization and System Software Module

Main Points of the Computer Organization and System Software Module Main Points of the Computer Organization and System Software Module You can find below the topics we have covered during the COSS module. Reading the relevant parts of the textbooks is essential for a

More information

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Computer Systems A Programmer s Perspective 1 (Beta Draft) Computer Systems A Programmer s Perspective 1 (Beta Draft) Randal E. Bryant David R. O Hallaron August 1, 2001 1 Copyright c 2001, R. E. Bryant, D. R. O Hallaron. All rights reserved. 2 Contents Preface

More information

ALT-Assembly Language Tutorial

ALT-Assembly Language Tutorial ALT-Assembly Language Tutorial ASSEMBLY LANGUAGE TUTORIAL Let s Learn in New Look SHAIK BILAL AHMED i A B O U T T H E T U TO R I A L Assembly Programming Tutorial Assembly language is a low-level programming

More information

12.1 Chapter Overview Tables Function Computation via Table Look-up. Calculation Via Table Lookups

12.1 Chapter Overview Tables Function Computation via Table Look-up. Calculation Via Table Lookups Calculation Via Table Lookups Calculation Via Table Lookups Chapter Twelve 12.1 Chapter Overview This chapter discusses arithmetic computation via table lookup. By the conclusion of this chapter you should

More information

INTEL Architectures GOPALAKRISHNAN IYER FALL 2009 ELEC : Computer Architecture and Design

INTEL Architectures GOPALAKRISHNAN IYER FALL 2009 ELEC : Computer Architecture and Design INTEL Architectures GOPALAKRISHNAN IYER FALL 2009 GBI0001@AUBURN.EDU ELEC 6200-001: Computer Architecture and Design Silicon Technology Moore s law Moore's Law describes a long-term trend in the history

More information

CPSC 3740 Programming Languages University of Lethbridge. Data Types

CPSC 3740 Programming Languages University of Lethbridge. Data Types Data Types A data type defines a collection of data values and a set of predefined operations on those values Some languages allow user to define additional types Useful for error detection through type

More information

M80C BIT CHMOS III NUMERIC PROCESSOR EXTENSION

M80C BIT CHMOS III NUMERIC PROCESSOR EXTENSION 80-BIT CHMOS III NUMERIC PROCESSOR EXTENSION Military Y High Performance 80-Bit Internal Architecture Y Implements ANSI IEEE Standard 754-1985 for Binary Floating-Point Arithmetic Y Implements Extended

More information

Instruction Set Architecture

Instruction Set Architecture C Fortran Ada etc. Basic Java Instruction Set Architecture Compiler Assembly Language Compiler Byte Code Nizamettin AYDIN naydin@yildiz.edu.tr http://www.yildiz.edu.tr/~naydin http://akademik.bahcesehir.edu.tr/~naydin

More information

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMPUTER ARCHITECURE- III YEAR EEE-6 TH SEMESTER 16 MARKS QUESTION BANK UNIT-1

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMPUTER ARCHITECURE- III YEAR EEE-6 TH SEMESTER 16 MARKS QUESTION BANK UNIT-1 CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMPUTER ARCHITECURE- III YEAR EEE-6 TH SEMESTER 16 MARKS QUESTION BANK UNIT-1 Data representation: (CHAPTER-3) 1. Discuss in brief about Data types, (8marks)

More information

Instruction Sets: Characteristics and Functions

Instruction Sets: Characteristics and Functions Instruction Sets: Characteristics and Functions Chapter 10 Lesson 15 Slide 1/22 Machine instruction set Computer designer: The machine instruction set provides the functional requirements for the CPU.

More information

Understand the factors involved in instruction set

Understand the factors involved in instruction set A Closer Look at Instruction Set Architectures Objectives Understand the factors involved in instruction set architecture design. Look at different instruction formats, operand types, and memory access

More information

CHAPTER 5 A Closer Look at Instruction Set Architectures

CHAPTER 5 A Closer Look at Instruction Set Architectures CHAPTER 5 A Closer Look at Instruction Set Architectures 5.1 Introduction 293 5.2 Instruction Formats 293 5.2.1 Design Decisions for Instruction Sets 294 5.2.2 Little versus Big Endian 295 5.2.3 Internal

More information

COS 140: Foundations of Computer Science

COS 140: Foundations of Computer Science COS 140: Foundations of Computer Science CPU Organization and Assembly Language Fall 2018 CPU 3 Components of the CPU..................................................... 4 Registers................................................................

More information

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126 INDEX = (assignment operator) 130, 816 = 0 (as function definition) 827 == (equality test operator) 146! (logical NOT operator) 159!= (inequality test operator) 146 #define 140, 158 #include 100, 112,

More information

Floating-Point Arithmetic

Floating-Point Arithmetic ENEE446---Lectures-4/10-15/08 A. Yavuz Oruç Professor, UMD, College Park Copyright 2007 A. Yavuz Oruç. All rights reserved. Floating-Point Arithmetic Integer or fixed-point arithmetic provides a complete

More information

ORG ; TWO. Assembly Language Programming

ORG ; TWO. Assembly Language Programming Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT III MULTIPROCESSOR CONFIGURATIONS PART A (2 Marks)

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT III MULTIPROCESSOR CONFIGURATIONS PART A (2 Marks) MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI-621213. UNIT III MULTIPROCESSOR CONFIGURATIONS PART A (2 Marks) 1. What are tightly coupled systems or closely coupled systems? In a tightly coupled systems

More information

13.1 Questions. Questions and Exercises

13.1 Questions. Questions and Exercises Questions and Exercises Questions, Projects, and Labs Chapter Thirteen 13.1 Questions 1) What is the purpose of the INTO instruction? 2) What was the main purpose for the INTMUL instruction in this volume?

More information

Questions, Projects, and Labs

Questions, Projects, and Labs Questions, Projects, and Laboratory Exercises Questions, Projects, and Labs Chapter Eight 8.1 Questions 1. What three components make up Von Neumann Machines? 2. What is the purpose of a) The system bus

More information

Basic Execution Environment

Basic Execution Environment Basic Execution Environment 3 CHAPTER 3 BASIC EXECUTION ENVIRONMENT This chapter describes the basic execution environment of an Intel Architecture processor as seen by assembly-language programmers.

More information

Compiler construction. x86 architecture. This lecture. Lecture 6: Code generation for x86. x86: assembly for a real machine.

Compiler construction. x86 architecture. This lecture. Lecture 6: Code generation for x86. x86: assembly for a real machine. This lecture Compiler construction Lecture 6: Code generation for x86 Magnus Myreen Spring 2018 Chalmers University of Technology Gothenburg University x86 architecture s Some x86 instructions From LLVM

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

CS 1313 Spring 2000 Lecture Outline

CS 1313 Spring 2000 Lecture Outline 1. What is a Computer? 2. Components of a Computer System Overview of Computing, Part 1 (a) Hardware Components i. Central Processing Unit ii. Main Memory iii. The Bus iv. Loading Data from Main Memory

More information

80C BIT MATH COPROCESSOR

80C BIT MATH COPROCESSOR 80-BIT MATH COPROCESSOR Y High Performance 80-Bit Internal Architecture Y Implements ANSI IEEE Standard 754-1985 for Binary Floating-Point Arithmetic Y Upward Object-Code Compatible from 8087 Y Fully Compatible

More information

Chapter 7 Central Processor Unit (S08CPUV2)

Chapter 7 Central Processor Unit (S08CPUV2) Chapter 7 Central Processor Unit (S08CPUV2) 7.1 Introduction This section provides summary information about the registers, addressing modes, and instruction set of the CPU of the HCS08 Family. For a more

More information

CHAPTER 5 A Closer Look at Instruction Set Architectures

CHAPTER 5 A Closer Look at Instruction Set Architectures CHAPTER 5 A Closer Look at Instruction Set Architectures 5.1 Introduction 199 5.2 Instruction Formats 199 5.2.1 Design Decisions for Instruction Sets 200 5.2.2 Little versus Big Endian 201 5.2.3 Internal

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

Reminder: tutorials start next week!

Reminder: tutorials start next week! Previous lecture recap! Metrics of computer architecture! Fundamental ways of improving performance: parallelism, locality, focus on the common case! Amdahl s Law: speedup proportional only to the affected

More information

Microcontrollers. Microcontroller

Microcontrollers. Microcontroller Microcontrollers Microcontroller A microprocessor on a single integrated circuit intended to operate as an embedded system. As well as a CPU, a microcontroller typically includes small amounts of RAM and

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad Introduction to MS-DOS Debugger DEBUG In this laboratory, we will use DEBUG program and learn how to: 1. Examine and modify the contents of the 8086 s internal registers, and dedicated parts of the memory

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

Processing Unit CS206T

Processing Unit CS206T Processing Unit CS206T Microprocessors The density of elements on processor chips continued to rise More and more elements were placed on each chip so that fewer and fewer chips were needed to construct

More information

C++ for System Developers with Design Pattern

C++ for System Developers with Design Pattern C++ for System Developers with Design Pattern Introduction: This course introduces the C++ language for use on real time and embedded applications. The first part of the course focuses on the language

More information

Honorary Professor Supercomputer Education and Research Centre Indian Institute of Science, Bangalore

Honorary Professor Supercomputer Education and Research Centre Indian Institute of Science, Bangalore COMPUTER ORGANIZATION AND ARCHITECTURE V. Rajaraman Honorary Professor Supercomputer Education and Research Centre Indian Institute of Science, Bangalore T. Radhakrishnan Professor of Computer Science

More information

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1... Instruction-set Design Issues: what is the format(s) Opcode Dest. Operand Source Operand 1... 1) Which instructions to include: How many? Complexity - simple ADD R1, R2, R3 complex e.g., VAX MATCHC substrlength,

More information

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation Computer Organization CS 231-01 Data Representation Dr. William H. Robinson November 12, 2004 Topics Power tends to corrupt; absolute power corrupts absolutely. Lord Acton British historian, late 19 th

More information

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1... Instruction-set Design Issues: what is the format(s) Opcode Dest. Operand Source Operand 1... 1) Which instructions to include: How many? Complexity - simple ADD R1, R2, R3 complex e.g., VAX MATCHC substrlength,

More information

Seth Jai Parkash Polytechnic, Damla

Seth Jai Parkash Polytechnic, Damla Seth Jai Parkash Polytechnic, Damla Name of the Faculty: Ms Richa Kharbanda Discipline: Computer Engg. Semester: 4 th Subject: DATA STRUCTURES USING C Lesson Plan Duration: 15 weeks (from January, 2018

More information

6x86 PROCESSOR Superscalar, Superpipelined, Sixth-generation, x86 Compatible CPU

6x86 PROCESSOR Superscalar, Superpipelined, Sixth-generation, x86 Compatible CPU 1-6x86 PROCESSOR Superscalar, Superpipelined, Sixth-generation, x86 Compatible CPU Product Overview Introduction 1. ARCHITECTURE OVERVIEW The Cyrix 6x86 CPU is a leader in the sixth generation of high

More information

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMMUNICATION ENGINEERING REG 2008 TWO MARKS QUESTION AND ANSWERS

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMMUNICATION ENGINEERING REG 2008 TWO MARKS QUESTION AND ANSWERS CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY B.E.,/B.TECH., ELECTRONICS EC6504 MICROPROCESSORS & MICRO CONTROLLERS COMMUNICATION ENGINEERING REG 2008 TWO MARKS QUESTION AND ANSWERS UNIT 1 AND 2 CS SUBJECT

More information

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer? Interfacing Compiler and Hardware Computer Systems Architecture FORTRAN 90 program C++ program Processor Types And Sets FORTRAN 90 Compiler C++ Compiler set level Hardware 1 2 What s Should A Processor

More information

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store. IT 3123 Hardware and Software Concepts February 11 and Memory II Copyright 2005 by Bob Brown The von Neumann Architecture 00 01 02 03 PC IR Control Unit Command Memory ALU 96 97 98 99 Notice: This session

More information

13) Repeat question (12) using short circuit boolean evaluation. 14) Convert the following Pascal CASE statement to assembly language:

13) Repeat question (12) using short circuit boolean evaluation. 14) Convert the following Pascal CASE statement to assembly language: Questions, Projects, and Laboratory Exercises Questions, Projects, and Labs Chapter Thirteen 13.1 Questions 1) What is the purpose of the UNPROTECTED section in a TRY..ENDTRY statement? 2) Once a TRY..ENDTRY

More information

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions Structure of von Nuemann machine Arithmetic and Logic Unit Input Output Equipment Main Memory Program Control Unit 1 1 Instruction Set - the type of Instructions Arithmetic + Logical (ADD, SUB, MULT, DIV,

More information

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions William Stallings Computer Organization and Architecture 8 th Edition Chapter 10 Instruction Sets: Characteristics and Functions Instruction Set = The complete collection of instructions that are recognized

More information

Chapter Five. Questions, Projects, and Lab Exercises. 5.1 Questions. Questions, Projects, and Laboratory Exercises

Chapter Five. Questions, Projects, and Lab Exercises. 5.1 Questions. Questions, Projects, and Laboratory Exercises Questions, Projects, and Lab Exercises Questions, Projects, and Laboratory Exercises Chapter Five 5.1 Questions 1) List the legal forms of a boolean expression in an HLA IF statement. 2) What data type

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

CN310 Microprocessor Systems Design

CN310 Microprocessor Systems Design CN310 Microprocessor Systems Design Micro Architecture Nawin Somyat Department of Electrical and Computer Engineering Thammasat University 28 August 2018 Outline Course Contents 1 Introduction 2 Simple

More information

Problem with Scanning an Infix Expression

Problem with Scanning an Infix Expression Operator Notation Consider the infix expression (X Y) + (W U), with parentheses added to make the evaluation order perfectly obvious. This is an arithmetic expression written in standard form, called infix

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

UNIT- 5. Chapter 12 Processor Structure and Function

UNIT- 5. Chapter 12 Processor Structure and Function UNIT- 5 Chapter 12 Processor Structure and Function CPU Structure CPU must: Fetch instructions Interpret instructions Fetch data Process data Write data CPU With Systems Bus CPU Internal Structure Registers

More information

CS6303 Computer Architecture Regulation 2013 BE-Computer Science and Engineering III semester 2 MARKS

CS6303 Computer Architecture Regulation 2013 BE-Computer Science and Engineering III semester 2 MARKS CS6303 Computer Architecture Regulation 2013 BE-Computer Science and Engineering III semester 2 MARKS UNIT-I OVERVIEW & INSTRUCTIONS 1. What are the eight great ideas in computer architecture? The eight

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST 2 Date : 02/04/2018 Max Marks: 40 Subject & Code : Microprocessor (15CS44) Section : IV A and B Name of faculty: Deepti.C Time : 8:30 am-10:00 am Note: Note: Answer any five complete

More information

CPE300: Digital System Architecture and Design

CPE300: Digital System Architecture and Design CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Arithmetic Unit 10032011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Recap Chapter 3 Number Systems Fixed Point

More information

Course Description: This course includes concepts of instruction set architecture,

Course Description: This course includes concepts of instruction set architecture, Computer Architecture Course Title: Computer Architecture Full Marks: 60+ 20+20 Course No: CSC208 Pass Marks: 24+8+8 Nature of the Course: Theory + Lab Credit Hrs: 3 Course Description: This course includes

More information

Computer Organization and Technology Processor and System Structures

Computer Organization and Technology Processor and System Structures Computer Organization and Technology Processor and System Structures Assoc. Prof. Dr. Wattanapong Kurdthongmee Division of Computer Engineering, School of Engineering and Resources, Walailak University

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

ISA: The Hardware Software Interface

ISA: The Hardware Software Interface ISA: The Hardware Software Interface Instruction Set Architecture (ISA) is where software meets hardware In embedded systems, this boundary is often flexible Understanding of ISA design is therefore important

More information

INTELLIGENCE PLUS CHARACTER - THAT IS THE GOAL OF TRUE EDUCATION UNIT-I

INTELLIGENCE PLUS CHARACTER - THAT IS THE GOAL OF TRUE EDUCATION UNIT-I UNIT-I 1. List and explain the functional units of a computer with a neat diagram 2. Explain the computer levels of programming languages 3. a) Explain about instruction formats b) Evaluate the arithmetic

More information

CC411: Introduction To Microprocessors

CC411: Introduction To Microprocessors CC411: Introduction To Microprocessors OBJECTIVES this chapter enables the student to: Describe the Intel family of microprocessors from 8085 to Pentium. In terms of bus size, physical memory & special

More information

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 INTRODUCTION SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Facilities and features of PL/1. Structure of programs written in PL/1. Data types. Storage classes, control,

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Latches. IT 3123 Hardware and Software Concepts. Registers. The Little Man has Registers. Data Registers. Program Counter

Latches. IT 3123 Hardware and Software Concepts. Registers. The Little Man has Registers. Data Registers. Program Counter IT 3123 Hardware and Software Concepts Notice: This session is being recorded. CPU and Memory June 11 Copyright 2005 by Bob Brown Latches Can store one bit of data Can be ganged together to store more

More information

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information