It is possible to define a number using a character or multiple numbers (see instruction DB) by using a string.

Similar documents
LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB4 FÖYÜ

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

SOEN228, Winter Revision 1.2 Date: October 25,

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

Computer Architecture..Second Year (Sem.2).Lecture(4) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

Intel Instruction Set (gas)

Basic Assembly Instructions

Introduction to 8086 Assembly

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Jump instructions. Unconditional jumps Direct jump. do not change flags. jmp label

IFE: Course in Low Level Programing. Lecture 6

Selection and Iteration. Chapter 7 S. Dandamudi

8086 INSTRUCTION SET

Conditional Processing

Programming of 8085 microprocessor and 8051 micro controller Study material

Week /8086 Microprocessor Programming

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

Assembly Language Lab # 6

Summer 2003 Lecture 4 06/14/03

CHAPTER SEVENTEEN Assemblers versus Compilers. Intel 80x86 Assembly Language

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

Assembly Language Programming of 8085

Lab 6: Conditional Processing

Branching and Looping

Microcontroller Intel [Instruction Set]

Lecture (08) x86 programming 7

Chapter 6 (Part a) Conditional Processing

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

Programming Model 2 A. Introduction

Assembly Language Programming of 8085

Branching and Looping

SN8F5000 Family Instruction Set

from WRITE GREAT CODE Volume 2: Thinking Low-Level, Writing High-Level ONLINE APPENDIX A The Minimal 80x86 Instruction Set by Randall Hyde

CMSC 313 Lecture 05 [draft]

