AM2: Programming with Contemporary Instruction Set

Size: px
Start display at page:

Download "AM2: Programming with Contemporary Instruction Set"

Transcription

1 : 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 the advantages of protected-mode programming compared to real-mode programming in x86 microprocessor. (c) To develop protected-mode assembly language programs which utilize the floatingpoint unit (FPU) on x86 based computer. (d) To develop Win32 Console programs based on x86 assembly language. 1. Floating-Point Unit The Intel 8086 processor was designed to handle only integer arithmetic. This turned out to be a problem for graphics and calculation-intensive software using floating-point calculations. It was possible to emulate floating-point arithmetic purely through software, but the performance penalty was severe. Programs such as AutoCad (by Autodesk) demanded a more powerful way to perform floating-point math. Intel sold a separate floating-point coprocessor chip named the 8087, and upgraded it along with each processor generation. Beginning from Intel 80486, the floating-point hardware was integrated into the processor and known as the floating-point unit (FPU). 1.1 FPU Register Stack The FPU does not use the general-purpose registers (EAX, EBX, etc.). Instead, it has its own set of registers called a register stack. It loads values from memory into the register stack, performs calculations, and stores stack values into memory. FPU instructions evaluate mathematical expressions in postfix format. The following, for example, is called an infix expression: (5 * 6) + 4. The postfix equivalent is 5 6 * 4 + The infix expression (A + B) * C requires parenthesis to override the default precedence rules (multiplication before addition). The parenthesis is not required in the equivalent postfix expression: A B + C * Expression Stack A stack holds intermediate values during the evaluation of postfix expressions. Figure 1.1 shows the steps required to evaluate the postfix expression 5 6 * 4. The stack entries are labelled ST(0) and ST(1), with ST(0) indicating where the stack pointer would normally be pointing. Page 1 of 11

2 Figure 1.1: Evaluating the Postfix Expression 5 6 * 4. Table 1.1 contains some examples of translating infix to equivalent postfix expressions. Table 1.1 Infix to Postfix Examples Infix Postfix A + B A B + (A - B) / D A B - D / (A + B) * (C + D) A B + C D + * ((A + B) / C) * (E - F) AB + C / EF - * 1.2 FPU Data Registers The FPU has eight individually addressable 80-bit data registers named R0 through R7 (see Figure 2). Together, they are called a register stack. A three-bit field named TOP in the FPU status word identifies the register number that is currently the top of the stack. In Figure 1.2, for example, TOP equals binary 011, identifying R3 as the top of the stack. This stack location is also known as ST(0) (or simply ST) when writing floating-point instructions. The last register is ST(7). Figure 1.2: Floating-Point Data Register Stack. As we might expect, a push operation (also called load) decrements TOP by 1 and copies an operand into the register identified as ST(0). If TOP equals 0 before a push, TOP wraps around to register R7. A pop operation (also called store) copies the data at ST(0) into an operand, then adds 1 to TOP. If TOP equals 7 before the pop, it wraps around to register R0. Page 2 of 11

3 If loading a value into the stack would result in overwriting existing data in the register stack, a floating-point exception is generated. Figure 1.3 shows the same stack after 1.0 and 2.0 have been pushed (loaded) on the stack. Figure 1.3: FPU Stack after Pushing 1.0 and 2.0. Although it is interesting to understand how the FPU implements the stack using a limited set of registers, we need only focus on the ST(n) notation, where ST(0) is always the top of stack. From this point forward, we refer to stack registers as ST(0), ST(1), and so on. Instruction operands cannot refer directly to register numbers. Floating-point values in registers use the IEEE 10-byte extended real format (also known as temporary real). When the FPU stores the result of an arithmetic operation in memory, it translates the result into one of the following formats: integer, long integer, single precision (short real), double precision (long real), or packed binary-coded decimal (BCD). 1.3 Floating-Point Instruction Set The FPU instruction set is somewhat complex, so we will attempt here to give you an overview of its capabilities, along with specific examples that demonstrate code typically generated by compilers. In addition, we will see how you can exercise control over the FPU by changing its rounding mode. The instruction set contains the following basic categories of instructions: Data transfer Basic arithmetic Comparison Transcendental Load constants (specialized predefined constants only) x87 FPU control x87 FPU and SIMD state management Floating-point instruction names begin with the letter F to distinguish them from CPU instructions. The second letter of the instruction mnemonic (often B or I) indicates how a memory operand is to be interpreted: B indicates a BCD operand, and I indicates a binary integer operand. If neither is specified, the memory operand is assumed to be in real-number format. For example, FBLD operates on BCD numbers, FILD operates on integers, and FLD operates on real numbers. Page 3 of 11

