LAB 3 Memory Addresses

Size: px
Start display at page:

Download "LAB 3 Memory Addresses"

Transcription

1 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 memory variable. To exam the address relationship among the memory variables and declared poers. To find the size of a variable in bytes. To exam indirect memory addressing mode. 1) Type and explain Example 1. Compile, Build, and Run the program. Example 1 illustrates to use of a. a poer to store the address of each element in an 8-bit array b. the address of operator (&) to initialize a poer c. MOV instruction to move the address of each element in an array to registers EAX (or EBX or ECX or EDX, etc), such as MOV EAX, cptr d. sizeof operator to find out the number of bytes of each element in the array and the address of each element in the array. e. indirect memory addressing mode to access the content stored in the memory location, for instance, MOV DL, [EAX] 2) Explain each line of Example 1 (addressconten.cpp) and describe the output of each in your lab report 3) Modify Example 2 and Example 3 provided in addresscontentemp.cpp to do: a. find the content and memory address of a16-bit array b. find the content and memory address of a 32-bit array c. find the size in bytes of the content and memory address of a 16 bit array d. find the size in bytes of the content and memory address of a 32 bit array e. use indirect addressing mode to find the content stored in the memory location and compare to the content of the original array 4) Explore the relationship among these addresses in memory. Understand the addresses for a byte, a word, and a double word, respectively. 5) Draw a table of the relationship among the variable value, the size of the variable, and the memory address of the variable. 6) Analyze the information in the table to understand the Little Endian Computer 7) Exam byte-addressable memory to store a byte, a word, and a double word, respectively. Written exercises: A title page with the lab title, your name and other identification, the current date, and the due date. If you modify or create a program in an exercise, the source code with comments for that program should appear in the laboratory report. The output from all programs should also appear in the lab report. For each exercise, you should provide a write-up describing the purpose of the exercise, what you learned from the exercise, and any comments, improvements, or other work you ve done with the exercise. If you make any mistakes that require correction, you should include the source code for the incorrect program with your lab report. Hand write on the listing where the error occurs and describe what you did to correct the problem. Appropriate diagrams can be included if needed.

2 Example 1 /*********************************************************** File name: addresscontent.cpp Find the content and the address for each memory variable in the array Method: Embedding an in-line assembly language module in a C program A. Find the contents for each element of an 8-bit array B. Find the addresses for each element of an 8-bit array C. Find out the number of bytes of each element in an 8-bit array D. Find out the number of bytes of the address of each element in an 8-bit array E. Access the content stored in the memory location by indirect memory addressing mode MOV DL, [EAX] to access the content stored in the memory location EAX sizeof() to find the number of byte prf() is used to display information on the console scanf_s() is used to receive the information from the keyboard std::cout is used to display the output on the console system ("pause") is used to hold console *************************************************************/ #include <stdio.h> // to use prf() #include <iostream> // to use system ("pause") to hold console; main() /*An 8-bit one dimensional sc8_arr[5] array declaration and initialization. Poers of scptr0, scptr1, etc will be used to store the address of each element of the array A 32-bit array md[5] will be used to store each of poers A 32-bit array madd[5] is used to store the address of each element of the array A 8-bit array var[5] is used to store the retrieved value by indirect memory addressing mode*/ sc8_arr[5] = 0x41, 0x42, 0x79, 0x7A, 0x7B ; *scptr0, *scptr1, *scptr2, *scptr3, *scptr4; md[5], madd[5]; var[4]; i; // used as index //address for each element in an array sc8_arr[5] scptr0 = &sc8_arr [0]; scptr1 = &sc8_arr [1]; scptr2 = & sc8_arr[2]; scptr3 = & sc8_arr[3]; scptr4 = & sc8_arr[4]; //Display Hex value, decimal value, and value for each element of array prf(" \n"); prf(" the value of each element of 8-bit array \n"); for (i=0; i < 5; i++) prf ("The value of element %d in an array is 0x%x (hex), %d(decimal), %c (acter)\n", i, sc8_arr[i], sc8_arr[i], sc8_arr[i]);

