1 Computer Architecture & Assembly Language Spring 2001 Dr. Richard Spillman Lecture 10 –Assembly V.

Slides:



Advertisements
Similar presentations
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Advertisements

CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
CS 61C L14Introduction to MIPS: Instruction Representation II (1) Garcia, Spring 2004 © UCB Roy Wang inst.eecs.berkeley.edu/~cs61c-tf inst.eecs.berkeley.edu/~cs61c.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Computer Architecture and Design – ECEN 350 Part 4 [Some slides adapted from M. Irwin, D. Paterson and others]
An Introduction to 8086 Microprocessor.
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
MIPS coding. SPIM Some links can be found such as:
Objective At the conclusion of this chapter you will be able to:
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /29/2013 Lecture 13: Compile-Link-Load Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Assembly Language programming
Microprocessor Fundamentals Week 2 Mount Druitt College of TAFE Dept. Electrical Engineering 2008.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Lecture 3 Translation.
Computer Architecture & Operations I
Assembly language.
Format of Assembly language
Microprocessor and Assembly Language
Assembly Language programming
System Programming and administration
Introduction to 8086 Microprocessor
The University of Adelaide, School of Computer Science
Computer Organization & Assembly Language Chapter 3
Additional Assembly Programming Concepts
16.317: Microprocessor System Design I
Microprocessor and Assembly Language
Chapter 4 Data Movement Instructions
EE3541 Introduction to Microprocessors
William Stallings Computer Organization and Architecture 8th Edition
Intel 8088 (8086) Microprocessor Structure
(The Stack and Procedures)
Chapter 3 Addressing Modes
Computer Science 210 Computer Organization
Symbolic Instruction and Addressing
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
The Assembly Language Level
Computer Science 210 Computer Organization
Chapter 4 Data Movement Instructions
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
CSCE Fall 2013 Prof. Jennifer L. Welch.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CSCE 121: Simple Computer Model Spring 2015
(The Stack and Procedures)
by Richard P. Paul, 2nd edition, 2000.
Symbolic Instruction and Addressing
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Computer Architecture
CSCE Fall 2012 Prof. Jennifer L. Welch.
Microprocessor and Assembly Language
Unit-I 80386DX Architecture
COMP 1321 Digital Infrastructure
Chapter 6 –Symbolic Instruction and Addressing
Process.
(The Stack and Procedures)
Computer Operation 6/22/2019.
Computer Architecture and System Programming Laboratory
Procedures & Macros Introduction Syntax Difference.
Presentation transcript:

1 Computer Architecture & Assembly Language Spring 2001 Dr. Richard Spillman Lecture 10 –Assembly V

2 Semester Topics PLU 1 Assembly Language CPU Disk Memory I/O ALU Assembly Microprogramming Alternatives Cache Virtual Structure Operation Network

3 Review – Last Lecture More on DOS Calls BIOS Calls Conditional Statements

4 Outline Macros Additional Instructions Running a Program Intro to Pentium Systems It’s too much my circuits hurt

5 Macros A macro is a set of assembly language statements given a symbolic name. After being defined, the assembler will substitute those statements whenever it finds the symbolic name. MASM = Macro Assembler

6 Example Define macros to input and print a character ; Input a character into al mInputChar macro mov ah, 1 int 21h endm ; print character in dl mPutChar macro mov ah, 2 int 21h endm

7 Macro Assembly Then writing mInputChar mov dl, al mPutChar results in the code mov ah, 1 int 21h mov dl, al mov ah, 2 int 21h Observe the text substitution

8 Macro Parameters Macros can have parameters. The text for the actual parameter is substituted for the name of the dummy parameter when the macro is invoked. §mInputChar macro aChar push ax mov ah, 1 int 21h mov aChar, al pop ax endm

9 Example mInputChar bl mInputChar aCh expands to push ax mov ah, 1 int 21h mov bl, al pop ax push ax mov ah, 1 int 21h mov aCh, al pop ax

10 Macros vs Procedures Similarities: Both Simplify program writing Encourage reuse of code Improve program readability Provide better structure to programs

11 Differences Macro 1. Can be used for any kind of code even data decl. Procedure 1. Can only be used for executable code. 5. Use does not change execution speed 5. Use decreases execution speed 4. No extra instructions 4. Needs CALL and RET 3. Use or non-use does not change code length 3. Longer procedures shorten code if used repeatedly 2. Expanded code appears in.EXE each time used 2. Generated code only appears once in.EXE