4 1.3.1 Operands A floating-point instruction can have zero operands, one operand, or two operands. If there are two operands, one must be a floating-point register. There are no immediate operands, but certain predefined constants (such as 0.0, _ and log2 10) can be loaded into the stack. General-purpose registers such as EAX, EBX, ECX, and EDX cannot be operands. (The only exception is FSTSW, which stores the FPU status word in AX.) Memory-to-memory operations are not permitted. Integer operands must be loaded into the FPU from memory (never from CPU registers); they are automatically converted to floating-point format. Similarly, when storing floating-point values into integer memory operands, the values are automatically truncated or rounded into integers Initialization (FINIT) The FINIT instruction initializes the FPU. It sets the FPU control word to 037Fh, which masks (hides) all floating-point exceptions, sets rounding to nearest even, and sets the calculation precision to 64 bits. We recommend calling FINIT at the beginning of your programs, so you know the starting state of the processor Floating-Point Data Types Let s quickly review the floating-point data types supported by MASM (QWORD, TBYTE, REAL4, REAL8, and REAL10), listed in Table 1.2. You will need to use these types when defining memory operands for FPU instructions. For example, when loading a floating-point variable into the FPU stack, the variable is defined as REAL4, REAL8, or REAL10: bigval REAL E+864 fld bigval ; load variable into stack Table 1.2: Intrinsic Data Types. Type Usage QWORD 64-bit integer TBYTE 80-bit (10-byte) integer REAL4 32-bit (4-byte) IEEE short real REAL8 64-bit (8-byte) IEEE long real REAL10 80-bit (10-byte) IEEE extended real Reading and Writing Floating-Point Values In this experiment, the following two procedures for floating-point input-output (created by William Barrett of San Jose State University) are used: ReadFloat: Reads a floating-point value from the keyboard and pushes it on the floatingpoint stack. It accepts a wide variety of floating-point formats. Some examples are shown below: E E E E-4 3.5E5 WriteFloat: Writes the floating-point value at ST(0) to the console window in exponential format. ShowFPUStack: Another useful procedure, written by James Brink of Pacific Lutheran University, displays the FPU stack. It is called with no parameters: call ShowFPUStack Page 4 of 11

5 Example 1.1 The following example program pushes two floating-point values on the FPU stack, displays it, inputs two values from the user, multiplies them, and displays their product: TITLE Example 1.1 (ex11.asm) INCLUDE Irvine32.inc INCLUDE macros.inc first REAL second REAL third REAL8? main PROC finit ; initialize FPU ; Push two floats and display the FPU stack. fld first fld second call ShowFPUStack ; Input two floats and display their product. mwrite "Please enter a real number: " call ReadFloat mwrite "Please enter a real number: " call ReadFloat fmul ST(0),ST(1) ; multiply mwrite "Their product is: " call WriteFloat call Crlf exit main ENDP END main Note: Please refer to Appendix A on how to build and run this program. Sample input/output (user input shown in bold type): FPU Stack ST(0): E+001 ST(1): E+002 Please enter a real number: 3.5 Please enter a real number: 4.2 Their product is: E+001 Example 1.2 Let s code the expression vald = -vala + (valb * valc). A possible step-by-step solution is: Load vala on the stack and negate it. Load valb into ST(0), moving vala down to ST(1). Multiply ST(0) by valc, leaving the product in ST(0). Add ST(1) and ST(0) and store the sum in vald: TITLE Example 1.2 (ex12.asm) INCLUDE Irvine32.inc INCLUDE macros.inc vala REAL8 1.5 valb REAL8 2.5 valc REAL8 3.0 vald REAL8? ; +6.0 Page 5 of 11