3 //Display address in hexadecimal for each element of array prf(" \n"); prf(" the address of each element of 8-bit array \n"); for (i=0; i < 5; i++) prf ("The memory address of element %d in an array is 0x%X (hexidecimal)\n", i, scptr0+i); prf(" \n"); //find the total numbers in byte of array sc8_arr[5] // find the number of byte of each element of array prf("\n"); prf(" the size information in bytes of an 8-bit array \n"); prf ("The total numbers in bytes of an 8-bit array with 5 elements is %d bytes\n", sizeof (sc8_arr)); md[i] = sizeof (sc8_arr [i]); madd[i] = sizeof(scptr0+i); prf (" \n"); prf ("the size of element %d is %d bytes\n", i, md[i]); prf ("the size of the address of the element %d is %d bytes\n ", i, madd[i]); //Indirect memory addressing by MOV DL, [EAX] /*move the address of element 0 to EAX store the content at the address shown in EAX o DL(indirect addressing) move the content of DL o the variable of var[0]*/ MOV EAX, scptr0; MOV DL, [EAX]; MOV var[0], DL; /*move the address of element 1 to EAX store the content at the address shown in EAX o DL(indirect addressing) move the content of DL o the variable of var[1]*/ MOV EAX, scptr1; MOV DL, [EAX]; MOV var[1], DL; /* move the address of element 2 to EAX store the content at the address shown in EAX o DL(indirect addressing) move the content of DL o the variable of var[2]*/ MOV EAX, scptr2;

4 MOV DL, [EAX]; MOV var[2], DL; /*move the address of element 3 to EAX store the content at the address shown in EAX o DL(indirect addressing) move the content of DL o the variable of var[3]*/ MOV EAX, scptr3 MOV DL, [EAX]; MOV var[3], DL; prf(" \n"); prf(" the value of each element of two 8-bit arrays \n"); prf("the values at the index %d of the original array and the retrieved array \n", i); prf("by indirect addressing mode are: 0x%x(hex) and 0x%x(hex), respectively\n", sc8_arr[i], var[i]); prf (" \n"); system ("pause"); return 0;

5 The output from addresscontent.cpp Example 2 (Template for 16 bit array) /*********************************************************** File name: addresscontenttemp.cpp Find the content and the address for each memory variable in the array Method: Embedding an in-line assembly language module in a C program A. Find the contents for each element of a 16-bit array B. Find the addresses for each element of a 16-bit array C. Find out the number of bytes of each element in a 16-bit array D. Find out the number of bytes of the address of each element in a 16-bit array E. Access the content stored in the memory location by indirect memory addressing mode

6 MOV DL, [EAX] to access the content stored in the memory location EAX sizeof() to find the number of byte prf() is used to display information on the console scanf_s() is used to receive the information from the keyboard std::cout is used to display the output on the console system ("pause") is used to hold console *************************************************************/ #include <stdio.h> // to use prf() #include <iostream> // to use system ("pause"); main() /*A 16-bit one dimensional array declaration and initialization. Poers of svptr0, svptr1, etc will be used to store the address of each element of the array A 32-bit array md[4] will be used to store each of poers A 32-bit array madd[4] is used to store the address of each element of the array A 16-bit array svar[4] is used to store the retrived value by indirect memory addressing mode*/ short sh16_arr[4] = -1, -3, 1000, 2000; //16-bit array short *svptr0, *svptr1, *svptr2, *svptr3; // used to store the address md[4], madd[4]; short svar[4]; i; // used as index //address for each element in an array sh16_arr[4] //Display Hex value, decimal value, and short value for each element of array prf(" the value of each element of 16-bit array \n"); //Display address in hexadecimal for each element of array prf("\n"); prf(" the address of each element of 16-bit array \n"); // find the numbber of byte of each element of array prf("\n"); prf(" the size information in byte of 8-bit array \n"); //Indirect memory addressing by MOV DX, [EAX]

7 prf(" the value of each element of two 16-bit arrays \n"); system ("pause"); return 0; Example 3 (Template for 32 bit array) /*********************************************************** File name: addresscontenttemp.cpp Find the content and the address for each memory variable in the array Method: Embedding an in-line assembly language module in a C program A. Find the contents for each element of a 32-bit array B. Find the addresses for each element of a 32-bit array C. Find out the number of bytes of each element in a 32-bit array D. Find out the number of bytes of the address of each element in a 32-bit array E. Access the content stored in the memory location by indirect memory addressing mode MOV DL, [EAX] to access the content stored in the memory location EAX sizeof() to find the number of byte prf() is used to display information on the console scanf_s() is used to receive the information from the keyboard std::cout is used to display the output on the console system ("pause") is used to hold console *************************************************************/ #include <stdio.h> // to use prf() #include <iostream> // to use system ("pause"); main() /*A 32-bit one dimentional array declaration and initilization.