CPU: SOFTWARE ARCHITECTURE INSTRUCTION SET (PART

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Microcontroller. Instruction set of 8051


TYPES OF INTERRUPTS: -

EC 333 Microprocessor and Interfacing Techniques (3+1)

Instructions and Instruction Set Architecture

PESIT Bangalore South Campus

Computer Architecture and Assembly Language Programming CS401 Lecture No: 1 Address, Data, and Control Buses A computer system comprises of a

Arithmetic and Logic Instructions And Programs

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

UNIT II 16 BIT MICROPROCESSOR INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING. The Intel 8086 Instruction Set


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

3.0 Instruction Set. 3.1 Overview

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 5

CS-202 Microprocessor and Assembly Language

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

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

(2) Explain the addressing mode of OR What do you mean by addressing mode? Explain diff. addressing mode for 8085 with examples.

8085 INSTRUCTION SET INSTRUCTION DETAILS

Section 002. Read this before starting!

db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

IBM PC Hardware CPU 8088, Pentium... ALU (Arithmetic and Logic Unit) Registers. CU (Control Unit) IP.

DR bit RISC Microcontroller. Instructions set details ver 3.10

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

UNIT-III ASSEMBLY LANGUAGE PROGRAMMING. The CPU can access data in various ways, which are called addressing modes

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue

Basic Assembly SYSC-3006

Week /8086 Microprocessor Programming II

Architecture and components of Computer System Execution of program instructions

8051 Microcontroller

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

3.1 DATA MOVEMENT INSTRUCTIONS 45

Lecture 8: Control Structures. Comparing Values. Flags Set by CMP. Example. What can we compare? CMP Examples

Tutorial 1: Programming Model 1

Assembly Language LAB

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

CS401 Assembly Language Solved MCQS From Midterm Papers

Lab 3. The Art of Assembly Language (II)

Practical Malware Analysis

8051 Overview and Instruction Set

CSE351 Spring 2018, Midterm Exam April 27, 2018

Step 1: Add the least significant digits together: produces with carry 1.

Q. Classify the instruction set of 8051 and list out the instructions in each type.

CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK

Read this before starting!

Summary: Direct Code Generation

Introduction to Assembly Language Programming (Instruction Set) 1/18/2011 1

if 2 16bit operands multiplied the result will be

Intel 8086: Instruction Set

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

SOURCE LANGUAGE DESCRIPTION

Chapter Four Instructions Set

Section 001 & 002. Read this before starting!

x64 Cheat Sheet Fall 2014

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

Digital Blocks Semiconductor IP

Section 001. Read this before starting!

INSTRUCTION SET OF 8085

Section 001. Read this before starting!

COMPUTER ENGINEERING DEPARTMENT

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

Transcription:

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 like cpu. In depth documentation and introduction to assembler can be found on the following websites: Assembly - Wikipedia (http://en.wikipedia.org/wiki/assembly_language) The Art of Assembly Language Programming (http://cs.smith.edu/~thiebaut/artofassembly/artofasm.html) NASM Language Documentation (http://www.nasm.us/xdoc/2.10.09/html/nasmdoc3.html) The simulator consists of a 8-bit cpu and 256 bytes of memory. All instructions (code) and variables (data) needs to fit inside the memory. For simplicity every instruction (and operand) is 1 byte. Therefore a MOV instruction will use 3 bytes of memory. The simulator provides a console output which is memory mapped from 0xE8 to 0xFF. Memory mapped means that every value written to this memory block is visible on the console. Syntax The syntax is similar as most assemblers are using. Every instruction must be on their own line. Labels are optional and must either start with a letter or a dot (.) and end with a colon. label: instruction operands ; Comment Valid number formats for constants are: Decimal: 200 Decimal: 200d Hex: 0xA4 Octal: 0o48 Binary: 101b It is possible to define a number using a character or multiple numbers (see instruction DB) by using a string. Character: 'A' String: "Hello World!" Operands can either be one of the four general purpose registers, stack pointer register, a memory address or a constant. Stack pointer register can only be used as operand in MOV, ADD, SUB, CMP, INC and DEC instructions. Instead of defining an address as a constant or by using a register you can use labels. The assembler will then replace the label with the corresponding constant. General purpose (GP) register: A, B, C, D Stack pointer register: SP Address using a GP register: [A] Address using a GP register and offset: [D-3] Address using SP register and offset: [SP+2] Address using a constant: [100] Address using a label: label Constant: Any number between 0..255 (8bit unsigned) Offset for indirect addressing: Integer between -16..+15 (sign is mandatory) MOV - Copy a value Copies a value from src to dest. The MOV instruction is the only one able to directly modify the memory. SP can be

2 od 5 17. 12. 2017 23:53 used as operand with MOV. MOV reg, reg MOV reg, address MOV reg, constant MOV address, reg MOV address, constant DB - Variable Defines a variable. A variable can either be a single number, character or a string. DB constant Math operations Addition and Subtraction Adds two numbers together or subtract one number form another. This operations will modify the carry and zero flag. SP can be used as operand with ADD and SUB. ADD reg, reg ADD reg, address ADD reg, constant SUB reg, reg SUB reg, address SUB reg, constant Increment and Decrement Increments or decrements a register by one. This operations will modify the carry and zero flag. SP can be used as operand with INC and DEC. INC reg DEC reg Multiplication and division Multiplies or divides the A register with the given value. This operations will modify the carry and zero flag. MUL reg MUL address MUL constant DIV reg DIV address DIV constant Logical instructions The following logical instructions are supported: AND, OR, XOR, NOT. This operations will modify the carry and zero flag.

3 od 5 17. 12. 2017 23:53 AND reg, reg AND reg, address AND reg, constant OR reg, reg OR reg, address OR reg, constant XOR reg, reg XOR reg, address XOR reg, constant NOT reg Shift instructions The following shift instructions are supported: SHL/SAL and SHR/SAR. As this simulator only supports unsigned numbers SHR and SAR yield the same result. This operations will modify the carry and zero flag. SHL reg, reg SHL reg, address SHL reg, constant SHR reg, reg SHR reg, address SHR reg, constant CMP - Compare Compares two values and sets the zero flag to true if they are equal. SP can be used as operand with CMP. Use this instruction before a conditional jump. CMP reg, reg CMP reg, address CMP reg, constant Jumps JMP - Unconditional jump Let the instruction pointer do a unconditional jump to the defined address. JMP address Conditional jumps Let the instruction pointer do a conditional jump to the defined address. See the table below for the available conditions. Instruction Description Condition Alternatives JC Jump if carry Carry = TRUE JB, JNAE JNC Jump if no carry Carry = FALSE JNB, JAE JZ Jump if zero Zero = TRUE JB, JE JNZ Jump if no zero Zero = FALSE JNE JA > Carry = FALSE && Zero = FALSE JNBE

4 od 5 17. 12. 2017 23:53 Instruction Description Condition Alternatives JNBE not <= Carry = FALSE && Zero = FALSE JA JAE >= Carry = FALSE JNC, JNB JNB not < Carry = FALSE JNC, JAE JB < Carry = TRUE JC, JNAE JNAE not >= Carry = TRUE JC, JB JBE <= C = TRUE or Z = TRUE JNA JNA not > C = TRUE or Z = TRUE JBE JE = Z = TRUE JZ JNE!= Z = FALSE JNZ CALL - Function call Call can be used to jump into a subroutine (function). Pushes the instruction address of the next instruction to the stack and jumps to the specified address. CALL address RET - Exit a subroutine Exits a subroutines by popping the return address previously pushed by the CALL instruction. Make sure the SP is balanced before calling RET otherwise the instruction pointer will have an ambiguous value. RET Stack instructions PUSH - Push to stack Pushes a value to the stack. The stack grows down and the current position is available in the stack pointer register (SP). This instruction will decrease the SP. PUSH reg PUSH address PUSH constant POP - Pop from stack Pops a value from the stack to a register. This instruction will increase the SP. POP reg Other instructions HLT - Stops the processor. Stops operation of the processor. Hit Reset button to reset IP before restarting. HLT

5 od 5 17. 12. 2017 23:53 by Marco Schweighauser (2015) MIT License Blog (https://www.mschweighauser.com/make-your-own-assembler-simulator-injavascript-part1/)