6 main PROC finit fld vala ; ST(0) = vala fchs ; change sign of ST(0) fld valb ; load valb into ST(0) fmul valc ; ST(0) *= valc fadd ; ST(0) += ST(1) fstp vald ; store ST(0) to vald exit main ENDP END main Please refer to Appendix B on how to debug this program. Exercise 1 Write a program that prompts the user for the radius of a circle. Calculate and display the circle s circumference / area. Use the ReadFloat and WriteFloat procedures. Use the FLDPI instruction to load onto the register stack. Please refer to Appendix A on how to create, build and run your program. 2. Win32 Console Programming On the surface, 32-bit console mode programs look and behave like 16-bit MS-DOS programs running in text mode. There are differences, however: The former runs in 32-bit protected mode, whereas MS-DOS programs run in real-address mode. They use different function libraries. Win32 programs call functions from the same library used by graphical Windows applications. MS-DOS programs use BIOS and MS-DOS interrupts that have existed since the introduction of the IBM-PC. 2.1 Application Programming Interface An Application Programming Interface (API) is a collection of types, constants, and functions that provide a way to directly manipulate objects through programming. Therefore, the Win32 API lets you tap into the functions in the 32-bit version of MS-Windows. The Irvine32 link library used in this experiment is completely built on Win32 console functions. It is compatible with Win32 API functions and can be used for basic input output, simulations, timing, and other useful operations. Table 2.1 gives a complete list of procedures in the Irvine32 link library. Table 2.1: Procedures in the Irvine32 link library Procedure Description CloseFile Closes a disk file that was previously opened. Clrscr Clears the console window and locates the cursor at the upper left corner. CreateOutputFile Creates a new disk file for writing in output mode. Crlf Writes an end-of-line sequence to the console window. Delay Pauses the program execution for a specified n -millisecond interval. DumpMem Writes a block of memory to the console window in hexadecimal. DumpRegs Displays the EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EFLAGS, and EIP registers in hexadecimal. Also displays the most common CPU status flags. GetCommandTail Copies the program s command-line arguments (called the command tail) into an array of bytes. GetDateTime Gets the current date and time from the system. GetMaxXY Gets the number of columns and rows in the console window s buffer. GetMseconds Returns the number of milliseconds elapsed since midnight. GetTextColor Returns the active foreground and background text colors in the console Page 6 of 11

7 Gotoxy IsDigit MsgBox MsgBoxAsk OpenInputFile ParseDecimal32 ParseInteger32 Random32 Randomize RandomRange ReadChar ReadDec ReadFromFile ReadHex ReadInt ReadKey ReadString SetTextColor Str_compare Str_copy Str_length Str_trim Str_ucase WaitMsg WriteBin WriteBinB WriteChar WriteDec WriteHex WriteHexB WriteInt WriteStackFrame WriteStackFrameName WriteString WriteToFile WriteWindowsMsg window. Locates the cursor at a specific row and column in the console window. Sets the Zero flag if the AL register contains the ASCII code for a decimal digit (0 9). Displays a popup message box. Display a yes/no question in a popup message box. Opens an existing disk file for input. Converts an unsigned decimal integer string to 32-bit binary. Converts a signed decimal integer string to 32-bit binary. Generates a 32-bit pseudorandom integer in the range 0 to FFFFFFFFh. Seeds the random number generator with a unique value. Generates a pseudorandom integer within a specified range. Waits for a single character to be typed at the keyboard and returns the character. Reads an unsigned 32-bit decimal integer from the keyboard, terminated by the Enter key. Reads an input disk file into a buffer. Reads a 32-bit hexadecimal integer from the keyboard, terminated by the Enter key. Reads a 32-bit signed decimal integer from the keyboard, terminated by the Enter key. Reads a character from the keyboard s input buffer without waiting for input. Reads a string from the keyboard, terminated by the Enter key. Sets the foreground and background colors of all subsequent text output to the console. Compares two strings. Copies a source string to a destination string. Returns the length of a string in EAX. Removes unwanted characters from a string. Converts a string to uppercase letters. Displays a message and waits for a key to be pressed. Writes an unsigned 32-bit integer to the console window in ASCII binary format. Writes a binary integer to the console window in byte, word, or doubleword format. Writes a single character to the console window. Writes an unsigned 32-bit integer to the console window in decimal format. Writes a 32-bit integer to the console window in hexadecimal format. Writes a byte, word, or doubleword integer to the console window in hexadecimal format Writes a signed 32-bit integer to the console window in decimal format. Writes the current procedure s stack frame to the console. Writes the current procedure s name and stack frame to the console. Writes a null-terminated string to the console window. Writes a buffer to an output file. Displays a string containing the most recent error generated by MS- Windows. Some of the procedures that are used in this experiment are described in the following sections. Page 7 of 11