8 Poers of ivptr0, ivptr1, etc will be used to store the address of each element of the array A 32-bit array md[4] will be used to store each of poers A 32-bit array madd[4] is used to store the address of each element of the array A 32-bit array ivar[4] is used to store the retrived value by indirect memory addressing mode*/ i32_arr[4]=0x , 0x0000ffff, , ; //32-bit (double word) array *ivptr0, *ivptr1, *ivptr2, *ivptr3; //ivptr0, ivptr1, ivptr2 are used to store the address md[4], madd[4]; short svar[4]; i; // used as index //address for each element in an array i32_arr[4] //Display Hex value, decimal value, and short value for each element of array prf(" the value of each element of 32-bit array \n"); //Display address in hexadecimal for each element of array prf(" the address of each element of 32-bit array \n"); // find the numbber of byte of each element of array prf(" the size information in byte of 8-bit array \n"); //Indirect memory addressing by MOV EDX, [EAX]

9 prf(" the value of each element of two 32-bit arrays \n"); system ("pause"); return 0; Fill in the table with data types, memory contents, and memory addresses Data type short short Short (array with 4 elements) short Variable name sc8_arr[0] sc8_arr[1] sc8_arr[2] sc8_arr[3] sc8_arr[4] sh16_arr[0] sh16_arr[1] sh16_arr[2] sh16_arr[3] i32_arr[0] i32_arr[1] i32_arr[2] i32_arr[3] Hexadecimal Decimal Address

10 Fill in the table with the size of memory contents, and the size of memory addresses, respectively Data type (array with 5 elements) short short short short (array with 4 elements) Variable name sc8_arr[0] sc8_arr[1] sc8_arr[2] sc8_arr[3] sc8_arr[4] sh16_arr[0] sh16_arr[1] sh16_arr[2] sh16_arr[3] i32_arr[0] i32_arr[1] i32_arr[2] i32_arr[3] Size of each contents in byte(s) Size of each memory addresses in byte(s)

LAB 4 Extending Signed and Unsigned Numbers

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

LAB 5 Arithmetic Operations Simple Calculator

LAB 5 Arithmetic Operations Simple Calculator LAB 5 Arithmetic Operations Simple Calculator Objective: Practice arithmetic operation for the 80x86, such as add, subtract, multiple, divide, and mod. When dealing with the multiply, divide, and mod instructions

More information

Lab 8 The Stack (LIFO) Structure

Lab 8 The Stack (LIFO) Structure Lab 8 The Stack (LIFO) Structure Objective: The stack segment in memory is where the 80x86 maintains the stack. The stack stores important information about program including local variables, subroutine

