Chapter 8: Programming the Microprocessor

Slides:



Advertisements
Similar presentations
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
Advertisements

The Assembly Language Level
Chapter 3 Loaders and Linkers
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++
Lab6 – Debug Assembly Language Lab
Chapter 8: Programming the Microprocessor. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. The Intel.
Chapter 12: High-Level Language Interface. Chapter Overview Introduction Inline Assembly Code C calls assembly procedures Assembly calls C procedures.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
The Assembly Language Level
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Protected Mode. Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from.
ICS312 Set 11 Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Assembly Language Level.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
Chapter 2 Software Tools and Assembly Language Syntax.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1.
Microsoft Visual Basic 2005: Reloaded Second Edition
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
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.
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
The Structure of a C++ Program. Outline 1. Separate Compilation 2. The # Preprocessor 3. Declarations and Definitions 4. Organizing Decls & Defs into.
Programming With C.
Objective At the conclusion of this chapter you will be able to:
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
The x86 PC Assembly Language, Design, and Interfacing By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey © 2010, 2003, 2000, 1998 Pearson.
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.
Ass. Prof. Dr Masri Ayob TK 6123 Lecture 13: Assembly Language Level (Level 4)
ICS312 Set 14 MACROS. Macros The program structure is similar to that for procedures. As for procedure names, macro names represent a group of instructions.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
CCSA 221 Programming in C CHAPTER 15 WORKING WITH LARGER PROGRAMS 1 ALHANOUF ALAMR.
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
Assembly Language programming
Introduction to OOP CPS235: Introduction.
Assembly 08. Outline Local Labels Jump Lengths External Libraries Macros 1.
Preocedures A closer look at procedures. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4.
Lecture 3 Translation.
Visit for more Learning Resources
Chapter 5- Assembling , Linking, and Executing Programs
MODULAR PROGRAMMING Many programs are too large to be developed by one person. programs are routinely developed by teams of programmers The linker program.
Programming languages
Assembly Language programming
Chapter 5 Conclusion CIS 61.
Microprocessor and Assembly Language
High-Level Language Interface
Assembler Design Options
MACRO Processors CSCI/CMPE 3334 David Egle.
Assembler, Compiler, Interpreter
and Executing Programs
The Assembly Language Level
CIS16 Application Development Programming with Visual Basic
CSCE Fall 2013 Prof. Jennifer L. Welch.
Assembly Language for Intel-Based Computers
Topics Introduction Hardware and Software How Computers Store Data
INTRODUCTION ABOUT ASSEMBLY
Assembler, Compiler, Interpreter
CSCE Fall 2012 Prof. Jennifer L. Welch.
A programming language
An introduction to systems programming
Procedures & Macros Introduction Syntax Difference.
BASIC SYNTAX OF ASSEMBLY LANGUAGE “HELLO WORLD” PROGRAM.
Presentation transcript:

Chapter 8: Programming the Microprocessor

8–1  MODULAR PROGRAMMING Many programs are too large to be developed by one person. programs are routinely developed by teams of programmers The linker program is provided with Visual Studio so that programming modules can be linked together into a complete program. Linking is also available from the command prompt provided by Windows.

The Assembler and Linker The assembler program converts a symbolic source module (file) into a hexadecimal object file. It is even a part of Visual Studio, located in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin folder. The version that comes with Visual C will not work for 16-bit DOS programs. if a 16-bit assembler and linker are needed, they are in the Windows Driver Development Kit (DDK)

Whenever you create a source file, it should have the extension of ASM. Source files are created by using NotePad or almost any other word processor or editor capable of generating an ASCII file. The linker program, which executes as the second part of ML, reads the object files that are created by the assembler program and links them together into a single execution file. An execution file is created with the file name extension EXE.

Execution files are selected by typing the file name at the DOS prompt (C:\). If a file is short enough (less than 64K bytes long), it can be converted from an execution file to a command file (.COM). The command file is slightly different from an execution file in that the program must be originated at location 0100H before it can execute. This means that the program must be no larger than 64K–100H in length.

ML NEW.ASM / LINK NUMB.LIB Library files are entered after the file name and after the switch / LINK. To use a library called NUMB.LIB while assembling a program called NEW.ASM, type ML NEW.ASM / LINK NUMB.LIB In the Windows environment you cannot link a program—only assemble program. You must use Visual Studio to link the program files during the build. You can assemble a file or files and generate objects for use with Visual C++.

To use a library called NUMB.LIB type C:\masm614\BIN\ml new.asm /LINK NUMB.LIB

Public and Extern Very important to modular programming as they allow communications between modules. PUBLIC declares labels of code, data, or entire segments are available to other program modules EXTRN (external) declares labels are external to a module Without these statements, modules could not be linked together to create a program by using modular programming techniques. modules would communicate with one another

PUBLIC is placed in the opcode field of a statement to define a label as public, so the label can be seen & used by other modules. made public, they combine with other public segments containing data with the same name EXTRN appears in both data and code segments to define labels as external to the segment. if defined as external, sizes must be defined as BYTE, WORD, or DWORD if jump or call address is external, it must be defined as NEAR or FAR

Libraries Libraries allow common procedures to be collected into one place so they can be used by many different applications. assembled and compiled by the LIB program that accompanies the MASM assembler When the library file is linked with a program, only procedures required by are removed from the library file and added to the program. A good set of library files is essential and saves hours in recoding common functions.

Creating a Library File A library file is a collection of assembled .OBJ files that contains procedures or tasks written in assembly language or any other language. The procedure must be declared PUBLIC and does not need to match the file name. A variable is transferred to each file, so the EXTRN statement also appears in each procedure to gain access to an external variable.

The LIB program begins with the copyright message from Microsoft, followed by the prompt Library name. Because this is a new file, the library program must be prompted with the object file name. The LIB program is invoked with the object name following it on the command line. Once a library file is linked to your program, only the library procedures actually used by your program are placed in the execution file.

Macros A group of instructions that perform one task, just as a procedure performs one task. a procedure is accessed via a CALL instruction a macro & all instructions defined in the macro, is inserted in the program at the point of usage Creating a macro is very similar to creating a new opcode Macros execute faster than procedures because there is no CALL or RET instruction to execute.

Macros will not function with the inline assembler only in external assembly language modules MACRO and ENDM directives delineate a macro sequence. MACRO contains the name of the macro and any parameters associated with it Last statement of a macro is the ENDM instruction, which is placed on a line by itself. Never place a label in front of ENDM, the macro will not assemble

Local Variables in a Macro A local variable is one that appears in the macro, but is not available outside the macro. to define use the LOCAL directive The LOCAL directive must always be used on the line immediately following the MACRO statement or an error occurs. The LOCAL statement may have up to 35 labels, all separated with commas.

Placing MACRO Definitions in Their Own Module Macro definitions can be placed in the program file or in their own macro module. a file can be created that contains only macros to be included with other program files Use the INCLUDE directive to indicate a program file will include a module that contains external macro definitions. While not a library file, for practical purposes it functions as a library of macro sequences.

Programs may contain both macro include files and library files. When macro sequences are placed in a file they do not contain PUBLIC statements as does a library. Programs may contain both macro include files and library files. A macro file named MACRO.MAC included in an assembly file using the statement: INCLUDE C:\ASSM\MACRO.MAC No public or extern directives are needed to access macro statements that have been included.