8 2.1.1 MsgBox The MsgBox procedure displays a graphical popup message box with an optional caption. (This works when the program is running in a console window.) Pass it the offset of a string in EDX, which will appear in the inside the box. Optionally, pass the offset of a string for the box s title in EBX. To leave the title blank, set EBX to zero. Sample call: caption db "Dialog Title", 0 HelloMsg mov ebx,offset caption mov edx,offset HelloMsg call MsgBox Sample output: BYTE "This is a pop-up message box.", 0dh,0ah BYTE "Click OK to continue...", MsgBoxAsk The MsgBoxAsk procedure displays a graphical popup message box with Yes and No buttons. (This works when the program is running in a console window.) Pass it the offset of a question string in EDX, which will appear in the inside the box. Optionally, pass the offset of a string for the box s title in EBX. To leave the title blank, set EBX to zero. MsgBoxAsk returns an integer in EAX that tells you which button was selected by the user. The value will be one of two predefined Windows constants: IDYES (equal to 6) or IDNO (equal to 7). Sample call: caption BYTE "Survey Completed",0 question BYTE "Thank you for completing the survey." BYTE 0dh,0ah BYTE "Would you like to receive the results?",0 mov ebx,offset caption mov edx,offset question call MsgBoxAsk ;(check return value in EAX) Sample output: Page 8 of 11

9 2.1.3 ReadString The ReadString procedure reads a string from the keyboard, stopping when the user presses the Enter key. Pass the offset of a buffer in EDX and set ECX to the maximum number of characters the user can enter, plus 1 (to save space for the terminating null byte). The procedure returns the count of the number of characters typed by the user in EAX. Sample call: buffer BYTE 21 DUP(0) ; input buffer bytecount DWORD? ; holds counter mov edx,offset buffer ; point to the buffer mov ecx,sizeof buffer ; specify max characters call ReadString ; input the string mov bytecount,eax ; number of characters ReadString automatically inserts a null terminator in memory at the end of the string. The following is a hexadecimal and ASCII dump of the first 8 bytes of buffer after the user has entered the string ABCDEFG : ABCDEFG The variable bytecount equals WriteString The WriteString procedure writes a null-terminated string to the console window. Pass the string s offset in EDX. Sample call: prompt BYTE "Enter your name: ",0 mov edx,offset prompt call WriteString WriteDec The WriteDec procedure writes a 32-bit unsigned integer to the console window in decimal format with no leading zeros. Pass the integer in EAX. Sample call: mov eax,295 call WriteDec ; displays: "295" WriteToFile The WriteToFile procedure writes the contents of a buffer to an output file. Pass it a valid file handle in EAX, the offset of the buffer in EDX, and the number of bytes to write in ECX. When the procedure returns, if EAX is greater than zero, it contains a count of the number of bytes written; otherwise, an error occurred. The following code calls WriteToFile: BUFFER_SIZE = 5000 filehandle DWORD? buffer BYTE BUFFER_SIZE DUP(?) mov eax,filehandle mov edx,offset buffer mov ecx,buffer_size call WriteToFile Page 9 of 11