More information

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut dthiebaut@smith.edu Homework Solutions Outline Review Hexdump Pentium Data Registers 32-bit, 16-bit and 8-bit quantities (registers

More information

In order to run the program, go to the folder Release and run project.exe.

In order to run the program, go to the folder Release and run project.exe. 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

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

mith College Computer Science CSC231 - Assembly Week #3 Dominique Thiébaut

mith College Computer Science CSC231 - Assembly Week #3 Dominique Thiébaut mith College Computer Science CSC231 - Assembly Week #3 Dominique Thiébaut dthiebaut@smith.edu memory mov add registers hexdump listings number systems Let's Review Last Week's Material section.data

More information

MODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE

MODE (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 information

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

Computer Systems Lecture 9

Computer Systems Lecture 9 Computer Systems Lecture 9 CPU Registers in x86 CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important conditions

More information

Lab 3: Defining Data and Symbolic Constants

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

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated CNIT 127: Exploit Development Ch 1: Before you begin Updated 1-14-16 Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend, such as Denial

More information

Load Effective Address Part I Written By: Vandad Nahavandi Pour Web-site:

Load Effective Address Part I Written By: Vandad Nahavandi Pour   Web-site: Load Effective Address Part I Written By: Vandad Nahavandi Pour Email: AlexiLaiho.cob@GMail.com Web-site: http://www.asmtrauma.com 1 Introduction One of the instructions that is well known to Assembly

More information

Lab 4: Basic Instructions and Addressing Modes

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

ADDRESSING MODES. Operands specify the data to be used by an instruction

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

Lab 5: Input/Output using a Library of Procedures

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 information

Faculty of Engineering Student Number:

Faculty of Engineering Student Number: Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, Second Semester: 2013/2014 Course Title: Microprocessors Date: 08/06/2014 Course No:

More information

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents. Intel Assembly Format of an assembly instruction: LABEL OPCODE OPERANDS COMMENT DATA1 db 00001000b ;Define DATA1 as decimal 8 START: mov eax, ebx ;Copy ebx to eax LABEL: Stores a symbolic name for the

More information

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

Assembly Language Lab # 9

Assembly Language Lab # 9 Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Assembly Language Lab # 9 Stacks and Subroutines Eng. Doaa Abu Jabal Assembly Language Lab # 9 Stacks and Subroutines

More information

mith College Computer Science CSC231 - Assembly Week #8 Dominique Thiébaut

mith College Computer Science CSC231 - Assembly Week #8 Dominique Thiébaut mith College Computer Science CSC231 - Assembly Week #8 Dominique Thiébaut dthiebaut@smith.edu Can't Sleep https://xkcd.com/571/ Logic Design Logic Design Image from http://www.willegal.net/appleii/images/motherboard.jpg

More information

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

Full Name: CISC 360, Fall 2008 Example of Exam

Full Name: CISC 360, Fall 2008 Example of Exam Full Name: CISC 360, Fall 2008 Example of Exam Page 1 of 0 Problem 1. (12 points): Consider the following 8-bit floating point representation based on the IEEE floating point format: There is a sign bit

More information

Assembly Language Each statement in an assembly language program consists of four parts or fields.

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

CS , Fall 2001 Exam 1

CS , Fall 2001 Exam 1 Andrew login ID: Full Name: CS 15-213, Fall 2001 Exam 1 October 9, 2001 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1 Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD 21252 rkarne@towson.edu 11/12/2014 Slide 1 Intel x86 Aseembly Language Assembly Language Assembly Language

More information

mith College Computer Science CSC231 Assembly Week #9 Fall 2017 Dominique Thiébaut

mith College Computer Science CSC231 Assembly Week #9 Fall 2017 Dominique Thiébaut mith College Computer Science CSC231 Assembly Week #9 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Looping Through Arrays LOOP INSTRUCTION Looping Through Arrays INDIRECT ADDRESSING MODE Indirect Addressing

More information

CS , Fall 2004 Exam 1

CS , Fall 2004 Exam 1 Andrew login ID: Full Name: CS 15-213, Fall 2004 Exam 1 Tuesday October 12, 2004 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front.

More information

OBJECT ORIENTED PROGRAMMING

OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object

More information

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III. CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1 Name: Question Points I. /34 II. /30 III. /36 TOTAL: /100 Instructions: 1. This is a closed-book, closed-notes exam. 2. You

More information

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

The Instruction Set. Chapter 5

The Instruction Set. Chapter 5 The Instruction Set Architecture Level(ISA) Chapter 5 1 ISA Level The ISA level l is the interface between the compilers and the hardware. (ISA level code is what a compiler outputs) 2 Memory Models An

More information

mith College Computer Science CSC231 - Assembly Week #9 Dominique Thiébaut

mith College Computer Science CSC231 - Assembly Week #9 Dominique Thiébaut mith College Computer Science CSC231 - Assembly Week #9 Dominique Thiébaut dthiebaut@smith.edu https://docs.google.com/forms/d/e/1faipqlscgsgjakylraq3zt6rvr-xmksy1zxrpe0myhpanyigp8byjba/viewform 1,000,000

More information

Assembly Language LAB

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

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

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

CSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature

CSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature CSE2421 FINAL EXAM SPRING 2013 Name KEY Instructions: This is a closed-book, closed-notes, closed-neighbor exam. Only a writing utensil is needed for this exam. No calculators allowed. If you need to go

More information

CPU. IBM PC and compatible Memory Structure

CPU. IBM PC and compatible Memory Structure CPU The CPU is usually organised in three parts: The Arithmetic and Logic Unit or ALU (which performs computations and comparisons) and the Control Unit which fetches information from and stores information

More information

C and Programming Basics

C and Programming Basics Announcements Assignment 1 Will be posted on Wednesday, Jan. 9 Due Wednesday, Jan. 16 Piazza Please sign up if you haven t already https://piazza.com/sfu.ca/spring2019/cmpt125 Lecture notes Posted just

More information

X86 Assembly Language and C Fundamentals. Chapter 5. Data Transfer Instructions. X86 Code Figures

X86 Assembly Language and C Fundamentals. Chapter 5. Data Transfer Instructions. X86 Code Figures 1 X86 Assembly Language and C Fundamentals Chapter 5 Data Transfer Instructions X86 Code Figures 2 Page 200, Figure 5.4 ;swap_bytes.asm ;-----------------------------------------------------------.STACK

More information

By: Dalbir Singh, Computer Science Dep't

By: Dalbir Singh, Computer Science Dep't Assembly language is essentially the native language of your computer. Technically the processor of your machine understands machine code (consisting of ones and zeroes). But in order to write such a machine

More information

16.317: Microprocessor Systems Design I Fall 2014

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

Module 3 Instruction Set Architecture (ISA)

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

Chapter 11. Addressing Modes

Chapter 11. Addressing Modes Chapter 11 Addressing Modes 1 2 Chapter 11 11 1 Register addressing mode is the most efficient addressing mode because the operands are in the processor itself (there is no need to access memory). Chapter

More information

CS , Fall 2002 Exam 1

CS , Fall 2002 Exam 1 Andrew login ID: Full Name: CS 15-213, Fall 2002 Exam 1 October 8, 2002 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

Data Transfers, Addressing, and Arithmetic. Part 2

Data Transfers, Addressing, and Arithmetic. Part 2 Islamic University Of Gaza Assembly Language Faculty of Engineering Discussion Computer Department Chapter 4 Created By: Eng. Ahmed M. Ayash Modified and Presented by: Eng. Eihab S. El-Radie Chapter 4

More information

CS , Spring 2004 Exam 1

CS , Spring 2004 Exam 1 Andrew login ID: Full Name: CS 15-213, Spring 2004 Exam 1 February 26, 2004 Instructions: Make sure that your exam is not missing any sheets (there should be 15), then write your full name and Andrew login

More information

Lab 2: Introduction to Assembly Language Programming

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

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Microprocessors & 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 information

Subprograms: Local Variables

Subprograms: 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 information

CS 3843 Final Exam Fall 2012

CS 3843 Final Exam Fall 2012 CS 3843 Final Exam Fall 2012 Name (Last), (First) ID Please indicate your session: Morning Afternoon You may use a calculator and two sheets of notes on this exam, but no other materials and no computer.

More information

CS 3330 Introduction 1

CS 3330 Introduction 1 CS 3330 Introduction 1 layers of abstraction 2 x += y Higher-level language: C add %rbx, %rax! 60 03 SIXTEEN Assembly: X86-64 Machine code: Y86 Hardware Design Language: HCLRS Gates / Transistors / Wires

More information

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

Computer Systems II. Memory Management Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed Computer Systems II Memory Management" Memory Management" Subdividing memory to accommodate many processes A program is loaded in main memory to be executed Memory needs to be allocated efficiently to

More information

Question 4.2 2: (Solution, p 5) Suppose that the HYMN CPU begins with the following in memory. addr data (translation) LOAD 11110

Question 4.2 2: (Solution, p 5) Suppose that the HYMN CPU begins with the following in memory. addr data (translation) LOAD 11110 Questions 1 Question 4.1 1: (Solution, p 5) Define the fetch-execute cycle as it relates to a computer processing a program. Your definition should describe the primary purpose of each phase. Question

More information

COMP 210 Example Question Exam 2 (Solutions at the bottom)

COMP 210 Example Question Exam 2 (Solutions at the bottom) _ Problem 1. COMP 210 Example Question Exam 2 (Solutions at the bottom) This question will test your ability to reconstruct C code from the assembled output. On the opposing page, there is asm code for

More information

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 16.317: Microprocessor Systems Design I Fall 2014 Exam 2 November 5, 2014 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices (e.g.,

More information

buffer overflow exploitation

buffer overflow exploitation buffer overflow exploitation Samuele Andreoli, Nicolò Fornari, Giuseppe Vitto May 11, 2016 University of Trento Introduction 1 introduction A Buffer Overflow is an anomaly where a program, while writing

More information

Chapter 3: Addressing Modes

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

mith College Computer Science CSC231 Assembly Week #5 Fall 2017 Dominique Thiébaut

mith College Computer Science CSC231 Assembly Week #5 Fall 2017 Dominique Thiébaut mith College Computer Science CSC231 Assembly Week #5 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7 1000 8 8 1001 9 9 1010 A 10

More information

16.317: Microprocessor Systems Design I Fall 2015

16.317: Microprocessor Systems Design I Fall 2015 16.317: Microprocessor Systems Design I Fall 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

Lab 6: Conditional Processing

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

CS 5513 Entry Quiz. Systems Programming (CS2213/CS3423))

CS 5513 Entry Quiz. Systems Programming (CS2213/CS3423)) Name (please print): CS 5513 Entry Quiz Systems Programming (CS2213/CS3423)) 1. What is a compiler? In addition to the definition, give examples of compilers you have used. A compiler is a program that