12 Additional Instructions There are over 100 instructions in the Intel assembly language and we have only consider a few of them Some will be introduced as we study additional architectural issues Some will not be covered and are left to you to research Some will be covered in this lecture

13 XCHG The XCHG instruction swaps (exchanges) the contents of the two operands. This instruction takes the place of THREE MOV instructions. The XCHG instruction can swap Two byte operands. Two word operands. Two doubleword operands. The operands may be Two register operands. One memory operand and one register operand. Note: XCHG can NOT be used to swap The contents of two segment registers. The contents of two memory locations. xchg AX,BX

14 LODSB The LODSB instruction loads a byte from memory into the AL register and increments or decrements SI by one. The source operand is a byte stored in memory at address DS:SI The increment/decrement is determined by the D flag

15 STOSB The STOSB instruction stores AL in memory in the extra segment at the offset given by DI and increments DI by one. The destination operand is memory address ES:SI

16 XLAT XLAT stands for Table Lookup and Translation. This instruction is useful when you have a table of byte codes stored in memory { like seven-segment LED codes} Before the XLAT instruction, you put the index of the code you want into the AL register and the offset address of the table into the BX register. The XLAT instruction reads the desired byte code out of the table and puts it into the AL register.

17 Example GOAL: store the ASCII code for the 16 hex digits in a table so that the code can be accessed using the hex digit as an index Store the table table db ‘ ABCDEF’ Set up registers BX and AL Use XLAT instruction

18 Example (continued) Memory looks like: Find the ASCII code for “A” MOV AL, 0Ah :set AL with the index MOV BX, offset table :BX points to beginning BX XLAT :Lookup the value AL Load AL with 41

19 Running a Program Running a program involves several steps: C++ Compiler Assembly Program Assembler Object Code (Machine Language) Linker Library Executable Code (Machine Language) Loader Memory

20 Assembler Reads and Uses Directives Directives give instructions to the assembler but do not produce machine language instructions.data,... Produce Machine Language Creates Object File

21 Object File Format object file header: size and position of the other pieces of the object file text segment: the machine code data segment: binary representation of the data in the source file relocation information: identifies lines of code that need to be “handled” symbol table: list of this file’s labels and data that can be referenced debugging information

22 Link Editor/Linker Combines several object (.o) files into a single executable (“linking”) Enable Separate Compilation of files Changes to one file do not require recompilation of whole program Windows NT source is >30 M lines of code! And Growing! Called a module Link Editor name from editing the “links” in jump and link instructions

23 Linker Tasks Step 1: Take text segment from each.o file and put them together. Step 2: Take data segment from each.o file, put them together, and concatenate this onto end of text segments. Step 3: Resolve References Go through Relocation Table and handle each entry That is, fill in all absolute addresses

24 Loader Executable files are stored on disk. When one is run, loader’s job is to load it into memory and start it running. In reality, loader is the operating system (OS) loading is one of the OS tasks

25 Loader Tasks I Reads executable file’s header to determine size of text and data segments Creates new address space for program large enough to hold text and data segments, along with a stack segment Copies instructions and data from executable file into the new address space (this may be anywhere in memory)

26 Loader Tasks II Copies arguments passed to the program onto the stack Initializes machine registers Most registers cleared, but stack pointer assigned address of 1st free stack location Jumps to start-up routine that copies program’s arguments from stack to registers and sets the PC If main routine returns, start-up routine terminates program with the exit system call

27 Running Summary Compiler converts a single HLL file into a single assembly language file. Assembler converts what it can to machine language and creates a checklist for the linker (relocation table). This changes each.s file into a.o file. Linker combines several.o files and resolves absolute addresses. Loader loads executable into memory and begins execution

28 Introduction to Pentium Systems The Pentium Pro system is a far cry from the 8086 architecture System busL2 cache Bus Interface Unit L1 instruction cacheL1 data cache Fetch & Decode Unit Dispatch / Execute Unit Retirement Unit Registers Instruction pool / reorder buffer FetchLoadStore

29 Summary Macros Additional Instructions Running a Program Intro to Pentium Systems It wasn’t so bad after all