10 The following pseudocode describes how to handle the value returned in EAX after calling WriteToFile: if EAX = 0 then error occurred when writing to file call WriteWindowsMessage to see the error else EAX = number of bytes written to the file endif Example 2 The following program creates a file in output mode, asks the user to enter some text, writes the text to the output file, reports the number of bytes written, and closes the file. It checks for errors after attempting to create the file: TITLE Creating a File (CreateFile.asm) INCLUDE Irvine32.inc BUFFER_SIZE = 501 buffer BYTE BUFFER_SIZE DUP(?) filename BYTE "output.txt",0 filehandle HANDLE? stringlength DWORD? byteswritten DWORD? str1 BYTE "Cannot create file",0dh,0ah,0 str2 BYTE "Bytes written to file [output.txt]:",0 str3 BYTE "Enter up to 500 characters and press" BYTE "[Enter]: ",0dh,0ah,0 main PROC ; Create a new text file. mov edx,offset filename call CreateOutputFile mov filehandle,eax ; Check for errors. cmp eax, INVALID_HANDLE_VALUE ; error found? jne file_ok ; no: skip mov edx,offset str1 ; display error call WriteString jmp quit ; Ask the user to input a string. file_ok: mov edx,offset str3 ; "Enter up to..." call WriteString mov ecx,buffer_size ; Input a string mov edx,offset buffer call ReadString mov stringlength,eax ; counts chars entered ; Write the buffer to the output file. mov eax,filehandle mov edx,offset buffer Page 10 of 11

11 mov ecx,stringlength call WriteToFile mov byteswritten,eax ; save return value call CloseFile ; Display the return value. mov edx,offset str2 ; "Bytes written" call WriteString mov eax,byteswritten call WriteDec call Crlf quit: exit main ENDP END main Note: Please refer to Appendix A on how to create, build and run this program Exercise 2 Modify the program in Example 2 so that it will display a graphical popup message box to ask the user whether the text file should be created. If the user selects Yes, the text file is created and the program terminates. Otherwise, the program will terminate directly. References 1. Kip R. Irvine, Assembly Language for x86 Processors, 6 th Edition, Prentice-Hall Inc., U.S.A., Kip R. Irvine, Assembly Language for x86 Processors, 6 th Edition [Online]. Available: Important Note: Lab assessment will be carried out during the lab session. It is the student's responsibility to complete the given tasks and report to the lab instructors for assessment. (END) Page 11 of 11

AM2: Protected-Mode Programming

AM2: 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 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

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

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

Assembly Language. Lecture 5 Procedures

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

Assembly Language. Lecture 5 Procedures

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

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures

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

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

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

Libraries and Procedures

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

Libraries and Procedures

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

COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

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

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

Build a program in Release mode and an executable file project.exe is created in Release folder. Run it.

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

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

Islamic 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 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 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 19: Procedures Procedure s parameters Slides prepared by Kip R Irvine Revision date: 08/22/2002 Modified

More information

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

Marking 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: 08/06/2014 Section 1 Weighting 40% of

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

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

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

COMPUTER ENGINEERING DEPARTMENT

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

Assembly Language for Intel-Based Computers, 5 th Edition. Chapter 9: Strings and Arrays

Assembly Language for Intel-Based Computers, 5 th Edition. Chapter 9: Strings and Arrays Assembly Language for Intel-Based Computers, 5 th Edition Kip R. Irvine Chapter 9: Strings and Arrays Slide show prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2006-2007. All

More information

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

Chapter 3: Assembly Language Fundamentals. Cristina G. Rivera

Chapter 3: Assembly Language Fundamentals. Cristina G. Rivera Chapter 3: Assembly Language Fundamentals Cristina G. Rivera Basic Elements of Assembly Language Example: Adding and Subtracting Integers Assembling, Linking, and Running Programs Defining Data Symbolic

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

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 3: Assembly Language Fundamentals (c) Pearson Education, 2002. Chapter Overview Basic Elements of Assembly Language Example:

More information

Assembly Language for Intel-Based Computers, 5 th Edition. Kip Irvine. Chapter 3: Assembly Language Fundamentals

Assembly Language for Intel-Based Computers, 5 th Edition. Kip Irvine. Chapter 3: Assembly Language Fundamentals Assembly Language for Intel-Based Computers, 5 th Edition Kip Irvine Chapter 3: Assembly Language Fundamentals Chapter Overview Basic Elements of Assembly Language Example: Adding and Subtracting Integers