More information

Assembly Language Programming: Procedures. EECE416 uc. Charles Kim Howard University. Fall

Assembly Language Programming: Procedures. EECE416 uc. Charles Kim Howard University. Fall Assembly Language Programming: Procedures EECE416 uc Charles Kim Howard University Fall 2013 www.mwftr.com Before we start Schedule of the next few weeks T Nov 19: Procedure and Calls (continued) R Nov

More information

Introduction to 8086 Assembly

Introduction to 8086 Assembly Introduction to 8086 Assembly Lecture 6 Working with memory Why using memory? Registers are limited in number and size Program data Program code etc. The data segment dd 1234 dw 13 db -123 The data segment

More information

CPSC 121: Models of Computation Lab #9: A Working Computer

CPSC 121: Models of Computation Lab #9: A Working Computer CPSC 121: Models of Computation Lab #9: A Working Computer Objectives In this lab, we revisit the Y86 processor, which you saw components of in labs 4 and 6. Recall that in lab 4, you learned about the

More information

16.317: Microprocessor Systems Design I Spring 2015

16.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 information

EEM336 Microprocessors I. Addressing Modes

EEM336 Microprocessors I. Addressing Modes EEM336 Microprocessors I Addressing Modes Introduction Efficient software development for the microprocessor requires a complete familiarity with the addressing modes employed by each instruction. This

