We will first study the basic instructions for doing multiplications and divisions
|
|
- Amberlynn Jackson
- 6 years ago
- Views:
Transcription
1 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 into binary number that this string represents 2. Convert a binary number (stored in some register) its a string of ASCII digits that represents its numerical value We will also use the XLAT instruction to perform character encoding
2 Integer Multiplication Multiplication depends on the interpretation 1. No interpretation: FFh 2h =?? 2. Signed interpretation: -1 2 = Unsigned interpretation: = 510 We have two different multiplication instructions MUL Source ;for unsigned multiplication IMUL Source ;for signed multiplication Where Source must be either Mem or Reg 1. Source is being multiplied by AL AX if Source is of type BYTE if Source is of type WORD EAX if Source is of type DWORD 2. The result of MUL/IMUL is stored in AX DX:AX if Source is of type BYTE if Source is of type WORD EDX:EAX if Source is of type DWORD
3 Integer Multiplication (Continued) AL = 80h and BL = FFh MUL BL F 80 1 IMUL BL Instruction Result DX AX CF/OF There is always enough storage to hold the result of MUL/IMUL. Nevertheless, CF = OF = 1 iff the result cannot be contained within the least significant half (LSH) of its storage location 1. LSH = AL if Source is of type BYTE 2. LSH = AX if Source is of type WORD 3. LSH = EAX if Source is of type DWORD CF = OF = 0 iff 1. The most significant half (MSH) is 0, for MUL 2. MSH is the sign extension of the LSH, for IMUL AX = 1h and BX = FFFFh MUL BX FFFF 0 IMUL BX -1 FFFF FFFF 0 AX = FFFFh and BX = FFFFh MUL BX FFFE IMUL BX AL = 30h and BL = 4h MUL BL C0 0 IMUL BL C0 1
4 Two-Operand Form for IMUL IMUL Destination, Source multiplies Source by Destination Source can be Imm, Mem or Reg, and Destination must be Reg16 or Reg32 The product is stored (only) into Destination. other registers are changed No MOV EAX, 1 ;EAX = h IMUL AX, -1 ;EAX = 0000FFFFh, CF = OF = 0 MOV EAX, 100h ;EAX = 2 8 IMUL AX, 100h ;EAX = h, CF = OF = 1 MOV EAX, 100h IMUL EAX, 100h ;EAX = h, CF = OF = 0 Exercise #1 Give the hexadecimal content of AX and the values of CF and OF immediately after the execution of each instruction below 1. IMUL AH when AX = 0FE02h 2. MUL BH when AL = 8Eh and BH = 10h 3. IMUL BH when AL = 9Dh and BH = 10h 4. IMUL AX, 0FFh when AX = 0FFh
5 Integer Division Notation for integer division 1. Ex: 7 2 = (3, 1) 2. Dividend Divisor = (Quotient, Remainder) We have two different division instructions Div Divisor ;for unsigned division IDIV Division ;for signed division Where Divisor must be either Mem or Reg Convention for IDIV: the remainder has always the same sign as the dividend. Ex: 5 2 = ( 2, 1) ;not ( 3, 1) The divisor determines what will hold the dividend, the quotient and the remainder Divisor Dividend Quotient Remainder BYTE WORD DWORD AX DX:AX EDX:EAX AL AX EAX AH DX EDX The effects on flags is undefined
6 Integer Division (Continued) We have a divide overflow whenever the quotient cannot be contained in its destination (AL if divisor is BYTE... ) Execution then traps into the OS which displays a message on screen and terminates the program DX = 0000h, AX = 0005h, BX = FFFEh DIV BX IDIV BX -2 1 FFFE 0001 DX = FFFFh, AX = FFFBh, BX = 0002h DIV BX -2-1 FFFE FFFF IDIV BX Divide Overflow AX = 0007h and BX = FFFEh DIV BL IDIV BL -3 1 FD 01 AX = 00FBh and BX = 0CFFh DIV BL FB IDIV BL Divide Overflow Instruction Quotient Remainder AX DX Exercise #2 Give the hexadecimal content of AX immediately after the execution of each instruction below or indicate if there is a divide overflow 1. IDIV BL when AX = 0FFFBh and BL = 0FEh 2. IDIV BL when AX = 0080h and BL = 0FFh 3. DIV BL when AX = 7FFFh and BL = 08h
7 Preparing for a Division Recall that for a 1. BYTE divisor: the dividend is in AX 2. WORD divisor: the dividend is in DX:AX 3. DWORD divisor: the dividend is in EDX:EAX If the dividend occupies only its LSH we must prepare its MSH for a division 1. For DIV: MSH must be 0 2. For IDIV: MSH must be the sign extension of the LSH Preparing for IDIV To fill the MSH of the dividend with the sign of its LSF, use 1. CBW (Convert Byte to Word) fills AH with the sign of AL 2. CWD (Convert Word to Double-Word fills DX with the sign of AX 3. CDQ (Convert Double-Word to Quad-Word) fills EDX with the sign of EAX
8 Preparing for DIV or IDIV Sign extension (recall): 1. If AX = 8AC0h then CWD sets DX to FFFFh 2. If AX = 7F12h then CWD sets DX to 0000h To divide the unsigned number in AX by the unsigned number in BX, you must do XOR DX, DX ;to fill DX with 0 DIV BX To divide the signed number in AX by the signed number in BX, you must do CWD IDIV BX ;to fill DX with sign extension of AX Never assign the MSH of the dividend to zero before performing IDIV
9 The XLAT Instruction XLAT (no operand) basic tool for character translation Upon execution of XLAT, the byte pointed by EBX + AL is moved to AL.data Table DB ABCDEF.code MOV EBX, OFFSET Table MOV AL, 0Ah XLAT ;AL = A = 41h ;converts from binary to ASCII ;code of hexadecimal digit Character Encoding This is a table to encode numerical and alphabetical characters.data CodeTable DB ABCDEF DB 48 DUP(0) ;no translation DB ;ASCII codes DB 7 DUP(0) ;no translation DB GVHZUSOBMIKPJCADLFTYEQNWXR DB 6 DUP(0) ;no translation DB gvhzusobmikpjcadlftyeqnwxr DB 133 DUP(0) ;no translation
10 Character Encoding This is a code snippet to encode (only) numerical and alphabetical characters.data CodeTable DB ABCDEF DB 48 DUP(0) ;no translation DB ;ASCII codes DB 7 DUP(0) ;no translation DB GVHZUSOBMIKPJCADLFTYEQNWXR DB 6 DUP(0) ;no translation DB gvhzusobmikpjcadlftyeqnwxr DB 133 DUP(0) ;no translation.code MOV EBX, OFFSET CodeTable next char: GETCH ;character in AL MOV EDX, EAX ;save original in DL XLAT ;translates character in AL CMP AL, 0 ;not translatable? JE put char ;then write original MOV EDX, EAX ;else write translation put char: PUTCH EDX ;write DL to output JMP next char
11 Binary to ASCII Conversion We want to convert a binary number into the string of ASCII digits that represents its unsigned value (for display) Ex: if AX = 4096, to generate the string 4096 we divide by 10 until the quotient is 0 Dividend 10 = Quotient Remainder = = = = 0 4 The same method can be used to obtain the ASCII string of digits with respect to any base Ex: if AX = 10C4 = 4292, to generate the string 10C4 we divide by 16 until the quotient is 0 Dividend 16 = Quotient Remainder = = c = = 0 1 1
12 Binary to ASCII Conversion (Continued) The Wuint procedure displays the ASCII string of the unsigned value in EAX EBX contains a radix value (2 to 16) that determines the base of the displayed number The Wsint procedure displays the ASCII string of the signed value in EAX 1. Check the sign-bit. If the value is negative, perform two s complement (with NEG instruction) and display - 2. Then use the same algorithm to display the digits of the (now) positive number
13 Procedure Wuint Wuint PROC ;Writes a 32-bit unsigned binary ;integer to standard output ;Input parameters: EAX = value, EBX = radix ;stores each digit in the stack PUSHA CMP EBX, 2 JAE wu cont1 PUTSTR Rad err JMP wu exit wu cont1: CMP EBX, 16 JBE wu cont2 PUTSTR Rad err JMP wu exit wu cont2: MOV ESI, EBX ;save radix into ESI MOV EBX, OFFSET XTable ;translate table XOR ECX, ECX ;clear digit count L3: XOR EDX, EDX ;clear upper half of dividend DIV ESI ;divide EDX:EAX by the radix XCHG EAX, EDX ;now: EAX=remainder and EDX=quotient XLAT ;look up ASCII digit PUSH EAX ;store digit in stack XCHG EAX, EDX ;swap quotient into EAX INC ECX ;increment digit count OR EAX, EAX ;quotient = 0? JNZ L3 ;no! divide again L4: ;Display digit in stack starting with last entered POP EDX ;DL = character to be displayed PUTCH EDX ;display char in DL LOOP L4 wu exit: POPA RET XTable DB ABCDEF ;translate table Rad err DB "Error: radix must be between 2 and 16",0 Wuint ENDP
14 Procedure Wsint Wsint PROC ;Writes a 32-bit signed binary ;integer to standard output ;Input parameters: EAX = value, EBX = radix ;stores each digit in the stack PUSHA CMP EBX, 2 JAE ws cont1 PUTSTR Rad err JMP ws exit ws cont1: CMP EBX, 16 JBE ws cont2 PUTSTR Rad err JMP ws exit ws cont2: MOV ESI, EBX ;save radix into ESI MOV EBX, OFFSET XTable ;translate table XOR ECX, ECX ;clear digit count TEST EAX, h ;is the signed value ;in AX negative? JZ L3 ;no! so display positive value PUTCH - NEG EAX ;perform two s complement L3: XOR EDX, EDX ;clear upper half of dividend DIV ESI ;divide EDX:EAX by the radix XCHG EAX, EDX ;now: EAX=remainder and EDX=quotient XLAT ;look up ASCII digit PUSH EAX ;store digit in stack XCHG EAX, EDX ;swap quotient into EAX INC ECX ;increment digit count OR EAX, EAX ;quotient = 0? JNZ L3 ;no! divide again L4: ;Display digit in stack starting with last entered POP EDX ;DL = character to be displayed PUTCH EDX ;display char in DL LOOP L4 ws exit: POPA RET XTable DB ABCDEF ;translate table Rad err DB "Error: radix must be between 2 and 16",0 Wsint ENDP
15 ASCII to Binary Conversion To convert a sequence of ASCII digits into its numerical value: From left to right: for each digit, we multiply the previous product by the base and add the digit to the current product. Previous product is set to 0, initially Ex: to convert 4096 into its base-10 value Previous 10 + Digit = Current = = = = 4096 Final value The same method can be used to obtain the ASCII string of digits with respect to any base Be careful when doing addition and multiplication in a base other than 10. Review you notes
16 ASCII to Binary Conversion (Continued) The Rint procedure reads a string of ASCII decimal digits and stores the base 10 numerical value into EAX 1. For signed numbers: the sequence of digits can be preceded by a sign 2. Checks for overflows at each multiplication and addition The program below uses both Rint and Wsint.386.model Flat include Cs266.inc.data Msg1 DB "Enter an integer: ", 0 Msg2 DB "EAX = ", 0.code main: PUTSTR Msg1 CALL Rint PUTSTR Msg2 MOV EBX 10 CALL Wsint RET ;from main include Wsint.asm include Rint.asm End
17 Procedure Rint Rint PROC ;Reads a signed integer from standard input ;The first sequence of decimal ;digits determines the number ;all other entries are ignored ;Input: none (only keyboard input) ;Output: EAX contains the number PUSH EBX PUSH ECX PUSH EDX PUSH ESI PUSH EDI MOV EDI, 1 ;assume that the number is positive M1: GETCH ;char in AL CMP AL, + JE M1 ;read next char CMP AL, - JNE M2 MOV EDI, -1 ;the number is negative JMP M1 ;read next char M2: CALL IsDecDigit ;ZF=1 iff AL contains a dec-digit JNE M1 ;read a char until a digit is found ;a Dec digit as been entered ;perform signed multiplication ;of positive numbers ;until a non-dec-digit is entered MOV EBX, 10 ;EBX is the multiplier AND EAX, 0Fh ;convert to numerical value ;EAX holds the product ;initially EAX = first number entered M3: PUSH EAX ;save product on stack GETCH CALL IsDecDigit JZ M4 POP EAX JMP done ;we are done
18 Procedure Rint (Continued) M4: MOV ECX, EAX ;save digit in CL AND ECX, 0Fh ;convert to numerical value POP EAX ;recover the product IMUL EBX ;EDX:EAX = EAX 10 JO A6 ;exit if overflow ADD EAX, ECX ;add to product JO A6 ;exit if overflow JMP M3 done: IMUL EDI ;EDX:EAX = EAX * sign ;no possibility of overflow here JMP exit A6: PUTSTR Overflow msg exit: POP EDI POP ESI POP EDX POP ECX POP EBX RET Overflow msg DB integer overflow,10,0 Rint ENDP IsDecDigit PROC ;sets ZF = 1 iff the character ;in AL is a decimal digit. CMP AL, 0 JB B1 CMP AL, 9 JA B1 TEST AX, 0 ;set ZF=1 B1: RET IsDecDigit ENDP
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 informationECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic
ECOM 2325 Computer Organization and Assembly Language Computer Engineering Department CHAPTER 7 Integer Arithmetic Presentation Outline Shift and Rotate Instructions Shift and Rotate Applications Multiplication
More informationInstructions moving data
do not affect flags. Instructions moving data mov register/mem, register/mem/number (move data) The difference between the value and the address of a variable mov al,sum; value 56h al mov ebx,offset Sum;
More informationEC 333 Microprocessor and Interfacing Techniques (3+1)
EC 333 Microprocessor and Interfacing Techniques (3+1) Lecture 6 8086/88 Microprocessor Programming (Arithmetic Instructions) Dr Hashim Ali Fall 2018 Department of Computer Science and Engineering HITEC
More informationINSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI
8 Unsigned and Signed Integer Numbers 1. Unsigned integer numbers: each type of integer can be either byte-wide or word-wide. This data type can be used to represent decimal numbers in the range 0 through
More informationIntroduction to 8086 Assembly
Introduction to 8086 Assembly Lecture 7 Multiplication and Division Multiplication commands: mul and imul mul source (source: register/memory) Unsigned Integer Multiplication (mul) mul src (src: register/memory)
More informationSigned number Arithmetic. Negative number is represented as
Signed number Arithmetic Signed and Unsigned Numbers An 8 bit number system can be used to create 256 combinations (from 0 to 255), and the first 128 combinations (0 to 127) represent positive numbers
More informationArithmetic Instructions
Segment 3C Arithmetic Instructions This topic covers the following instructions: Addition (ADD, INC, ADC) Subtraction (SUB, DEC, SBB,CMP) Multiplication (MUL, IMUL) Division (DIV, IDIV) BCD Arithmetic
More informationBasic Pentium Instructions. October 18
Basic Pentium Instructions October 18 CSC201 Section 002 Fall, 2000 The EFLAGS Register Bit 11 = Overflow Flag Bit 7 = Sign Flag Bit 6 = Zero Flag Bit 0 = Carry Flag "Sets the flags" means sets OF, ZF,
More informationBasic Assembly Instructions
Basic Assembly Instructions Ned Nedialkov McMaster University Canada SE 3F03 January 2013 Outline Multiplication Division FLAGS register Branch Instructions If statements Loop instructions 2/21 Multiplication
More informationCOMPUTER ENGINEERING DEPARTMENT
Page 1 of 14 COMPUTER ENGINEERING DEPARTMENT Jan. 7, 2010 COE 205 COMPUTER ORGANIZATION & ASSEMBLY PROGRAMMING Major Exam II First Semester (091) Time: 3:30 PM-6:00 PM Student Name : KEY Student ID. :
More informationWeek /8086 Microprocessor Programming I
Week 4 8088/8086 Microprocessor Programming I Example. The PC Typewriter Write an 80x86 program to input keystrokes from the PC s keyboard and display the characters on the system monitor. Pressing any
More informationInteger Arithmetic Part2
Islamic University Of Gaza Assembly Language Faculty of Engineering Discussion Computer Department Chapter 7 Eng. Ahmed M. Ayash Date: 21/04/2013 Chapter 7 Integer Arithmetic Part2 7.4: Multiplication
More informationEx: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.
INSTRUCTOR: ABDULMUTTALIB A H ALDOURI Conditional Jump Cond Unsigned Signed = JE : Jump Equal JE : Jump Equal ZF = 1 JZ : Jump Zero JZ : Jump Zero ZF = 1 JNZ : Jump Not Zero JNZ : Jump Not Zero ZF = 0
More informationLecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide
Lecture 9 INC and DEC Arithmetic Operations Overflow Multiply and Divide INC adds one to a single operand DEC decrements one from a single operand INC destination DEC destination where destination can
More informationMnem. Meaning Format Operation Flags affected ADD Addition ADD D,S (D) (S)+(D) (CF) Carry ADC Add with ADC D,C (D) (S)+(D)+(CF) O,S,Z,A,P,C
ARITHMETIC AND LOGICAL GROUPS 6-1 Arithmetic and logical groups: The arithmetic group includes instructions for the addition, subtraction, multiplication, and division operations. The state that results
More informationDefining and Using Simple Data Types
85 CHAPTER 4 Defining and Using Simple Data Types This chapter covers the concepts essential for working with simple data types in assembly-language programs The first section shows how to declare integer
More informationWeek /8086 Microprocessor Programming
Week 5 8088/8086 Microprocessor Programming Multiplication and Division Multiplication Multiplicant Operand Result (MUL or IMUL) (Multiplier) Byte * Byte AL Register or memory Word * Word AX Register or
More informationIntel 8086: Instruction Set
IUST-EE (Chapter 6) Intel 8086: Instruction Set 1 Outline Instruction Set Data Transfer Instructions Arithmetic Instructions Bit Manipulation Instructions String Instructions Unconditional Transfer Instruction
More informationMarking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 02/06/2018 Section 1 Weighting 40% of
More informationSPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY
BACKGROUND 8086 CPU has 8 general purpose registers listed below: AX - the accumulator register (divided into AH / AL): 1. Generates shortest machine code 2. Arithmetic, logic and data transfer 3. One
More information8086 INSTRUCTION SET
8086 INSTRUCTION SET Complete 8086 instruction set Quick reference: AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD CLI CMC CMP CMPSB CMPSW CWD DAA DAS DEC DIV HLT IDIV IMUL IN INC INT INTO I JA JAE JB JBE
More informationcomplement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]
The following pages contain references for use during the exam: tables containing the x86 instruction set (covered so far) and condition codes. You do not need to submit these pages when you finish your
More informationIBM PC Hardware CPU 8088, Pentium... ALU (Arithmetic and Logic Unit) Registers. CU (Control Unit) IP.
IBM PC Hardware CPU 8088, 8086 80286 80386 80486 Pentium... ALU (Arithmetic and Logic Unit) Registers CU (Control Unit) IP Memory ROM BIOS I/O RAM OS Programs Video memory BIOS data Interrupt Vectors Memory
More informationQ1: Multiple choice / 20 Q2: Data transfers and memory addressing
16.317: Microprocessor Systems Design I Fall 2014 Exam 1 October 1, 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 information3.1 DATA MOVEMENT INSTRUCTIONS 45
3.1.1 General-Purpose Data Movement s 45 3.1.2 Stack Manipulation... 46 3.1.3 Type Conversion... 48 3.2.1 Addition and Subtraction... 51 3.1 DATA MOVEMENT INSTRUCTIONS 45 MOV (Move) transfers a byte, word,
More informationConditional Processing
١ Conditional Processing Computer Organization & Assembly Language Programming Dr Adnan Gutub aagutub at uqu.edu.sa Presentation Outline [Adapted from slides of Dr. Kip Irvine: Assembly Language for Intel-Based
More informationX86 Addressing Modes Chapter 3" Review: Instructions to Recognize"
X86 Addressing Modes Chapter 3" Review: Instructions to Recognize" 1 Arithmetic Instructions (1)! Two Operand Instructions" ADD Dest, Src Dest = Dest + Src SUB Dest, Src Dest = Dest - Src MUL Dest, Src
More informationInteger Arithmetic. Pu-Jen Cheng. Adapted from the slides prepared by Kip Irvine for the book, Assembly Language for Intel-Based Computers, 5th Ed.
Computer Organization & Assembly Languages Integer Arithmetic Pu-Jen Cheng Adapted from the slides prepared by Kip Irvine for the book, Assembly Language for Intel-Based Computers, 5th Ed. Chapter Overview
More information8088/8086 Programming Integer Instructions and Computations
Unit3 reference 2 8088/8086 Programming Integer Instructions and Computations Introduction Up to this point we have studied the software architecture of the 8088 and 8086 microprocessors, their instruction
More information22 Assembly Language for Intel-Based Computers, 4th Edition. 3. Each edge is a transition from one state to another, caused by some input.
22 Assembly Language for Intel-Based Computers, 4th Edition 6.6 Application: Finite-State Machines 1. A directed graph (also known as a diagraph). 2. Each node is a state. 3. Each edge is a transition
More informationCOMPUTER ENGINEERING DEPARTMENT
Page 1 of 11 COMPUTER ENGINEERING DEPARTMENT December 31, 2007 COE 205 COMPUTER ORGANIZATION & ASSEMBLY PROGRAMMING Major Exam II First Semester (071) Time: 7:00 PM-9:30 PM Student Name : KEY Student ID.
More informationQ1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100
16.317: Microprocessor-Based Systems I Summer 2012 Exam 1 July 20, 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 informationChapter 7 Integer Arithmetic
Chapter 7 Integer Arithmetic 7.1 Introduction 193 7.2 Shift and Rotate Instructions 194 7.2.1 Logical Shifts and Arithmetic Shifts 194 7.2.2 SHL Instruction 195 7.2.3 SHR Instruction 196 7.2.4 SAL and
More informationAssembler lecture 4 S.Šimoňák, DCI FEEI TU of Košice
Assembler lecture 4 S.Šimoňák, DCI FEEI TU of Košice Addressing data access specification arrays - specification and manipulation impacts of addressing to performance Processor architecture CISC (more
More informationComputer 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 informationQ1: Multiple choice / 20 Q2: Protected mode memory accesses
16.317: Microprocessor-Based Systems I Summer 2012 Exam 2 August 1, 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 informationAPPENDIX C INSTRUCTION SET DESCRIPTIONS
APPENDIX C INSTRUCTION SET DESCRIPTIONS This appendix provides reference information for the 80C186 Modular Core family instruction set. Tables C-1 through C-3 define the variables used in Table C-4, which
More information16.317: Microprocessor Systems Design I Spring 2014
16.317: Microprocessor Systems Design I Spring 2014 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by
More informationdb "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'
PA4 Sample Solution.model large.stack 100h.data msg1 db "This programs scans a string of up to 256 bytes and counts the repetitions of the number 4206 and sums them.",0dh,0ah,'$' msg2 db "Please enter
More informationInteger Arithmetic. Computer Organization and Assembly Languages Yung-Yu Chuang 2005/11/17. with slides by Kip Irvine
Integer Arithmetic Computer Organization and Assembly Languages Yung-Yu Chuang 2005/11/17 with slides by Kip Irvine Announcements Assignment #2 is due next week. Assignment #3 box filter is online now,
More informationELEC 242 Time Delay Procedure
There are many occasions where we wish to time events. If we are using a personal computer, we have a number of ways to do this. The 8088/8086 computer had a Programmable Interval Timer like the 8253/54
More informationComputer 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 informationBasic Assembly SYSC-3006
Basic Assembly Program Development Problem: convert ideas into executing program (binary image in memory) Program Development Process: tools to provide people-friendly way to do it. Tool chain: 1. Programming
More informationSPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY
BACKGROUND Segment The "SEGMENT" and "ENDS" directives indicate to the assembler the beginning and ending of a segment and have the following format label SEGMENT [options] ;place the statements belonging
More informationAdding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit
Part 5 Adding Binary Integers Arithmetic Logic Unit = Adding Binary Integers Adding Base Numbers Computer's add binary numbers the same way that we do with decimal Columns are aligned, added, and "'s"
More informationComputer Architecture and System Programming Laboratory. TA Session 3
Computer Architecture and System Programming Laboratory TA Session 3 Stack - LIFO word-size data structure STACK is temporary storage memory area register points on top of stack (by default, it is highest
More informationSOEN228, Winter Revision 1.2 Date: October 25,
SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003 1 Contents Flags Mnemonics Basic I/O Exercises Overview of sample programs 2 Flag Register The flag register stores the condition flags that retain
More informationCSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs
CSC 2400: Computer Systems Towards the Hardware: Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32)
More informationCSC 8400: Computer Systems. Machine-Level Representation of Programs
CSC 8400: Computer Systems Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32) 1 Compilation Stages
More informationChapter 3: Addressing Modes
Chapter 3: Addressing Modes Chapter 3 Addressing Modes Note: Adapted from (Author Slides) Instructor: Prof. Dr. Khalid A. Darabkh 2 Introduction Efficient software development for the microprocessor requires
More informationWe can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...
COMPUTER ARCHITECTURE II: MICROPROCESSOR PROGRAMMING We can study computer architectures by starting with the basic building blocks Transistors and logic gates To build more complex circuits Adders, decoders,
More informationBAHAR DÖNEMİ MİKROİŞLEMCİLER LAB4 FÖYÜ
LAB4 RELATED INSTRUCTIONS: Compare, division and jump instructions CMP REG, memory memory, REG REG, REG memory, immediate REG, immediate operand1 - operand2 Result is not stored anywhere, flags are set
More information16.317: Microprocessor Systems Design I Fall 2013
16.317: Microprocessor Systems Design I Fall 2013 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationAssembly Language: IA-32 Instructions
Assembly Language: IA-32 Instructions 1 Goals of this Lecture Help you learn how to: Manipulate data of various sizes Leverage more sophisticated addressing modes Use condition codes and jumps to change
More informationEECE.3170: Microprocessor Systems Design I Spring 2016
EECE.3170: Microprocessor Systems Design I Spring 2016 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response
More informationWeek /8086 Microprocessor Programming II
Week 5 8088/8086 Microprocessor Programming II Quick Review Shift & Rotate C Target register or memory SHL/SAL 0 C SHR 0 SAR C Sign Bit 2 Examples Examples Ex. Ex. Ex. SHL dest, 1; SHL dest,cl; SHL dest,
More informationPractical Malware Analysis
Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the
More informationLAB 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 informationLecture 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 informationLecture (08) x86 programming 7
Lecture (08) x86 programming 7 By: Dr. Ahmed ElShafee 1 Conditional jump: Conditional jumps are executed only if the specified conditions are true. Usually the condition specified by a conditional jump
More informationLecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET
Lecture 1: Passing Parameters on the Stack Push Examples Quick Stack Review Passing Parameters on the Stack Binary/ASCII conversion ;assume SP = 0202 mov ax, 124h push ax push 0af8h push 0eeeh EE 0E F8
More informationUNIT 4. Modular Programming
1 UNIT 4. Modular Programming Program is composed from several smaller modules. Modules could be developed by separate teams concurrently. The modules are only assembled producing.obj modules (Object modules).
More informationInteger Arithmetic. Shift and rotate. Overview. Shift and Rotate Instructions
Overview Integer Arithmetic Shift and rotate instructions and their applications Multiplication and division instructions Extended addition and subtraction Computer Organization and Assembly Languages
More informationCMSC 313 Lecture 07. Short vs Near Jumps Logical (bit manipulation) Instructions AND, OR, NOT, SHL, SHR, SAL, SAR, ROL, ROR, RCL, RCR
CMSC 313 Lecture 07 Short vs Near Jumps Logical (bit manipulation) Instructions AND, OR, NOT, SHL, SHR, SAL, SAR, ROL, ROR, RCL, RCR More Arithmetic Instructions NEG, MUL, IMUL, DIV Indexed Addressing:
More information.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]
Problem : Programming in Assembly [ Points] The following assembly program is supposed to: receive three integer numbers from the console, call a function, name sort, function sort arranges the three input
More informationMarking Scheme. Examination Paper. Module: Microprocessors (630313)
Philadelphia University Faculty of Engineering Marking Scheme Examination Paper Department of CE Module: Microprocessors (630313) Final Exam Second Semester Date: 12/06/2017 Section 1 Weighting 40% of
More informationMODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE
EXERCISE 9. Determine the mod bits from Figure 7-24 and write them in Table 7-7. MODE (mod) FIELD CODES mod 00 01 10 DESCRIPTION MEMORY MODE: NO DISPLACEMENT FOLLOWS MEMORY MODE: 8-BIT DISPLACEMENT MEMORY
More informationLABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS
LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS 1. Object of laboratory The x86 microprocessor family has a large variety of instructions that allow instruction flow control. We have 4 categories: jump,
More informationLab 6: Conditional Processing
COE 205 Lab Manual Lab 6: Conditional Processing Page 56 Lab 6: Conditional Processing Contents 6.1. Unconditional Jump 6.2. The Compare Instruction 6.3. Conditional Jump Instructions 6.4. Finding the
More informationScott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998
Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998 Assembler Syntax Everything looks like this: label: instruction dest,src instruction label Comments: comment $ This is a comment
More informationSummer 2003 Lecture 4 06/14/03
Summer 2003 Lecture 4 06/14/03 LDS/LES/LSS General forms: lds reg,mem lseg reg,mem Load far pointer ~~ outside of current segment {E.g., load reg w/value @ mem, & seg w/mem+2 XCHG Exchange values General
More informationCS/ECE/EEE/INSTR F241 MICROPROCESSOR PROGRAMMING & INTERFACING MODULE 4: 80X86 INSTRUCTION SET QUESTIONS ANUPAMA KR BITS, PILANI KK BIRLA GOA CAMPUS
CS/ECE/EEE/INSTR F241 MICROPROCESSOR PROGRAMMING & INTERFACING MODULE 4: 80X86 INSTRUCTION SET QUESTIONS ANUPAMA KR BITS, PILANI KK BIRLA GOA CAMPUS Q1. IWrite an ALP that will examine a set of 20 memory
More information1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M. 2 PUSH/ POP R16/M16/SR/F 2 x ( ) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M
Increment R16 1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M 4 x (16+48) = 256 opcodes 2 PUSH/ POP R16/M16/SR/F 2 x (8+24+4+1) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M 4 x (16+48) = 256 opcodes INC
More informationAssembly Language Programming
Assembly Language Programming Integer Constants Optional leading + or sign Binary, decimal, hexadecimal, or octal digits Common radix characters: h hexadecimal d decimal b binary r encoded real q/o - octal
More informationCS-202 Microprocessor and Assembly Language
CS-202 Microprocessor and Assembly Language Lecture 2 Introduction to 8086 Assembly Language Dr Hashim Ali Spring - 2019 Department of Computer Science and Engineering HITEC University Taxila!1 Lecture
More information8086 Programming. Multiplication Instructions. Multiplication can be performed on signed and unsigned numbers.
Multiplication Instructions 8086 Programming Multiplication can be performed on signed and unsigned numbers. MUL IMUL source source x AL source x AX source AX DX AX The source operand can be a memory location
More informationModule 3 Instruction Set Architecture (ISA)
Module 3 Instruction Set Architecture (ISA) I S A L E V E L E L E M E N T S O F I N S T R U C T I O N S I N S T R U C T I O N S T Y P E S N U M B E R O F A D D R E S S E S R E G I S T E R S T Y P E S O
More informationIt is possible to define a number using a character or multiple numbers (see instruction DB) by using a string.
1 od 5 17. 12. 2017 23:53 (https://github.com/schweigi/assembler-simulator) Introduction This simulator provides a simplified assembler syntax (based on NASM (http://www.nasm.us)) and is simulating a x86
More informationADDRESSING MODES. Operands specify the data to be used by an instruction
ADDRESSING MODES Operands specify the data to be used by an instruction An addressing mode refers to the way in which the data is specified by an operand 1. An operand is said to be direct when it specifies
More informationKingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems
Kingdom of Saudi Arabia Ministry of Higher Education Taif University Faculty of Computers & Information Systems المملكة العربية السعودية وزارة التعليم العالي جامعة الطاي ف آلية الحاسبات ونظم المعلومات
More informationEEM336 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 informationUMBC. 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 informationEXPERIMENT 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 to search a number in given array. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM
More information6/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 informationCONTENTS. 1. Display a Message Display a one Digit Number Accept a Character from keyboard and display the character 4
University of Kashmir, North Campus Course Code Course Name Course Instructor MCA-104-DCE Assembly Language Programming Bilal Ahmad Dar CONTENTS 1. Display a Message 2 2. Display a one Digit Number 3 3.
More informationAssembly 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 informationAssembly Language Each statement in an assembly language program consists of four parts or fields.
Chapter 3: Addressing Modes Assembly Language Each statement in an assembly language program consists of four parts or fields. The leftmost field is called the label. - used to identify the name of a memory
More informationThe 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 informationArithmetic and Logic Instructions And Programs
Dec Hex Bin 3 3 00000011 ORG ; FOUR Arithmetic and Logic Instructions And Programs OBJECTIVES this chapter enables the student to: Demonstrate how 8-bit and 16-bit unsigned numbers are added in the x86.
More informationLab 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 informationInline 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 informationAdding Binary Integers. Part 4. Negative Binary. Integers. Adding Base 10 Numbers. Adding Binary Example = 10. Arithmetic Logic Unit
Part 4 Adding Binary Integers Arithmetic Logic Unit = Adding Binary Integers Adding Base Numbers Computer's add binary numbers the same way that we do with decimal Columns are aligned, added, and "'s"
More informationJones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION 80x86 Instructions
80x86 Instructions Chapter 4 In the following sections, we review some basic instructions used by the 80x86 architecture. This Jones is by & no Bartlett means a Learning, complete list LLC of the Intel
More informationCMSC 313 Lecture 05 [draft]
CMSC 313 Lecture 05 [draft] More on Conditional Jump Instructions Short Jumps vs Near Jumps Using Jump Instructions Logical (bit manipulation) Instructions AND, OR, NOT, SHL, SHR, SAL, SAR, ROL, ROR, RCL,
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 21: Generating Pentium Code 10 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 21: Generating Pentium Code 10 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Simple Code Generation Three-address code makes it
More informationIslamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 7. Procedures and the Stack
Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 7 Procedures and the Stack April, 2014 1 Assembly Language LAB Runtime Stack and Stack
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST 2 Date : 02/04/2018 Max Marks: 40 Subject & Code : Microprocessor (15CS44) Section : IV A and B Name of faculty: Deepti.C Time : 8:30 am-10:00 am Note: Note: Answer any five complete
More informationBasic Intel x86 Assembly Language Programming
1 Basic Intel x86 Programming 2 Intel x86 Processor Family Processor Integer Width (bits) Physical Address (bits) Year Features 8086 16 20 1978 16-bit data I/O bus 8088 16 20 1979 8-bit data I/O bus Used
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 6: Conditional Processing
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 6: Conditional Processing (c) Pearson Education, 2002. All rights reserved. Chapter Overview Boolean and Comparison Instructions
More information