In order to run the program, go to the folder Release and run project.exe.
|
|
- Todd Greene
- 5 years ago
- Views:
Transcription
1 Assembly Language and System Software Lab exercise You need to implement seven programs. In this lab exercise, you are going to get familiar with assembly programming. You should follow the guideline to finish all the tasks. You may think about how to solve the problems before reading the guideline. Make sure that you compile and build the programs in Release mode. After building a program, an executable file is generated and the name of the file is project.exe. In order to run the program, go to the folder Release and run project.exe. If you modify your code, make sure you compile and build your program again. After finishing all the exercises, tell TAs and then you may leave.
2 p1. Write a program to ask a user to input three unsigned integers and then compute the sum of three unsigned integers. Print out the sum on the console window. We call ReadDec to read an unsigned integer to EAX. Then, we assign the value of EAX to another register. After we have all the three unsigned integers, we compute the sum and store it to EAX. For example, call ReadDec ; read an unsigned integer which will be stored in eax mov ebx, eax ; ebx = eax call ReadDec ; read an unsigned integer which will be stored in eax mov ecx, eax ; ecx = eax call ReadDec ; read an unsigned integer which will be stored in eax add eax, ebx ; eax = eax + ebx add eax, ecx ; eax = eax + ecx In order to print out an unsigned integer eax, we call writedec. call WriteDec After you finish the program, try the following data sets and check the result. Data set one: Input: 1, 2, 3 sum: 6 Data set two: Input: 0, 0, 0 sum: 0 Data set three: Input: 900, 80, 7 sum: 987 Data set four: Input: 1, 0, 0 sum:? Data set five: Input: 1, 2, 3 sum:? Could you explain why the incorrect results are obtained for the data sets four and five?
3 p2. Write a program to ask a user to input three signed integers and then compute the sum of three signed integers. Print out the sum on the console window. We call ReadInt to read a signed integer to EAX. Then, we assign the value of EAX to another register. After we have all the three signed integers, we compute the sum and store it to EAX. For example, mov ebx, eax ; ebx = eax mov ecx, eax ; ecx = eax add eax, ebx ; eax = eax + ebx add eax, ecx ; eax = eax + ecx In order to print out a signed integer in eax, we call WriteInt. call WriteInt Data set one: Input: 2, 3, 5 sum: +10 Data set two: Input: 2, 3, 5 sum: 10 Data set three: Input: 100, 20, 3 sum: +123 Data set four: Input: , , sum:? (9 zero digits) What is the sum for data set four? Could you explain why the result is obtained?
4 p3. In the previous programs, it is not easy to see that which integer is being entered. In order to let the user to know which integer is being entered, we can show a message on the screen. We call mwrite to do so. However, mwrite is defined in another file. In order to use mwrite, we need to include the file which defines macros. Make sure that you have the following two lines: INCLUDE Irvine32.inc INCLUDE Macros.inc ; this is the file which defines macros. Let s write a simple program to ask a user to input three signed integers and show them on the screen. For example, mwrite Please enter the first signed integer: mov ebx, eax ; ebx = eax mwrite Please enter the second signed integer: mov ecx, eax ; ecx = eax mwrite Please enter the third signed integer: add eax, ebx ; eax = eax + ebx add eax, ecx ; eax = eax + ecx mwrite The sum of the three signed integers is: call WriteInt Now, compile and build the program. After that try the following data sets: Data set one: Input: 0, 1, 2 sum: +3 Data set two: Input: 0, 1, 2 sum: 3 Data set three: Input: 123, 0, 123 sum: 0
5 p4. We can print out a value stored in EAX in different formats. Write a program to ask a user to input three unsigned integers and then compute the sum of three unsigned integers. Store the sum to EAX. Print out EAX with different formats on the console window. mwrite First signed integer: mov ebx, eax ; ebx = eax mwrite Second signed integer: mov ecx, eax ; ecx = eax mwrite Third signed integer: add eax, ebx ; eax = eax + ebx add eax, ecx ; eax = eax + ecx mwriteln The sum is (unsigned): call WriteDec mwriteln The sum is (signed): call WriteInt mwriteln The sum is (Hex): call WriteHex mwriteln The sum is (Binary): call WriteBinary mwriteln The sum is (Char): call WriteChar ; write AL as a ASCII code on screen Build and run the program. Data set one: Input: 1, 2, 4 Sum (in decimal): 1 Data set two: Input: 1, 0, 8 Sum (in decimal): 7 As you can see for the same value stored in EAX, we have different outputs on the console window. We interpret a value from different perspectives. Thus, make sure that you interpret a value correctly in a specific content.
6 p5. In this program, we draw a char on screen and make it move horizontally. We need an animation loop. The idea is stated as follows. An animation loop is as follows: clear the screen update the positions of objects draw objects at their current positions pause for a short period of time repeat To clear the screen, L1: call Clrscr ;here, we label this line. Later on, we can jump back to here. In our case, an object is a character which is stored in AL. We need to set the coordinates of the object and then draw it on screen. The coordinates of an object are defined as a pair (column, row). Thus, we define column and row in.data as follows: column BYTE 0 row BYTE 0 In order to update the position, we increase the column coordinate of the object: inc BYTE PTR column ; treat the content at column as one byte and increase its value by 1. Then, we set the position of the object to the current position: mov dl, column mov dh, row call Gotoxy ; set the cursor position to (dl, dh) After that we draw the object (i.e., a char) as follows: mov al, A call WriteChar In order to pause the program for a while, we do the following: mov eax, 10; // in milliseconds call Delay Thus, there is one second delay if we do the following: mov eax, 1000; // in milliseconds call Delay Finally, we jump back to the beginning of the animation loop, i.e., jmp L1. Build your program and check it. You can find the solution in the solution folder. Do you see something that does not look well? The character is blinking while it s moving!
7 p6. Let s do something better than p5. We want to show an introduction message and then enter the animation loop. We have the followings: L0: show an introduction message L1: save the current positions of objects L2: update the positions of objects L3: draw objects (with the background color) at their old positions L4: draw objects (with their own colors) at their current positions L5: pause for a short period of time L6: constrain the positions of the objects within certain ranges repeat L1 L6 In this modified animation loop, we do not clear the screen anymore. Instead, we draw the objects twice but with different colors. When we draw the objects with background at the first time, we clear the regions that were covered by the objects. In the following, let s finish the items one by one. Define data:.data curx BYTE 0 ; current column cury BYTE 0 ; current row oldx BYTE 0 ; old column oldy BYTE 0 ; old row L0: show an introduction message call Clrscr mwriteln This is a simple animation written by XYZ. mwriteln Press a key to continue. Call ReadInt call Clrscr ; clear the screen before starting the animation L1: save the current positions of objects mov al, curx mov oldx, al mov al, cury mov oldy, al L2: update the positions of objects inc PTR BYTE curx L3: draw objects (with the background color) at their old positions mov dl, oldx mov dh, oldy call GotoXY
8 mov al, 0 call SetTextColor mov al, A call WriteChar L4: draw objects (with their own colors) at their current positions mov dl, oldx mov dh, oldy call GotoXY mov al, blue ; call SetTextColor ; set text color mov al, A call WriteChar L5: pause for a short period of time mov eax, 20 call Delay In order to make the x coordinate of the object lie within an interval, e.g., [0, 60], we add the following lines immediate after inc PTR BYTE curx : mov al, curx cmp al, 60 jna L2 mov al, 0 mov curx, al L2: Question: What happens if you add the above 6 lines after call Delay. After that we write: jmp L1 ; go to the L1 Build and run the program. You can see the motion blur of the character. There is no blinking anymore. You may use different colors to draw the character.
9 P7. We extend p6 to show characters with different colors (e.g., white, yellow and cyan). In each row, we show a character moving from the left to the right. If the x coordinate of an object is greater than 60, make it move from 0. You can assume that there are three characters and each character moves in one row. 1. Convert each item into a procedure. Give a meaningful name to each procedure. 2. Then, we have the followings: L1: call ShowIntroduction call SaveCurrentPositions call UpdateObjectPositions call DrawObjectsAtOldPositions call DrawObjectsAtCurrentPositions call DelayForAPeriod jmp L1 As you can see, we perform the tasks one by one and each task is associated with one procedure. Your code is very readable. At the end of each procedure, we must write down ret. For example, ShowIntroduction PROC call Clrscr mwriteln This is a simple animation written by XYZ. mwriteln Press a key to continue. Call ReadInt call Clrscr ; clear the screen before starting the animation ret ; return to the caller ShowIntroduction ENDP SaveCurrentPositions PROC ; we need three pairs of coordinates for three objects ; later on, we can use array and loop structure handle the following tedious data structure mov al, curx01 mov oldx01, al mov al, cury01 mov oldy01, al mov al, curx02 mov oldx02, al mov al, cury02
10 mov oldy02, al mov al, curx03 mov oldx03, al mov al, cury03 mov oldy03, al ret SaveCurrentPositions ENDP DelayForAPeriod PROC mov eax, 20 call Delay ret DelayForAPeriod ENDP Please convert the other tasks into procedures. You can find the solution in the solution folder. After you are done, add call Clrscr immediately after L1. Run the program again. You will see the moving characters which are blinking heavily. Note: After you have finished all the programs, ask yourself what you have learnt. Enjoy.
Lab 5: Input/Output using a Library of Procedures
COE 205 Lab Manual Lab 5: Input/Output using a Library of Procedures - Page 46 Lab 5: Input/Output using a Library of Procedures Contents 5.1. Using an External Library of Procedures for Input and Output
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 6 Input/output using a Library of Procedures April, 2014 1 Assembly Language LAB Using
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures. Chapter Overview. The Book's Link Library
Assembly Language for Intel-Based Computers, 4 th Edition Kip R Irvine Chapter 5: Procedures Slides prepared by Kip R Irvine Revision date: 10/3/2003 Chapter corrections (Web) Assembly language sources
More informationLibraries and Procedures
Computer Organization and Assembly Language Computer Engineering Department Chapter 5 Libraries and Procedures Presentation Outline Link Library Overview The Book's Link Library Runtime Stack and Stack
More informationBuild a program in Release mode and an executable file project.exe is created in Release folder. Run it.
Assembly Language and System Software Lab Exercise. Finish all the lab exercise under 50 minutes. In this lab exercise, you will learn to use the floating point unit (FPU). The FPU maintains a stack which
More informationLibraries and Procedures
Libraries and Procedures COE 205 Computer Organization and Assembly Language Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Link Library Overview The
More informationAssembly Language for Intel-Based Computers, 4 th Edition
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 5: Procedures Lecture 18 Linking to External Library The Book s Link Library Stack Operations Slides prepared by Kip R. Irvine
More informationCOE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh
Libraries i and Procedures COE 205 Computer Organization and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted from
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 10 Advanced Procedures May, 2014 1 Assembly Language LAB Stack Parameters There are
More informationAM2: Programming with Contemporary Instruction Set
: Programming with Contemporary Instruction Set Duration: 3 hours Components: Lab exercises and report. Objectives: (a) To examine how protected-mode programming is done on x86 based computer. (b) To evaluate
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 5: Procedures Slides prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2002. All rights reserved.
More informationMarking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 02/06/2018 Section 1 Weighting 40% of
More informationAssembly Language. Lecture 5 Procedures
Assembly Language Lecture 5 Procedures Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Linking to External Library The Irvine library Stack Operations Runtime Stack PUSH, POP
More informationAM2: Protected-Mode Programming
: Protected-Mode Programming Duration: 3 hours Components: Lab exercises and report. Objectives: (a) To examine how protected-mode programming is done on x86 based computer. (b) To evaluate the advantages
More informationAssembly Language. Lecture 5 Procedures
Assembly Language Lecture 5 Procedures Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Data Transfer Instructions Operand types MOV, MOVZX, MOVSX instructions LAHF, SAHF instructions
More informationEECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution
1. (40 points) Write the following subroutine in x86 assembly: Recall that: int f(int v1, int v2, int v3) { int x = v1 + v2; urn (x + v3) * (x v3); Subroutine arguments are passed on the stack, and can
More informationAssembly Language for Intel-Based Computers, 4 th Edition
Assembly Language for Intel-Based Computers, 4 th Edition Kip R Irvine Chapter 5: Procedures Lecture 19: Procedures Procedure s parameters Slides prepared by Kip R Irvine Revision date: 08/22/2002 Modified
More informationLab 6: Conditional Processing
COE 205 Lab Manual Lab 6: Conditional Processing Page 56 Lab 6: Conditional Processing Contents 6.1. Unconditional Jump 6.2. The Compare Instruction 6.3. Conditional Jump Instructions 6.4. Finding the
More informationProject Pr Write a program Writ i e t a re r port e
Project Write a program Write a report Overview In this project, you are going to implement a system for controlling the motion of objects. You should modify only the.asm file. The program is called directly
More informationMacros. Introducing Macros Defining Macros Invoking Macros Macro Examples Nested Macros Example Program: Wrappers
Macros Introducing Macros Defining Macros Invoking Macros Macro Examples Nested Macros Example Program: Wrappers Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 1 Introducing Macros A
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 9 Integer Arithmetic and Bit Manipulation April, 2014 1 Assembly Language LAB Bitwise
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 8. Conditional Processing
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 8 Conditional Processing April, 2014 1 Assembly Language LAB Unconditional Jump The
More informationCOMPUTER ENGINEERING DEPARTMENT
Page 1 of 11 COMPUTER ENGINEERING DEPARTMENT December 31, 2007 COE 205 COMPUTER ORGANIZATION & ASSEMBLY PROGRAMMING Major Exam II First Semester (071) Time: 7:00 PM-9:30 PM Student Name : KEY Student ID.
More informationLab 3: Defining Data and Symbolic Constants
COE 205 Lab Manual Lab 3: Defining Data and Symbolic Constants - page 25 Lab 3: Defining Data and Symbolic Constants Contents 3.1. MASM Data Types 3.2. Defining Integer Data 3.3. Watching Variables using
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 7. Procedures and the Stack
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 7 Procedures and the Stack April, 2014 1 Assembly Language LAB Runtime Stack and Stack
More informationAssembly Language Programming
Assembly Language Programming Integer Constants Optional leading + or sign Binary, decimal, hexadecimal, or octal digits Common radix characters: h hexadecimal d decimal b binary r encoded real q/o - octal
More informationModule 3 Instruction Set Architecture (ISA)
Module 3 Instruction Set Architecture (ISA) I S A L E V E L E L E M E N T S O F I N S T R U C T I O N S I N S T R U C T I O N S T Y P E S N U M B E R O F A D D R E S S E S R E G I S T E R S T Y P E S O
More informationCSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs
CSC 2400: Computer Systems Towards the Hardware: Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32)
More informationCOE 205 Lab Manual Experiment N o 12. Experiment N o Using the Mouse
Experiment N o 12 12 Using the Mouse Introduction The mouse is an I/O device that replaces the arrow keys on the keyboard for graphical and text style programs. This experiment shows how to add the mouse
More informationCSC 8400: Computer Systems. Machine-Level Representation of Programs
CSC 8400: Computer Systems Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32) 1 Compilation Stages
More informationWe can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...
COMPUTER ARCHITECTURE II: MICROPROCESSOR PROGRAMMING We can study computer architectures by starting with the basic building blocks Transistors and logic gates To build more complex circuits Adders, decoders,
More informationProgram Exploitation Intro
Program Exploitation Intro x86 Assembly 04//2018 Security 1 Univeristà Ca Foscari, Venezia What is Program Exploitation "Making a program do something unexpected and not planned" The right bugs can be
More informationCOMPUTER ENGINEERING DEPARTMENT
Page 1 of 14 COMPUTER ENGINEERING DEPARTMENT Jan. 7, 2010 COE 205 COMPUTER ORGANIZATION & ASSEMBLY PROGRAMMING Major Exam II First Semester (091) Time: 3:30 PM-6:00 PM Student Name : KEY Student ID. :
More informationLAB 3 Memory Addresses
LAB 3 Memory Addresses Objective: To access and explain the computer memory and memory addresses. To develop a program for moving data between CPU and RAM, and find the contents and addresses for each
More informationReverse Engineering Low Level Software. CS5375 Software Reverse Engineering Dr. Jaime C. Acosta
1 Reverse Engineering Low Level Software CS5375 Software Reverse Engineering Dr. Jaime C. Acosta Machine code 2 3 Machine code Assembly compile Machine Code disassemble 4 Machine code Assembly compile
More informationLab 2: Introduction to Assembly Language Programming
COE 205 Lab Manual Lab 2: Introduction to Assembly Language Programming - page 16 Lab 2: Introduction to Assembly Language Programming Contents 2.1. Intel IA-32 Processor Architecture 2.2. Basic Program
More informationSubprograms: Local Variables
Subprograms: Local Variables ICS312 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) Local Variables in Subprograms In all the examples we have seen so far, the subprograms were
More informationWe will first study the basic instructions for doing multiplications and divisions
MULTIPLICATION, DIVISION AND NUMERICAL CONVERSIONS We will first study the basic instructions for doing multiplications and divisions We then use these instructions to 1. Convert a string of ASCII digits
More information16.317: Microprocessor Systems Design I Fall 2014
16.317: Microprocessor Systems Design I Fall 2014 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More information.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]
Problem : Programming in Assembly [ Points] The following assembly program is supposed to: receive three integer numbers from the console, call a function, name sort, function sort arranges the three input
More informationRequired Setup for 32-bit Applications
1 of 23 8/25/2015 09:30 Getting Started with MASM and Visual Studio 2012 Updated 4/6/2015. This tutorial shows you how to set up Visual Studio 2012 (including Visual Studio 2012 Express for Windows Desktop)
More informationUNIT 4. Modular Programming
1 UNIT 4. Modular Programming Program is composed from several smaller modules. Modules could be developed by separate teams concurrently. The modules are only assembled producing.obj modules (Object modules).
More informationELEC VIDEO BIOS ROUTINES
It is less confusing to the user if we remove unnecessary messages from the display before giving information or instructions. At the command prompt, we do this with the DOS command CLS. However, this
More informationConstants and Expressions. Lecture 7: Assembly Language Programs. Constants and Expressions (cont.) Statements. Names. Assembly Directives
Lecture 7: Assembly Language Programs Basic elements of assembly language Assembler directives Data allocation directives Data movement instructions Assembling, linking, and debugging Using TASM Constants
More informationExperiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics
Experiment #5 Using BIOS Services and DOS functions Part 1: Text-based Graphics 5.0 Objectives: The objective of this experiment is to introduce BIOS and DOS interrupt service routines to be utilized in
More informationECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic
ECOM 2325 Computer Organization and Assembly Language Computer Engineering Department CHAPTER 7 Integer Arithmetic Presentation Outline Shift and Rotate Instructions Shift and Rotate Applications Multiplication
More informationPractical 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 informationAssembly basics CS 2XA3. Term I, 2017/18
Assembly basics CS 2XA3 Term I, 2017/18 Outline What is Assembly Language? Assemblers NASM Program structure I/O First program Compiling Linking What is Assembly Language? In a high level language (HLL),
More informationX86 Addressing Modes Chapter 3" Review: Instructions to Recognize"
X86 Addressing Modes Chapter 3" Review: Instructions to Recognize" 1 Arithmetic Instructions (1)! Two Operand Instructions" ADD Dest, Src Dest = Dest + Src SUB Dest, Src Dest = Dest - Src MUL Dest, Src
More informationADDRESSING MODES. Operands specify the data to be used by an instruction
ADDRESSING MODES Operands specify the data to be used by an instruction An addressing mode refers to the way in which the data is specified by an operand 1. An operand is said to be direct when it specifies
More informationAssembler Programming. Lecture 10
Assembler Programming Lecture 10 Lecture 10 Mixed language programming. C and Basic to MASM Interface. Mixed language programming Combine Basic, C, Pascal with assembler. Call MASM routines from HLL program.
More information16.317: Microprocessor Systems Design I Fall 2015
16.317: Microprocessor Systems Design I Fall 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationMicroprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)
Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition
More informationAssembly Language LAB
Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Created by: Eng. Ahmed M. Ayash Modified and Presented By: Eihab
More informationFaculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals
Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Assembly Language Lab # 2 Assembly Language Fundamentals Assembly Language Lab # 2 Assembly Language Fundamentals
More informationSOEN228, Winter Revision 1.2 Date: October 25,
SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003 1 Contents Flags Mnemonics Basic I/O Exercises Overview of sample programs 2 Flag Register The flag register stores the condition flags that retain
More informationObjectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8
Objectives ICT106 Fundamentals of Computer Systems Topic 8 Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8 To understand how HLL procedures/functions are actually implemented
More informationSummary: Direct Code Generation
Summary: Direct Code Generation 1 Direct Code Generation Code generation involves the generation of the target representation (object code) from the annotated parse tree (or Abstract Syntactic Tree, AST)
More informationUNIVERSITY OF CALIFORNIA, RIVERSIDE
Final Page 1 of 7 UNIVERSITY OF CALIFORNIA, RIVERSIDE Computer Science Department CS61 Machine Organization & Assembly Language Final September 1, 2000 53 Name: Solution Key Student ID#: Please print legibly
More informationBranching and Looping
Branching and Looping EECE416 uc Fall 2011 Unconditional Jumps jmp Like a goto in a high-level language Format: jmp StatementLabel The next statement executed will be the one at StatementLabel: jmp Encoding
More informationLow-Level Essentials for Understanding Security Problems Aurélien Francillon
Low-Level Essentials for Understanding Security Problems Aurélien Francillon francill@eurecom.fr Computer Architecture The modern computer architecture is based on Von Neumann Two main parts: CPU (Central
More informationLAB 4 Extending Signed and Unsigned Numbers
LAB 4 Extending Signed and Unsigned Numbers Objective: Explain unsigned and signed numbers, zero extension and sign extension, and variable declarations. The 80x86 provides several instructions that will
More informationSubprograms: Arguments
Subprograms: Arguments ICS312 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) Activation Records The stack is useful to store and rieve urn addresses, transparently managed via
More informationComputer Organization and Assembly Language. Lab Session 3
Lab Session 3 Objective: To be familiar with Basic Elements of Assembly Language Understanding Constants, Identifiers, Directives and Instructions. Theory: Integer Constants An integer constant (or integer
More informationELEC 242 Using Library Procedures
ELEC 242 Using Library Procedures There are a number of existing procedures that are already written for you that you will use in your programs. In order to use the library procedures that come with the
More information16.317: Microprocessor Systems Design I Spring 2015
16.317: Microprocessor Systems Design I Spring 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by
More informationStack -- Memory which holds register contents. Will keep the EIP of the next address after the call
Call without Parameter Value Transfer What are involved? ESP Stack Pointer Register Grows by 4 for EIP (return address) storage Stack -- Memory which holds register contents Will keep the EIP of the next
More informationChapter 3 (Part a) Assembly Language Fundamentals
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2025: Assembly Language Discussion Chapter 3 (Part a) Assembly Language Fundamentals Eng. Eman R. Habib February, 2014
More informationConstants and. Lecture 7: Assembly Language Programs. Expressions (cont.) Constants and. Statements. Expressions
Lecture 7: Assembly Language Programs Basic elements of assembly language Assembler directives Data allocation directives Data movement instructions Assembling, linking, and debugging Using TASM Constants
More informationOverview of Compiler. A. Introduction
CMPSC 470 Lecture 01 Topics: Overview of compiler Compiling process Structure of compiler Programming language basics Overview of Compiler A. Introduction What is compiler? What is interpreter? A very
More informationLab 4: Basic Instructions and Addressing Modes
COE 205 Lab Manual Lab 4: Basic Instructions and Addressing Modes - page 36 Lab 4: Basic Instructions and Addressing Modes Contents 4.1. Data Transfer Instructions 4.2. Addition and Subtraction 4.3. Data
More informationSystem calls and assembler
System calls and assembler Michal Sojka sojkam1@fel.cvut.cz ČVUT, FEL License: CC-BY-SA 4.0 System calls (repetition from lectures) A way for normal applications to invoke operating system (OS) kernel's
More informationLanguage of x86 processor family
Assembler lecture 2 S.Šimoňák, DCI FEEI TU of Košice Language of x86 processor family Assembler commands: instructions (processor, instructions of machine language) directives (compiler translation control,
More information1/26 Tuesday, January 26, :17 PM
csc250p1 Page 1 1/26 Tuesday, January 26, 2010 4:17 PM 1 2 a 6 0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 2^15 2^14 2^13 2^12 2^11 2^10 2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 2^1+2^2+2^5+2^7+2^9+2^12 = 4,774 Wednesday,
More information1 Number Representation(10 points)
Name: Sp15 Midterm Q1 1 Number Representation(10 points) 1 NUMBER REPRESENTATION(10 POINTS) Let x=0xe and y=0x7 be integers stored on a machine with a word size of 4bits. Show your work with the following
More informationdb "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'
PA4 Sample Solution.model large.stack 100h.data msg1 db "This programs scans a string of up to 256 bytes and counts the repetitions of the number 4206 and sums them.",0dh,0ah,'$' msg2 db "Please enter
More informationELEC 242 Time Delay Procedure
There are many occasions where we wish to time events. If we are using a personal computer, we have a number of ways to do this. The 8088/8086 computer had a Programmable Interval Timer like the 8253/54
More informationSample Exam I PAC II ANSWERS
Sample Exam I PAC II ANSWERS Please answer questions 1 and 2 on this paper and put all other answers in the blue book. 1. True/False. Please circle the correct response. a. T In the C and assembly calling
More informationIntroduction to Assembly Language
Introduction to Assembly Language COE 205 Computer Organization and Assembly Language Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Basic Elements
More informationECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION
ECOM 2325 Computer Organization and Assembly Language Instructor: Ruba A.Salamah INTRODUCTION Overview Welcome to ECOM 2325 Assembly-, Machine-, and High-Level Languages Assembly Language Programming Tools
More informationLaboratory IV LCD Framebuffer
Introduction Laboratory IV In this laboratory you will explore different ways of creating video images. There are four projects. In the first one you will create an image on the fly using PAL macros to
More informationmith College Computer Science CSC231 Assembly Week #9 Spring 2017 Dominique Thiébaut
mith College Computer Science CSC231 Assembly Week #9 Spring 2017 Dominique Thiébaut dthiebaut@smith.edu 2 Videos to Watch at a Later Time https://www.youtube.com/watch?v=fdmzngwchdk https://www.youtube.com/watch?v=k2iz1qsx4cm
More information#include <stdio.h> #include <math.h> int shownum(int digits[], int digitcount);
Problem 1: Programming in C [20 Points] Write a C program that takes as input a positive integer number and converts it to base 4. Some examples of input and output of this program are as follow: Example
More informationDr. D.M. Akbar Hussain
1 2 Compiler Construction F6S 1 3 4 Compiler Construction F6S 2 5 6 Compiler Construction F6S 3 7 8 Compiler Construction F6S 4 a=b*- c + b*- c 9 a=b*- c + b*- c 10 Compiler Construction F6S 5 a=b*- c
More informationMarking Scheme. Examination Paper. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 12/06/2017 Section 1 Weighting 40% of
More informationMODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE
EXERCISE 9. Determine the mod bits from Figure 7-24 and write them in Table 7-7. MODE (mod) FIELD CODES mod 00 01 10 DESCRIPTION MEMORY MODE: NO DISPLACEMENT FOLLOWS MEMORY MODE: 8-BIT DISPLACEMENT MEMORY
More informationBranching and Looping
X86 Assembly Language Programming: Branching and Looping EECE416 uc Charles Kim Howard University Fall 2013 www.mwftr.com Unconditional Jump: JMP jmp Like a goto in a high-level language Format: jmp StatementLabel
More informationAssembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction
Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction E I P CPU isters Condition Codes Addresses Data Instructions Memory Object Code Program Data OS Data Topics Assembly Programmer
More informationTopic 6: Code Generation
Compilers 2008 Topic 6: 6.4 Conditional Instructions Status Flags Conditionals A special register exists called the FLAGS register Consists of a sequence of bits, which are set (1) or unset (0). These
More informationChapter 3: Addressing Modes
Chapter 3: Addressing Modes Chapter 3 Addressing Modes Note: Adapted from (Author Slides) Instructor: Prof. Dr. Khalid A. Darabkh 2 Introduction Efficient software development for the microprocessor requires
More informationComputer Organization and Assembly Language. Lab Session 4
Lab Session 4 Objective: Learn how Data is represented in Assembly Language Introduction to Data Types and using different Data Types in Assembly language programs Theory: The basic machine data types
More informationprintf( Please enter another number: ); scanf( %d, &num2);
CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful
More informationUsing MMX Instructions to Perform Simple Vector Operations
Using MMX Instructions to Perform Simple Vector Operations Information for Developers and ISVs From Intel Developer Services www.intel.com/ids Information in this document is provided in connection with
More informationVideo processing The INT instruction enables program to interrupt its own processing. Use INT instruction to handle inputs and outputs
Video processing The INT instruction enables program to interrupt its own processing. Use INT instruction to handle inputs and outputs INT 10H: screen handling INT 21H: for displaying screen output and
More informationCPS104 Recitation: Assembly Programming
CPS104 Recitation: Assembly Programming Alexandru Duțu 1 Facts OS kernel and embedded software engineers use assembly for some parts of their code some OSes had their entire GUIs written in assembly in
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College February 9, 2016 Reading Quiz Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between
More informationProgramming Model 2 A. Introduction
Programming Model 2 A. Introduction Objectives At the end of this lab you should be able to: Use direct and indirect addressing modes of accessing data in memory Create an iterative loop of instructions
More informationAssembly Language Each statement in an assembly language program consists of four parts or fields.
Chapter 3: Addressing Modes Assembly Language Each statement in an assembly language program consists of four parts or fields. The leftmost field is called the label. - used to identify the name of a memory
More informationComplex Instruction Set Computer (CISC)
Introduction ti to IA-32 IA-32 Processors Evolutionary design Starting in 1978 with 886 Added more features as time goes on Still support old features, although obsolete Totally dominate computer market
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College September 25, 2018 Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between programmer
More information