More information

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86 Lecture 15 Intel Manual, Vol. 1, Chapter 3 Hampden-Sydney College Fri, Mar 6, 2009 Outline 1 2 Overview See the reference IA-32 Intel Software Developer s Manual Volume 1: Basic, Chapter 3. Instructions

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

Assembly Language for Intel-Based Computers, 5 th Edition. Chapter 3: Assembly Language Fundamentals

Assembly Language for Intel-Based Computers, 5 th Edition. Chapter 3: Assembly Language Fundamentals Assembly Language for Intel-Based Computers, 5 th Edition Kip Irvine Chapter 3: Assembly Language Fundamentals Slides prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2006-2007.

More information

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top Microprocessors (0630371) Fall 2010/2011 Lecture Notes # 15 Stack Operations Objectives of the Lecture Runtime Stack PUSH Operation POP Operation Initializing the Stack PUSH and POP Instructions Stack

More information

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals.

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals. Assembly Language for Intel-Based Computers, 4 th Edition Chapter 3: Assembly Language Fundamentals Slides prepared by Kip R. Irvine Revision date: 09/15/2002 Kip R. Irvine Chapter Overview Basic Elements

More information

The x86 Architecture

The x86 Architecture The x86 Architecture Lecture 24 Intel Manual, Vol. 1, Chapter 3 Robb T. Koether Hampden-Sydney College Fri, Mar 20, 2015 Robb T. Koether (Hampden-Sydney College) The x86 Architecture Fri, Mar 20, 2015

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

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

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

Assembly Language for Intel-Based Computers, 5 th Edition

Assembly Language for Intel-Based Computers, 5 th Edition Assembly Language for Intel-Based Computers, 5 th Edition Kip Irvine Chapter 3: Assembly Language Fundamentals Slides prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2006-2007.

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

Assembly Fundamentals

Assembly Fundamentals Chapter Overview Assembly Fundamentals Basic Elements of Assembly Language Example: Adding and Subtracting Integers Assembling, Linking, and Running Programs Defining Data Symbolic Constants Computer Organization

More information

Computer Architecture and Assembly Language. Practical Session 5

Computer Architecture and Assembly Language. Practical Session 5 Computer Architecture and Assembly Language Practical Session 5 Addressing Mode - "memory address calculation mode" An addressing mode specifies how to calculate the effective memory address of an operand.

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

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

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

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

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

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

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

Assembly Language for Intel-Based Computers, 4 th Edition. Lecture 25: Interface With High-Level Language

Assembly Language for Intel-Based Computers, 4 th Edition. Lecture 25: Interface With High-Level Language Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Lecture 25: Interface With High-Level Language Slide show prepared by Kip R. Irvine, Revision date: 07/07/2002 Modified on April

More information

Computer Science Final Examination Wednesday December 13 th 2006

Computer Science Final Examination Wednesday December 13 th 2006 Computer Science 03-60-266 Final Examination Wednesday December 13 th 2006 Dr. Alioune Ngom Last Name: First Name: Student Number: INSTRUCTIONS EXAM DURATION IS 3 hours. OPEN NOTES EXAM: lecture notes,

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

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

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

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

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Marking Scheme. Examination Paper. Module: Microprocessors (630313) Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam First Semester Date: 30/01/2018 Section 1 Weighting 40% of the

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

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź Low Level Programming Lecture 2 Intel processors' architecture reminder Fig. 1. IA32 Registers IA general purpose registers EAX- accumulator, usually used to store results of integer arithmetical or binary

More information

Memory Models. Registers

Memory Models. Registers Memory Models Most machines have a single linear address space at the ISA level, extending from address 0 up to some maximum, often 2 32 1 bytes or 2 64 1 bytes. Some machines have separate address spaces

More information

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

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

Inline Assembler. Willi-Hans Steeb and Yorick Hardy. International School for Scientific Computing

