VAX-11 Assembler & Simulator

Total Page:16

File Type:pdf, Size:1020Kb

VAX-11 Assembler & Simulator VAX11 Simulator 1 Software Laboratory Electrical Engineering Department Technion, Haifa, Israel Technion, Israel Institute of Technology. VAX-11 Assembler & Simulator Adar Nir, Grosman Rotem Instructor – Zion Gal Nir Adar Rotem Grosman VAX11 Simulator 2 Nir Adar Rotem Grosman VAX11 Simulator 3 1. Contents 1. CONTENTS 3 2. INTRODUCTION 9 2.1. PROJECT OBJECTIVE 9 2.1.1. GENERAL PROJECT DESCRIPTION 9 2.1.2. THE PROJECT GOAL 9 2.1.3. TIMES 10 2.1.4. REQUIRED FEATURES 10 2.2. PROJECT RESULT 11 2.3. THE OLD SIMULATOR 12 2.3.1. PROBLEMS WITH THE OLD SIMULATOR - GENERAL 12 2.3.2. LIMITATIONS 12 2.3.3. BUGS 13 2.3.4. ADVANTAGES OF OUR SIMULATOR 13 2.4. DESIGN OVERVIEW 14 2.4.1. STAGE 1 – LEARNING 15 2.4.2. STAGE 2 – DESIGN THE ASSEMBLER AND THE ENVIRONMENT 18 2.4.3. STAGE 3 – IMPLEMENTATION 20 2.4.4. STAGE 4 - DESIGNING THE SIMULATOR 20 2.4.5. STAGE 5 - IMPLEMENTATION OF THE SIMULATOR 21 2.5. ACKNOWLEDGEMENTS 22 3. VAX11 SIMULATOR SPECIFICATIONS 23 3.1. THE BASIC STRUCTURE OF VAX-11 COMPUTER 23 3.2. THE MEMORY SYSTEM 23 3.3. CENTRAL PROCESSING UNIT (CPU) 23 3.4. PROCESSOR STATUS WORD (PSW) 24 3.5. PROCESSOR STATUS LONGWORD (PSL) 24 3.6. REGISTERS 26 3.7. INPUT/OUTPUT DEVICES 27 3.8. VAX-11 INFORMATION UNIT 27 3.9. INSTRUCTION FORMAT 27 3.10. ADDRESSING MODES 28 3.11. FUNCTION CALLS 29 3.12. INTERRUPTS 33 3.12.1. INTRODUCTION 33 3.12.2. PROCESSOR INTERRUPT PRIORITY LEVELS (IPLS) 34 3.12.3. CONTRAST BETWEEN EXCEPTIONS AND INTERRUPTS 34 3.12.4. SOFTWARE INTERRUPT SUMMARY REGISTER 35 3.12.5. SOFTWARE INTERRUPT REQUEST REGISTER 36 Nir Adar Rotem Grosman VAX11 Simulator 4 3.12.6. INTERRUPT PRIORITY LEVEL REGISTER 36 3.12.7. SYSTEM CONTROL BLOCK (SCB) 37 3.12.8. SYSTEM CONTROL BLOCK BASE (SCBB) 37 3.12.9. PRIVILEGED REGISTERS 38 3.13. ARITHMETIC EXCEPTIONS 41 3.13.1. INTEGER OVERFLOW TRAP 41 3.13.2. INTEGER DIVIDE BY ZERO TRAP 41 3.13.3. SUBSCRIPT RANGE TRAP 42 3.14. ASSEMBLER'S DIRECTIVES 43 3.14.1. .TEXT - TEXT CODE SEGMENT 43 3.14.2. .DATA - DATA CODE SEGMENT 43 3.14.3. .SET - SYMBOL DECLARATION 43 3.14.4. .SPACE - BYTE ARRAY OF NULLS 44 3.14.5. .ASCII - STRING DECLARATION 44 3.14.6. .ASCIZ - STRING DECLARATION 45 3.14.7. .ASCIC - STRING DECLARATION 46 3.14.8. .BYTE - BYTE ASSIGNMENT 46 3.14.9. .WORD - WORD ASSIGNMENT 47 3.14.10. .INT - INTEGER ASSIGNMENT 47 3.14.11. .LONG - LONG ASSIGNMENT 48 3.14.12. .QUAD - QUADWORD STORAGE DIRECTIVE 48 3.14.13. .ORG - FILL AT ADDRESS 48 3.14.14. .ENTRYPOINT - DEFINE THE STARTING ADDRESS OF THE PROGRAM. 49 3.15. SYSTEM CALLS 50 3.15.1. EXIT 50 3.15.2. GETCHAR 51 3.15.3. PUTCHAR 51 3.15.4. GETS 52 3.15.5. PUTS 53 3.15.6. SCANF - READ FORMATTED DATA FROM STDIN 54 3.15.7. PRINTF - WRITE FORMATTED STRING TO STDOUT 57 3.15.8. MALLOC - ALLOCATE MEMORY BLOCK 60 3.15.9. FREE - DEALLOCATE MEMORY BLOCK 61 3.15.10. SPRINTF - WRITE FORMATTED STRING TO STRING 63 3.15.11. INITGRAPH - INITIALIZES THE GRAPHICS SYSTEM 66 3.15.12. CLOSEGRAPH - SHUTS DOWN THE GRAPHICS SYSTEM 66 3.15.13. CLEARDEVICE - CLEARS THE GRAPHICS SCREEN 66 3.15.14. LINE - DRAWS LINE 67 3.15.15. RECTANGLE - DRAWS A RECTANGLE 67 3.15.16. SETCOLOR - SETS THE CURRENT DRAWING COLOR 68 3.15.17. GETMAXX, GETMAXY 69 3.15.18. PUTPIXEL 69 3.15.19. CIRCLE 69 3.15.20. OUTTEXTXY 70 3.15.21. SETFONT 70 3.16. INSTRUCTION SET SUMMARY 71 4. VAX11 SIMULATOR - USER GUIDE 72 4.1. INTRODUCTION 72 4.2. MAIN FEATURES 72 4.3. START WORKING 73 4.4. TEXT EDITOR 74 4.5. OPTIONS WINDOW 76 Nir Adar Rotem Grosman VAX11 Simulator 5 4.5.1. WORKING ENVIRONMENT 76 4.5.2. ASSEMBLER 78 4.5.3. SIMULATOR 78 4.6. THE ASSEMBLER 80 4.7. THE SIMULATOR 82 5. OUR PROJECT - OVERVIEW 85 5.1. PROJECT MODULES 85 5.1.1. THE WORKING ENVIRONMENT 85 5.1.2. THE ASSEMBLER 85 5.1.3. THE SIMULATOR & THE CONTROLLER 86 6. SETTINGS CLASS 87 6.1. DESCRIPTION 87 6.2. CLASS STRUCTURE 87 7. WORKING ENVIRONMENT 89 7.1. OVERVIEW 89 7.2. ENVIRONMENT CLASSES 91 7.2.1. FRMMAIN 91 7.2.2. FRMTASKLIST 95 7.2.3. FRMCOMPILEMESSAGES 95 7.2.4. FRMEDITOR 96 7.2.5. REGISTERSVIEW 97 7.2.6. MEMORYVIEW 98 7.2.7. STACKVIEW 98 7.2.8. WATCHESVIEW 99 7.2.9. PROGRAMSPOOL 100 7.2.10. PROGRAM 101 7.2.11. BREAKPOINTLIST, BREAKPOINTENTRY (CLASS) 102 7.3. SIMULATOR DEBUG MODE'S DESIGN 103 7.3.1. FLAGS 103 7.3.2. SEMAPHORES 103 8. ASSEMBLER'S CLASS & ALGORITHMS 104 8.1. OVERVIEW 104 8.1.1. DATA STRUCTURES 105 8.1.2. CLASSES 105 8.1.3. ALGORITHM 106 8.2. DATA STRUCTURES 107 8.2.1. OPCODES TABLE 107 8.2.2. KNOWN PROCEDURES TABLE 108 8.2.3. KNOWN REGISTERS TABLE 108 8.2.4. ASSEMBLER MESSAGES 109 8.2.5. KNOWN VAX-11 FUNCTIONS: 110 8.2.6. VAX-11 REGISTER LIST 110 8.2.7. VAX-11 COMMANDS 111 Nir Adar Rotem Grosman VAX11 Simulator 6 8.3. ASSEMBLER CLASS AND INTERNAL DATA STRUCTURES 115 8.3.1. ASSEMBLER CLASS INTERFACE 115 8.3.2. CODEBLOCK (CLASS) 115 8.3.3. OPCODE ENTRY (CLASS) 117 8.3.4. SYMBOLS TABLE (CLASS) 117 8.3.5. LINESLOCATIONS (CLASS) 118 8.3.6. COMPILERCOMMENT (CLASS) 119 8.3.7. PASS2LIST (CLASS) 119 8.4. ASSEMBLER ALGORITHMS 120 8.4.1. GENERAL 120 8.4.2. CONSTRUCTOR 120 8.4.3. GETSYMBOLSTABLE 121 8.4.4. GETCOMPILEMESSAGES 121 8.4.5. GETLSTFILE 122 8.4.6. GETMACHINECODE 122 8.4.7. COMPILECODE 123 8.4.8. PRECOMPILER 124 8.4.9. DOPASS1 125 8.4.10. ANALYZECOMMAND 127 8.4.11. FETCHOPERAND 128 8.4.12. ANALYZEDIRECTIVE 128 8.4.13. READNEXTNUMBER 129 8.4.14. READNEXTWORD 130 8.4.15. READNEXTCHAR 130 8.4.16. CALCEXPRESSION 130 8.4.17. ANALYZESTRING 131 8.4.18. DOPASS2 131 8.4.19. OVERRANGE 132 9. VAX-11 SIMULATOR 133 9.1. SIMULATOR CLASS AND INTERNAL DATA STRUCTURES 133 9.1.1. CLASSES OVERVIEW 133 9.1.2. MEMORY CLASS 135 9.1.3. SIMULATOR CLASS 136 9.1.4. REGISTERS (CLASS) 137 9.1.5. CONSOLE 137 9.2. SIMULATOR ALGORITHMS 140 9.2.1. MEMORY 140 10. TEST PROGRAMS 141 10.1. PROGRAM 1 – “HELLO, WORLD” 141 10.2. PROGRAM 2 – DUMP MEMORY 143 10.3. PROGRAM 3 – ANALYZING USER INPUT 144 10.4. PROGRAM 4 – PRIME NUMBERS 145 10.5. PROGRAM 5 – STRING PROCESSING 146 10.6. PROGRAM 6 - FIBONACCI SERIES - VERSION 1 147 10.7. PROGRAM 7 - FIBONACCI SERIES - VERSION 2 148 10.8. PROGRAM 8 - COPY A STRING 149 10.9. PROGRAM 9 - ANALYZE INPUT - NUMBER OF CHARS, WORDS AND LINES 150 11. VAX-11 OPCODES 151 Nir Adar Rotem Grosman VAX11 Simulator 7 11.1. OPERAND DESCRIPTORS 151 11.2. NOTATION 153 11.3. VAX-11 OPCODES AND EXAMPLES 154 11.3.1. ACB ADD COMPARE AND BRANCH 154 11.3.2. ADD ADD 156 11.3.3. ADWC ADD WITH CARRY 159 11.3.4. ADAWI ADD ALIGNED WORD INTERLOCKED 160 11.3.5. AOB ADD ONE AND BRANCH 162 11.3.6. ASH ARITHMETIC SHIFT 164 11.3.7. B BRANCH ON (CONDTION) 166 11.3.8. BB BRANCH ON BIT 172 11.3.9. BB BRANCH ON BIT (AND MODIFY WITHOUT INTERLOCKED) 174 11.3.10. BB BRANCH ON BIT INTERLOCKED 175 11.3.11. BIC BIT CLEAR 176 11.3.12. BIS BIT SET 179 11.3.13. BISPSW, BICPSW BIT SET PSW, BIT CLEAR PSW PSL 182 11.3.14. BIT BIT TEST 183 11.3.15. BLB BRANCH ON LOW BIT 185 11.3.16. BPT BREAKPOINT FAULT 187 11.3.17. BR, JMP BRANCH, JUMP 188 11.3.18. BSB, JSB SUBROUTINE INSTRUCTIONS JUMP, BRANCH TO SUBROUTINE 189 11.3.19. CALLG CALL PROCEDURE WITH GENERAL ARGUMENT LIST 190 11.3.20. CALLS CALL PROCEDURE WITH STACK ARGUMENT LIST 192 11.3.21. CASE CASE INSTRUCTIONS 194 11.3.22. CLR CLEAR 195 11.3.23. CMP COMPARE 196 11.3.24. CMPC COMPARE CHARACTERS 198 11.3.25. CVT CONVERT 200 11.3.26. DEC DECREMENT 202 11.3.27. DIV DIVIDE 204 11.3.28. EDIV EXTENDED DIVIDE 206 11.3.29. EMOD EXTENDED MULTIPLY AND INTEGERIZE 207 11.3.30. EMUL EXTENDED MULTIPLY 209 11.3.31. HALT 210 11.3.32. INC INCREMENT 211 11.3.33. INDEX COMPUTE INDEX 213 11.3.34. INSQUE INSERT ENTRY IN QUEUE 214 11.3.35. LOCC SKPC LOCATE CHARACTER, SKIP CHARACTER 216 11.3.36. MATCHC MATCH CHARACTERS 218 11.3.37. MCOM MOVE COMPLEMENTED 219 11.3.38. MNEG MOVE NEGATED 220 11.3.39. MOV 222 11.3.40. MOVA, PUSHA MOVE ADDRESS, PUSH ADDRESS 225 11.3.41. MOVC MOVE CHARACTER 226 11.3.42. MOVPSL MOVE FROM PSL 229 11.3.43. MOVTC MOVE TRANSLATED CHARACTERS 230 11.3.44. MOVTUC MOVE TRANSLATED UNTIL CHARACTER 232 11.3.45. MOVZ MOVE ZERO-EXTENDED 234 11.3.46. MUL MULTIPLY 235 11.3.47. POLY POLYNOMINAL EVALUATION 237 11.3.48.
Recommended publications
  • E0C88 CORE CPU MANUAL NOTICE No Part of This Material May Be Reproduced Or Duplicated in Any Form Or by Any Means Without the Written Permission of Seiko Epson
    MF658-04 CMOS 8-BIT SINGLE CHIP MICROCOMPUTER E0C88 Family E0C88 CORE CPU MANUAL NOTICE No part of this material may be reproduced or duplicated in any form or by any means without the written permission of Seiko Epson. Seiko Epson reserves the right to make changes to this material without notice. Seiko Epson does not assume any liability of any kind arising out of any inaccuracies contained in this material or due to its application or use in any product or circuit and, further, there is no representation that this material is applicable to products requiring high level reliability, such as medical products. Moreover, no license to any intellectual property rights is granted by implication or otherwise, and there is no representation or warranty that anything made in accordance with this material will be free from any patent or copyright infringement of a third party. This material or portions thereof may contain technology or the subject relating to strategic products under the control of the Foreign Exchange and Foreign Trade Control Law of Japan and may require an export license from the Ministry of International Trade and Industry or other approval from another government agency. Please note that "E0C" is the new name for the old product "SMC". If "SMC" appears in other manuals understand that it now reads "E0C". © SEIKO EPSON CORPORATION 1999 All rights reserved. CONTENTS E0C88 Core CPU Manual PREFACE This manual explains the architecture, operation and instruction of the core CPU E0C88 of the CMOS 8-bit single chip microcomputer E0C88 Family. Also, since the memory configuration and the peripheral circuit configuration is different for each device of the E0C88 Family, you should refer to the respective manuals for specific details other than the basic functions.
    [Show full text]
  • Cmp Instruction in Assembly Language
    Cmp Instruction In Assembly Language booby-trapsDamien pedaling sound. conjointly? Untidiest SupposableGraham precools, and uncleansed his ilexes geologisesNate shrouds globed her chokos contemptuously. espied or It works because when a short jump if the stack to fill out over an implied subtraction of assembly language is the arithmetic operation of using our point Jump if actual assembler or of assembly is correct results in sequence will stay organized. If you want to prove that will you there is cmp instruction in assembly language, sp can also accept one, it takes quite useful sample programs in game reports to. Acts as the instruction pointer should be checked for? Please switch your skills, cmp instruction cmp in assembly language. To double word register onto the next step process in assembly language equivalent to collect great quiz. The comparisons and the ip value becomes a row! Subsequent generations became new game code starts in main program plays a few different memory locations declared with. Want to switch, many commands to thumb instructions will not examine the difference between filtration and in assembly language are used as conditional jumps are calls to the call. Note that was no difference in memory operands and its corresponding comparison yielded an explicit, xor is running but also uses a perennial study guide can exit? Each question before you want to see the control flow and play this instruction cmp in assembly language? This value off this for assembly language, cmp instruction in assembly language? But shl can explicitly directed as efficient ways to compare values stored anywhere in terms indicated by cmp instruction in assembly language calling convention rules.
    [Show full text]
  • (PSW). Seven Bits Remain Unused While the Rest Nine Are Used
    8086/8088MP INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI The Flags Register It is a 16-bit register, also called Program Status Word (PSW). Seven bits remain unused while the rest nine are used. Six are status flags and three are control flags. The control flags can be set/reset by the programmer. 1. DF (Direction Flag) : controls the direction of operation of string instructions. (DF=0 Ascending order DF=1 Descending order) 2. IF (Interrupt Flag): controls the interrupt operation in 8086µP. (IF=0 Disable interrupt IF=1 Enable interrupt) 3. TF (Trap Flag): controls the operation of the microprocessor. (TF=0 Normal operation TF=1 Single Step operation) The status flags are set/reset depending on the results of some arithmetic or logical operations during program execution. 1. CF (Carry Flag) is set (CF=1) if there is a carry out of the MSB position resulting from an addition operation or subtraction. 2. AF (Auxiliary Carry Flag) AF is set if there is a carry out of bit 3 resulting from an addition operation. 3. SF (Sign Flag) set to 1 when result is negative. When result is positive it is set to 0. 4. ZF (Zero Flag) is set (ZF=1) when result of an arithmetic or logical operation is zero. For non-zero result this flag is reset (ZF=0). 5. PF (Parity Flag) this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits. 6. OF (Overflow Flag) set to 1 when there is a signed overflow.
    [Show full text]
  • AVR Control Transfer -AVR Branching
    1 | P a g e AVR Control Transfer -AVR Branching Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 3: Branch, Call, and Time Delay Loop Section 3.1: Branching and Looping (Branch Only) Additional Reading Introduction to AVR assembler programming for beginners, controlling sequential execution of the program http://www.avr-asm-tutorial.net/avr_en/beginner/JUMP.html AVR Assembler User Guide http://www.atmel.com/dyn/resources/prod documents/doc1022.pdf 2 | P a g e TABLE OF CONTENTS Instruction Set Architecture (Review) ...................................................................................................................... 4 Instruction Set (Review) ........................................................................................................................................... 5 Jump Instructions..................................................................................................................................................... 6 How the Direct Unconditional Control Transfer Instructions jmp and call Work ...................................................... 7 How the Relative Unconditional Control Transfer Instructions rjmp and rcall Work ................................................ 8 Branch Instructions .................................................................................................................................................. 9 How the Relative Conditional Control Transfer Instruction
    [Show full text]
  • Overview of IA-32 Assembly Programming
    Overview of IA-32 assembly programming Lars Ailo Bongo University of Tromsø Contents 1 Introduction ...................................................................................................................... 2 2 IA-32 assembly programming.......................................................................................... 3 2.1 Assembly Language Statements................................................................................ 3 2.1 Modes........................................................................................................................4 2.2 Registers....................................................................................................................4 2.2.3 Data Registers .................................................................................................... 4 2.2.4 Pointer and Index Registers................................................................................ 4 2.2.5 Control Registers................................................................................................ 5 2.2.6 Segment registers ............................................................................................... 7 2.3 Addressing................................................................................................................. 7 2.3.1 Bit and Byte Order ............................................................................................. 7 2.3.2 Data Types.........................................................................................................
    [Show full text]
  • Assembly Language: IA-X86
    Assembly Language for x86 Processors X86 Processor Architecture CS 271 Computer Architecture Purdue University Fort Wayne 1 Outline Basic IA Computer Organization IA-32 Registers Instruction Execution Cycle Basic IA Computer Organization Since the 1940's, the Von Neumann computers contains three key components: Processor, called also the CPU (Central Processing Unit) Memory and Storage Devices I/O Devices Interconnected with one or more buses Data Bus Address Bus data bus Control Bus registers Processor I/O I/O IA: Intel Architecture Memory Device Device (CPU) #1 #2 32-bit (or i386) ALU CU clock control bus address bus Processor The processor consists of Datapath ALU Registers Control unit ALU (Arithmetic logic unit) Performs arithmetic and logic operations Control unit (CU) Generates the control signals required to execute instructions Memory Address Space Address Space is the set of memory locations (bytes) that are addressable Next ... Basic Computer Organization IA-32 Registers Instruction Execution Cycle Registers Registers are high speed memory inside the CPU Eight 32-bit general-purpose registers Six 16-bit segment registers Processor Status Flags (EFLAGS) and Instruction Pointer (EIP) 32-bit General-Purpose Registers EAX EBP EBX ESP ECX ESI EDX EDI 16-bit Segment Registers EFLAGS CS ES SS FS EIP DS GS General-Purpose Registers Used primarily for arithmetic and data movement mov eax 10 ;move constant integer 10 into register eax Specialized uses of Registers eax – Accumulator register Automatically
    [Show full text]
  • CS221 Booleans, Comparison, Jump Instructions Chapter 6 Assembly Language Is a Great Choice When It Comes to Working on Individu
    CS221 Booleans, Comparison, Jump Instructions Chapter 6 Assembly language is a great choice when it comes to working on individual bits of data. While some languages like C and C++ include bitwise operators, several high-level languages are missing these operations entirely (e.g. Visual Basic 6.0). At times these operations can be quite useful. First we will describe some common bit operations, and then discuss conditional jumps. AND Instruction The AND instruction performs a Boolean AND between all bits of the two operands. For example: mov al, 00111011b and al, 00001111b The result is that AL contains 00001011. We have “multiplied” each corresponding bit. We have used AND for a common operation in this case, to clear out the high nibble. Sometimes the operand we are AND’ing something with is called a bit mask because wherever there is a zero the result is zero (masking out the original data), and wherever we have a one, we copy the original data through the mask. For example, consider an ASCII character. “Low” ASCII ignores the high bit; we only need the low 7 bits and we might use the high bit for either special characters or perhaps as a parity bit. Given an arbitrary 8 bits for a character, we could apply a mask that removes the high bit and only retains the low bits: and al, 01111111b OR Instruction The OR instruction performs a Boolean OR between all bits of the two operands. For example: mov al, 00111011b or al, 00001111b As a result AL contains 00111111. We have “Added” each corresponding bit, throwing away the carry.
    [Show full text]
  • CS107, Lecture 13 Assembly: Control Flow and the Runtime Stack
    CS107, Lecture 13 Assembly: Control Flow and The Runtime Stack Reading: B&O 3.6 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution 2.5 License. All rights reserved. Based on slides created by Marty Stepp, Cynthia Lee, Chris Gregg, and others. 1 Learning Goals • Learn how assembly implements loops and control flow • Learn how assembly calls functions. 2 Plan For Today • Control Flow • Condition Codes • Assembly Instructions • Break: Announcements • Function Calls and the Stack 3 mov Variants • mov only updates the specific register bytes or memory locations indicated. • Exception: movl writing to a register will also set high order 4 bytes to 0. • Suffix sometimes optional if size can be inferred. 4 No-Op • The nop/nopl instructions are “no-op” instructions – they do nothing! • No-op instructions do nothing except increment %rip • Why? To make functions align on nice multiple-of-8 address boundaries. “Sometimes, doing nothing is the way to be most productive.” – Philosopher Nick 5 Mov • Sometimes, you’ll see the following: mov %ebx, %ebx • What does this do? It zeros out the top 32 register bits, because when mov is performed on an e- register, the rest of the 64 bits are zeroed out. 6 xor • Sometimes, you’ll see the following: xor %ebx, %ebx • What does this do? It sets %ebx to zero! May be more efficient than using mov. 7 Plan For Today • Control Flow • Condition Codes • Assembly Instructions • Break: Announcements • Function Calls and the Stack 8 Control • In C, we have control flow statements like if, else, while, for, etc.
    [Show full text]
  • Implicitly Modified Registers
    24592—Rev. 3.14—September 2007 AMD64 Technology Table 3-1. Implicit Uses of GPRs Registers 1 Name Implicit Uses Low 8-Bit 16-Bit 32-Bit 64-Bit • Operand for decimal arithmetic, multiply, divide, string, compare-and- exchange, table-translation, and I/O instructions. 2 • Special accumulator encoding AL AX EAX RAX Accumulator for ADD, XOR, and MOV instructions. • Used with EDX to hold double- precision operands. • CPUID processor-feature information. • Address generation in 16-bit code. • Memory address for XLAT BL BX EBX RBX 2 Base instruction. • CPUID processor-feature information. • Bit index for shift and rotate instructions. • Iteration count for loop and CL CX ECX RCX 2 Count repeated string instructions. • Jump conditional if zero. • CPUID processor-feature information. • Operand for multiply and divide instructions. • Port number for I/O instructions. DL DX EDX RDX 2 I/O Address • Used with EAX to hold double- precision operands. • CPUID processor-feature information. • Memory address of source operand for string instructions. SIL 2 SI ESI RSI 2 Source Index • Memory index for 16-bit addresses. Note: 1. Gray-shaded registers have no implicit uses. 2. Accessible only in 64-bit mode. General-Purpose Programming 31 AMD64 Technology 24592—Rev. 3.14—September 2007 Table 3-1. Implicit Uses of GPRs (continued) Registers 1 Name Implicit Uses Low 8-Bit 16-Bit 32-Bit 64-Bit • Memory address of destination Destination operand for string instructions. DIL 2 DI EDI RDI 2 Index • Memory index for 16-bit addresses. • Memory address of stack- BPL 2 BP EBP RBP 2 Base Pointer frame base pointer.
    [Show full text]
  • Assembly Language Tutorial
    Assembly Language Tutorial ASSEMBLY LANGUAGE TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Assembly Programming Tutorial Assembly language is a low-level programming language for a computer, or other programmable device specific to a particular computer architecture in contrast to most high- level programming languages, which are generally portable across multiple systems. Assembly language is converted into executable machine code by a utility program referred to as an assembler like NASM, MASM etc. Audience This tutorial has been designed for software programmers with a need to understand the Assembly programming language starting from scratch. This tutorial will give you enough understanding on Assembly programming language from where you can take yourself at higher level of expertise. Prerequisites Before proceeding with this tutorial you should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages will help you in understanding the Assembly programming concepts and move fast on the learning track. TUTORIALS POINT Simply Easy Learning Copyright & Disclaimer Notice All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at [email protected] TUTORIALS POINT Simply Easy Learning Table of Content Assembly Programming Tutorial .............................................
    [Show full text]
  • X86 Assembly Programming Part 2
    x86 Assembly Programming Part 2 EECE416 uC Charles Kim Howard University Resources: Intel 80386 Programmers Reference Manual Essentials of 80x86 Assembly Language Introduction to 80x86 Assembly Language Programming WWW.MWFTR.COM Reminder – Coding Assignment Listing (.LST) File of Assembly Code (.asm) Registers for x86 Basic Data Types • Byte, Words (WORD), Double Words (DWORD) • Little-Endian • Align by 2 (word) or 4 (Dword) for better performance – instead of odd address Data Declaration • Directives for Data Declaration and Reservation of Memory – BYTE: Reserves 1 byte in memory •Example: D1 BYTE 20 D2 BYTE 00010100b String1 BYTE “Joe” ; [4A 6F 65] – WORD: 2 bytes are reserved • Example: num1 WORD -10 num2 WORD FFFFH – DWORD: 4 bytes are reserved •Example: N1 DWORD -10 – QWORD: 8 bytes • 64 bit: RAX RBX RCX ,etc • 32 bit: EDX:EAX Concatenation for CDQ instruction Instruction Format • Opcode: – specifies the operation performed by the instruction. • Register specifier – an instruction may specify one or two register operands. • Addressing-mode specifier – when present, specifies whether an operand is a register or memory location. • Displacement – when the addressing-mode specifier indicates that a displacement will be used to compute the address of an operand, the displacement is encoded in the instruction. • Immediate operand – when present, directly provides the value of an operand of the instruction. Immediate operands may be 8, 16, or 32 bits wide. Register Size and Data • Assuming that the content of eax is [01FF01FF], what would
    [Show full text]
  • Status Flags
    BASIC EXECUTION ENVIRONMENT 3.4.3.1. STATUS FLAGS The status flags (bits 0, 2, 4, 6, 7, and 11) of the EFLAGS register indicate the results of arith- metic instructions, such as the ADD, SUB, MUL, and DIV instructions. The functions of the status flags are as follows: CF (bit 0) Carry flag. Set if an arithmetic operation generates a carry or a borrow out of the most-significant bit of the result; cleared otherwise. This flag indi- cates an overflow condition for unsigned-integer arithmetic. It is also used in multiple-precision arithmetic. PF (bit 2) Parity flag. Set if the least-significant byte of the result contains an even number of 1 bits; cleared otherwise. AF (bit 4) Adjust flag. Set if an arithmetic operation generates a carry or a borrow out of bit 3 of the result; cleared otherwise. This flag is used in binary- coded decimal (BCD) arithmetic. ZF (bit 6) Zero flag. Set if the result is zero; cleared otherwise. SF (bit 7) Sign flag. Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value.) OF (bit 11) Overflow flag. Set if the integer result is too large a positive number or too small a negative number (excluding the sign-bit) to fit in the destina- tion operand; cleared otherwise. This flag indicates an overflow condition for signed-integer (two’s complement) arithmetic. Of these status flags, only the CF flag can be modified directly, using the STC, CLC, and CMC instructions.
    [Show full text]