More information

Assembly Language Programming

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

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

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

Datorarkitektur, 2009 Tentamen

Datorarkitektur, 2009 Tentamen Namn: Personnummer: Datorarkitektur, 2009 Tentamen 2009-03-13 Instructions: Make sure that your exam is not missing any sheets, then write your full name on the front. Write your answers in the space provided

More information

Ethical Hacking. Assembly Language Tutorial

Ethical Hacking. Assembly Language Tutorial Ethical Hacking Assembly Language Tutorial Number Systems Memory in a computer consists of numbers Computer memory does not store these numbers in decimal (base 10) Because it greatly simplifies the hardware,

More information

Computer Systems Organization V Fall 2009

Computer Systems Organization V Fall 2009 Computer Systems Organization V22.0201 Fall 2009 Sample Midterm Exam ANSWERS 1. True/False. Circle the appropriate choice. (a) T (b) F At most one operand of an x86 assembly instruction can be an memory

More information

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017 CS 31: Intro to Systems ISAs and Assembly Martin Gagné Swarthmore College February 7, 2017 ANNOUNCEMENT All labs will meet in SCI 252 (the robot lab) tomorrow. Overview How to directly interact with hardware

More information

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

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

Philadelphia University Student Name: Student Number:

Philadelphia University Student Name: Student Number: Philadelphia University Student Name: Student Number: Faculty of Engineering Serial Number: Final Exam, Second Semester: 2016/2017 Dept. of Computer Engineering Course Title: Microprocessors Date: 12/06/2017

More information

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to: Introduction Efficient software development for the microprocessor requires a complete familiarity with the addressing modes employed by each instruction. This chapter explains the operation of the stack

More information

EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim

EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim EECE416 :Microcomputer Fundamentals and Design X86 Assembly Programming Part 1 Dr. Charles Kim Department of Electrical and Computer Engineering Howard University www.mwftr.com 1 Multiple Address Access

More information

Basic Information. CS318 Project #1. OS Bootup Process. Reboot. Bootup Mechanism