Inline Assembler. Willi-Hans Steeb and Yorick Hardy. International School for Scientific Computing Inline Assembler Willi-Hans Steeb and Yorick Hardy International School for Scientific Computing e-mail: steebwilli@gmail.com Abstract We provide a collection of inline assembler programs. 1 Using the

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

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

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam Assembly Language Lecture 2 - x86 Processor Architecture Ahmed Sallam Introduction to the course Outcomes of Lecture 1 Always check the course website Don t forget the deadline rule!! Motivations for studying

More information

Assembly Language Fundamentals

Assembly Language Fundamentals Computer Organization & Assembly Languages Assembly Language Fundamentals Pu-Jen Cheng Adapted from the slides prepared by Kip Irvine for the book, Assembly Language for Intel-Based Computers, 5th Ed.

More information

Hardware and Software Architecture. Chapter 2

Hardware and Software Architecture. Chapter 2 Hardware and Software Architecture Chapter 2 1 Basic Components The x86 processor communicates with main memory and I/O devices via buses Data bus for transferring data Address bus for the address of a

More information

Stack -- Memory which holds register contents. Will keep the EIP of the next address after the call

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

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

Figure 8-1. x87 FPU Execution Environment

Figure 8-1. x87 FPU Execution Environment Sign 79 78 64 63 R7 Exponent R6 R5 R4 R3 R2 R1 R0 Data Registers Significand 0 15 Control Register 0 47 Last Instruction Pointer 0 Status Register Last Data (Operand) Pointer Tag Register 10 Opcode 0 Figure

More information

Constants and Expressions. Lecture 7: Assembly Language Programs. Constants and Expressions (cont.) Statements. Names. Assembly Directives

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

COMPUTER ENGINEERING DEPARTMENT

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

CSC 8400: Computer Systems. Machine-Level Representation of Programs

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

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Slides prepared by Kip R. Irvine Revision date: 09/25/2002

More information

Lab 3. The Art of Assembly Language (II)

Lab 3. The Art of Assembly Language (II) Lab. The Art of Assembly Language (II) Dan Bruce, David Clark and Héctor D. Menéndez Department of Computer Science University College London October 2, 2017 License Creative Commons Share Alike Modified

More information

Summary: Direct Code Generation

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

Assembly Language. Lecture 2 x86 Processor Architecture

Assembly Language. Lecture 2 x86 Processor Architecture Assembly Language Lecture 2 x86 Processor Architecture Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Introduction to the course Outcomes of Lecture 1 Always check the course

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

Language of x86 processor family

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

Program Exploitation Intro

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

SOEN228, Winter Revision 1.2 Date: October 25,

SOEN228, 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 information

Digital Forensics Lecture 3 - Reverse Engineering

Digital Forensics Lecture 3 - Reverse Engineering Digital Forensics Lecture 3 - Reverse Engineering Low-Level Software Akbar S. Namin Texas Tech University Spring 2017 Reverse Engineering High-Level Software Low-level aspects of software are often the

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

Assembly Language for Intel-Based Computers, 4 th Edition. Kip R. Irvine. Chapter 2: IA-32 Processor Architecture

Assembly Language for Intel-Based Computers, 4 th Edition. Kip R. Irvine. Chapter 2: IA-32 Processor Architecture Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Chapter Overview General Concepts IA-32 Processor Architecture IA-32 Memory Management Components

More information

We will first study the basic instructions for doing multiplications and divisions

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

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

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

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

Introduction to Assembly Language

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

Constants and. Lecture 7: Assembly Language Programs. Expressions (cont.) Constants and. Statements. Expressions

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

Low-Level Essentials for Understanding Security Problems Aurélien Francillon

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

UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET

UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET Katedra za elektroniku Računarska elektronika Grupa br. 11 Projekat br. 8 Studenti: Stefan Vukašinović 466/2013 Jelena Urošević 99/2013 Tekst projekta :

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

History of the Intel 80x86

History of the Intel 80x86 Intel s IA-32 Architecture Cptr280 Dr Curtis Nelson History of the Intel 80x86 1971 - Intel invents the microprocessor, the 4004 1975-8080 introduced 8-bit microprocessor 1978-8086 introduced 16 bit microprocessor

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

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

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