Basic Information. CS318 Project #1. OS Bootup Process. Reboot. Bootup Mechanism Basic Information CS318 Project #1 Bootup Mechanism Lab is in 010 Friend Center Use your OIT username/password If you get the error unable to mount /u/username contact me, (most student should have it

More information

Assembly Language for Intel-Based Computers, 4 th Edition

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

CPSC 213. Introduction to Computer Systems. Numbers and Memory. Unit 1a

CPSC 213. Introduction to Computer Systems. Numbers and Memory. Unit 1a CPSC 213 Introduction to Computer Systems Unit 1a Numbers and Memory 1 The Big Picture Build machine model of execution for Java and C programs by examining language features and deciding how they are

More information

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM EXPERIMENT WRITE UP AIM: Assembly language program for 16 bit BCD addition LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM TOOLS/SOFTWARE

More information

Is stack overflow still a problem?

Is stack overflow still a problem? Morris Worm (1998) Code Red (2001) Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 31st January 2017 Memory corruption Buffer overflow remains

More information

Experiment 8 8 Subroutine Handling Instructions and Macros

Experiment 8 8 Subroutine Handling Instructions and Macros Introduction Experiment 8 8 Subroutine Handling Instructions and Macros In this experiment you will be introduced to subroutines and how to call them. You will verify the exchange of data between a main

More information

Operating Systems. Part 8. Operating Systems. What is an operating system? Interact with Applications. Vector Tables. The master software

Operating Systems. Part 8. Operating Systems. What is an operating system? Interact with Applications. Vector Tables. The master software Part 8 Operating Systems Operating Systems The master software Operating Systems What is an operating system? Master controller for all of the activities that take place within a computer Basic Duties:

More information

(the bubble footer is automatically inserted into this space)

(the bubble footer is automatically inserted into this space) CS 2150 Exam 2, spring 2015 Page 1 of 6 UVa userid: CS 2150 Exam 2, spring 2015 Name You MUST write your e-mail ID on EACH page and bubble in your userid at the bottom of this first page. And put your

More information

Assembly 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. 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 information

CS 3330 Introduction. Daniel and Charles. CS 3330 Computer Architecture 1

CS 3330 Introduction. Daniel and Charles. CS 3330 Computer Architecture 1 CS 3330 Introduction Daniel and Charles CS 3330 Computer Architecture 1 lecturers Charles and I will be splitting lectures same(ish) lecture in each section Grading Take Home Quizzes: 10% (10% dropped)

More information

Computer Architecture and Assembly Language. Practical Session 3

Computer Architecture and Assembly Language. Practical Session 3 Computer Architecture and Assembly Language Practical Session 3 Advanced Instructions division DIV r/m - unsigned integer division IDIV r/m - signed integer division Dividend Divisor Quotient Remainder

More information

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

ET156 Introduction to C Programming

ET156 Introduction to C Programming ET156 Introduction to C Programming Unit 1 INTRODUCTION TO C PROGRAMMING: THE C COMPILER, VARIABLES, MEMORY, INPUT, AND OUTPUT Instructor : Stan Kong Email : skong@itt tech.edutech.edu Figure 1.3 Components

More information

ECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic

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

Lab 3. Pointers Programming Lab (Using C) XU Silei

Lab 3. Pointers Programming Lab (Using C) XU Silei Lab 3. Pointers Programming Lab (Using C) XU Silei slxu@cse.cuhk.edu.hk Outline What is Pointer Memory Address & Pointers How to use Pointers Pointers Assignments Call-by-Value & Call-by-Address Functions

More information

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100 16.317: Microprocessor-Based Systems I Fall 2012 Exam 1 October 3, 2012 Name: ID #: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic devices (e.g.,

More information

CMSC Lecture 03. UMBC, CMSC313, Richard Chang

CMSC Lecture 03. UMBC, CMSC313, Richard Chang CMSC Lecture 03 Moore s Law Evolution of the Pentium Chip IA-32 Basic Execution Environment IA-32 General Purpose Registers Hello World in Linux Assembly Language Addressing Modes UMBC, CMSC313, Richard

More information

CS 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 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

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

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software. Outline Morris Worm (1998) Infamous attacks Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 23rd January 2014 Recap Simple overflow exploit

More information

C++ to assembly to machine code

C++ to assembly to machine code IBCM 1 C++ to assembly to machine code hello.cpp #include int main() { std::cout

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