ELEC 242 Using Library Procedures

Size: px
Start display at page:

Download "ELEC 242 Using Library Procedures"

Transcription

1 ELEC 242 Using Library Procedures There are a number of existing procedures that are already written for you that you will use in your programs. In order to use the library procedures that come with the text, you must install the example programs that come on the CD-ROM, or download the library from the authors web site at You will need to unzip the file to your work disk and directory. The name of the file is irvine.lib. You can use the Windows find file to locate exactly where Irvine.lib is located on your hard drive. In order to use the procedures in this library, the library file must be on your data disk in the same directory as your asm and obj files. You should copy the file from your hard drive to your data directory (the root directory on the 3 ½ inch Floppy.) The files indicated by the EXTRN directive are accessed by the linker. To use a procedure in the library, we must identify the procedure name in the area of our source code file. The EXTRN directive should be laced in the code segment of our source code file immediately after the directive. In order to link to an external library file, you must name the library in the command line. The figure below shows that the Link Library is input to LINK.EXE just as the obj file. Therefore, when we invoke ML, we must identify the library. In addition, The modified ml command line is: ml /Fl irvine.lib filename.asm To make this easier, you may wish to create a batch file called go.bat. It would have one command in the file: ml /Fl irvine.lib %1.asm To assemble and link a file called lab07.asm using the batch file go.bat, go to the system prompt and enter the command: go lab07 where lab07 is the name of the asm file that you created. The command is entered without the extension. We can use this batch file even if we are not using a procedure in the library. We could identify a library in the command line even if there are no EXTRN directives in our asm file. In this case, nothing needs to be accessed form the library, so no error or warning will be generated. However, if we have an EXTRN directive and no library is accessed from the command line, error messages may be generated. This is accomplished by placing the name of the external procedures that we wish to use in the code segment, preferably immediately after the or directive. The procedures that we wish to use are identified as ProcName:proc where ProcName is the external procedure name. If more than one external procedure is required, each is comma delimited. If many procs are being used, we may continue on the next line by placing a, \ at the of the current line. (If you forget the comma before the \ you will receive an error message from the assembler). The line with the EXTRN directive would be similar to the following: Extrn Proc1Name: proc, Proc2Name: proc, \ Proc3Name: proc, Proc3Name: proc Page 1

2 ELEC 242 Using Library Procedures - writestring WriteString is a procedure that allows you to easily s a string of data stored in a null terminated array to the display. We performed a similar task already using Function 9 INT 21H with our Hello World program. Function 9 requires a string array terminated by $. To use the WriteString library procedure, we must create an null terminated (the last character of the array is,0) array of characters that provide the message. The program requirements are: A null terminated string must exist in the data segment. The base address of the null terminated string data must be placed in DX. The string (without the 0) is present on Standard Output (the display) To use WriteString, we might enter the following in the segment: cr equ 0dh lf equ 0ah greet db cr,lf, Welcome to Brookdale Community College. db cr, lf, 0 WriteString is an external procedure that exists in irvine.lib. We must identify the name of the procedure in irvine.lib that we wish to use. TITLE Program Hello World by Andrew H. Andersen, Jr. PAGE 60,80 ; Brookdale Community College.model small.stack 2000H cr equ 0dh lf equ 0ah greet db cr,lf, "Hello world",cr,lf,lf,0 done equ 04c00H extrn WriteString: proc ; This code uses a procedure in irvine.lib to display a message lea dx,greet ;or mov dx,offset greet ;an external procedure fini: mov ax,done int 21h Page 2

3 ELEC 242 Using Library Procedures - WriteInt WriteInt WriteInt is another procedure that has been written for you and is part of irvine.lib. WriteInt is a procedure that allows you to easily write unsigned, 16-bit integer data to the standard output in ASCII. This means that the range of values are 0 through The data may be written binary, octal, decimal, or hexadecimal format. This procedure will perform the conversion to the desired number base, convert each digit to ASCII, and s the character to the console output. The 16-bit unsigned integer data must be in AX. Numeric value range is 0 to The radix for the format of the desired numeric display format must be in BX. The radix is entered as 2,8,10,16. Any other data in BX is invalid. The numeric data is present on the display in the specified number base. To use a procedure in the library, we must identify the procedure name in the area of our source code file. The EXTRN directive should be laced in the code segment of our source code file immediately after the directive. The beginning of the code segment is similar to the following: extrn Writeint:proc ; The general setup for WriteInt with 16-bit data is: mov ax,num ;put data value in AX mov bx,10 ;put desired numeric format in bx call WriteInt ;call the procedure WriteInt Notice that this requires a single piece data to be in a word-sized data storage buffer called data. For byte-sized data, the program would have to be modified as follows: xor ax,ax ;Clear the AX register (we need AH to be 0) mov al,data ;put byte value in AL ; since ah is 0, we have a proper 16-bit value mov bx,10 ;put desired numeric format in bx call WriteInt ;call the procedure WriteInt The proceeding is fine for single value of data. Suppose we wish to write an array of 16-bit unsigned integers. We would need to use word pointer to the array, and a loop counter that is incremented by 2, and a word pointer. The following is an example of a procedure with its required data segment to use WriteInt to display word-sized unsigned integers from an array called values with nvals as the number of entries in array. array dw 24 dup (1) ;init to all 1's nvals equ (($-array)/2) ;($-array)/2 since there are 2 bytes/value ; The previous statement automatically calculates ; the number of elements in the array Page 3

4 ELEC 242 Using Library Procedures - WriteInt extrn Writeint: proc, Crlf: proc ;call to library procedure ; some stuff may be here ; Assume it fills an array with word-size integer data. ; We will use nested procedures to Call ShowIt to walk the array ; and call a library procedure Writeint ; to s the value to the display ; and another procedure Blank to move the cursor to a new line lea si,array ;load SI as an address pointer to values mov cx,nvals ;initialize the loop counter mov bx,10 ;load the number base to display again: mov ax,word ptr [si] ; Get value from the array using word ptr call Writeint ; use a library function to show the value call crlf ;only if you wish to place each ; value on a separate line add si,2 ;Increment address pointer by 2 loop again ;Continue to again until CX is 0 mov ax,4c00h ;normal MS-DOS exit int 21H To write multiple numbers on the same line, modify the code to the following: array dw 24 dup (1) ; init to all 1's nvals equ (($-array)/2) ;($-array)/2 since there are 2 bytes/value blank db,0 ; or replace the single space in the quotes ; with 20h,0 extrn Writeint: proc, Crlf: proc, WriteString: proc ; some stuff may be here lea dx, blank lea si,array ;load SI as an address pointer to values mov cx,nvals ;initialize the loop counter mov bx,10 ;load the number base to display Page 4

5 ELEC 242 Using Library Procedures - WriteInt again: mov ax,word ptr [si] ; Get value from the array using word ptr call Writeint ; use a library function to show the value ; to print 1 space between values add si,2 ; Increment address pointer by 2 loop again ; Continue to again until CX is 0 mov ax,4c00h ; normal MS-DOS exit int 21H Page 5

6 ELEC 242 Using Library Procedures - ReadInt ReadInt ReadInt is the fourth procedure that we will discuss and is part of irvine.lib. ReadInt is a procedure that allows the user enter a signed, 16-bit binary integer in ASCII from Standard Input (the keyboard). Since this requires user input, you should print a prompt (a message that tells the user what to do) to Standard Output You should print an appropriate prompt on the display If AX contains data that you will need later, save it in Storage or on the Stack The 16-bit signed binary integer data is returned in AX. indata dw 24 dup (1) ;init to all 1's nvals equ (($-indata)/2) ;we used ($-array)/2 since there are 2 bytes/value prompt db Enter a number ==>,0 greet db You will have to enter 24 numbers., 0 The beginning of the code segment is similar to the following: extrn Readint:proc, WriteString:proc, crlf:proc ;The general setup for ReadInt is: lea dx,greet ;or mov dx,offset greet call Crlf lea dx,prompt ;or mov dx,offset greet push ax ;only if it contains useful data mov si,offset indata ;point to address of word size data mov cx, nvals ;load loop counter with number of words more: ;an external procedure to display prompt call ReadInt ;get the number call Crlf ;go to next line mov word ptr [si],ax ;put in array add si,2 ;increment 1 word loop more ;until cx = 0 pop ax ;get ax back ;do whatever has to be done here mov ax,4c00h ;normal MS-DOS exit int 21H Page 6

7 ELEC 242 Using Library Procedures - ReadString ReadString ReadString reads a string of characters from Standard Input and stores it as a null terminated string. This is the reverse of WriteString. We need to perform a number of steps to use this procedure. 1. We need to setup storage in memory (RAM) for the input data. Since the string is null terminated, make the array 1 byte larger than the number of characters you wish to store. 2. We need to define the size of the storage area. 3. Since the user must do something, provide a prompt to tell them what to do. You should print an appropriate prompt on the display telling the user what to do. You must have storage setup that is one byte larger than the number of characters Initialize DX to the base address of the string. Initialize CX to the maximum number of characters to accept AX contains the number of characters entered from Standard Input. The String is written to RAM. Your_Name db 26 dup (?) ;init to all 1's Num_Char equ $-indata-1 ;we use $-array-1 since we need an extra byte for the null prompt db Enter your name ==>,0 result db Your name has,0 nextmsg db characters.,0 The code segment is similar to the following: extrn WriteString: proc, ReadString: proc, \ WriteInt: proc, ReadInt: proc mov mov ax,@data ds,ax lea dx, prompt lea dx, Your_Name mov cx, Num_Char call ReadString lea dx, result mov bx,10 call Writeint lea dx, Nextmsg mov ah,4ch int 21h Page 7

Experiment 3 3 Basic Input Output

Experiment 3 3 Basic Input Output Experiment 3 3 Basic Input Output Introduction The aim of this experiment is to introduce the use of input/output through the DOS interrupt. Objectives: INT Instruction Keyboard access using DOS function

More information

INTRODUCTION. NOTE Some symbols used in this manual CL = Click Left CR = Click Right DCL = Double Click Left = Enter. Page 1

INTRODUCTION. NOTE Some symbols used in this manual CL = Click Left CR = Click Right DCL = Double Click Left = Enter. Page 1 INTRODUCTION OBJECTIVE The purpose of this manual is to provide the student with practical experience in the writing of assembly language programs, and give them background and instructions on how to use

More information

Experiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics

Experiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics Experiment #5 Using BIOS Services and DOS functions Part 1: Text-based Graphics 5.0 Objectives: The objective of this experiment is to introduce BIOS and DOS interrupt service routines to be utilized in

More information

Experiment N o 3 Segmentation and Addressing Modes

Experiment N o 3 Segmentation and Addressing Modes Introduction: Experiment N o 3 Segmentation and Addressing Modes In this experiment you will be introduced to physical segmentation of the memory, and the logical segmentation of programs. You will also

More information

Experiment N o 3. Segmentation and Addressing Modes

Experiment N o 3. Segmentation and Addressing Modes Introduction: Experiment N o 3 Segmentation and Addressing Modes In this experiment you will be introduced to physical segmentation of the memory, and the logical segmentation of programs. You will also

More information

The statement above assumes that the PCMAC.INC file is in the current directory. The full path of the file can also be given:

The statement above assumes that the PCMAC.INC file is in the current directory. The full path of the file can also be given: MACROS for I/O As you have probably noticed, writing DOS calls can become tedious. Much of the code is repetitive, and each call has its own function code and register usage. You are probably used to dealing

More information

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 Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 6 Input/output using a Library of Procedures April, 2014 1 Assembly Language LAB Using

More information

Lab 5: Input/Output using a Library of Procedures

Lab 5: Input/Output using a Library of Procedures COE 205 Lab Manual Lab 5: Input/Output using a Library of Procedures - Page 46 Lab 5: Input/Output using a Library of Procedures Contents 5.1. Using an External Library of Procedures for Input and Output

More information

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000 Declaring Variables in Assembly Language As in Java, variables must be declared before they can be used Unlike Java, we do not specify a variable type in the declaration in assembly language Instead we

More information

Lab 3: Defining Data and Symbolic Constants

Lab 3: Defining Data and Symbolic Constants COE 205 Lab Manual Lab 3: Defining Data and Symbolic Constants - page 25 Lab 3: Defining Data and Symbolic Constants Contents 3.1. MASM Data Types 3.2. Defining Integer Data 3.3. Watching Variables using

More information

EXPERIMENT TWELVE: USING DISK FILES

EXPERIMENT TWELVE: USING DISK FILES EXPERIMENT TWELVE: USING DISK FILES INTRODUCTION Because just about any program ever written requires the use of a disk file to store or retrieve data, this experiment shows how to create, read, write,

More information

Summer 2003 Lecture 15 07/03/03

Summer 2003 Lecture 15 07/03/03 Summer 2003 Lecture 15 07/03/03 Initialization of Variables In the C (or C++) programming language any variable definition can have an optional initializer for the variable. How and when the initialization

More information

EEM336 Microprocessors I. Data Movement Instructions

EEM336 Microprocessors I. Data Movement Instructions EEM336 Microprocessors I Data Movement Instructions Introduction This chapter concentrates on common data movement instructions. 2 Chapter Objectives Upon completion of this chapter, you will be able to:

More information

UNIT 4. Modular Programming

UNIT 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 information

Constants and. Lecture 7: Assembly Language Programs. Expressions (cont.) Constants and. Statements. Expressions

Constants and. Lecture 7: Assembly Language Programs. Expressions (cont.) Constants and. Statements. Expressions Lecture 7: Assembly Language Programs Basic elements of assembly language Assembler directives Data allocation directives Data movement instructions Assembling, linking, and debugging Using TASM Constants

More information

Experiment N o 1. Introduction to Assembly Language Programming

Experiment N o 1. Introduction to Assembly Language Programming Experiment N o 1 Introduction to Assembly Language Programming Introduction: The aim of this experiment is to introduce the student to assembly language programming, and the use of the tools that he will

More information

Constants and Expressions. Lecture 7: Assembly Language Programs. Constants and Expressions (cont.) Statements. Names. Assembly Directives

Constants and Expressions. Lecture 7: Assembly Language Programs. Constants and Expressions (cont.) Statements. Names. Assembly Directives Lecture 7: Assembly Language Programs Basic elements of assembly language Assembler directives Data allocation directives Data movement instructions Assembling, linking, and debugging Using TASM Constants

More information

Q. State and Explain steps involved in program development. [w-08, w-10, s-12, w-11]

Q. State and Explain steps involved in program development. [w-08, w-10, s-12, w-11] Q. State and Explain steps involved in program development. [w-08, w-10, s-12, w-11] Answer: 1. Defining Problem 2. Algorithm 3. Flowchart 4. Initialization of checklist 5. Choosing instructions 6. Converting

More information

Experiment #2. Addressing Modes and Data Transfer using TASM

Experiment #2. Addressing Modes and Data Transfer using TASM 2.0 Objective Experiment #2 Addressing Modes and Data Transfer using TASM The objective of this experiment is to learn various addressing modes and to verify the actions of data transfer. 2.1 Introduction

More information

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program. Experiment 3 Introduction: In this experiment the students are exposed to the structure of an assembly language program and the definition of data variables and constants. Objectives: Assembly language

More information

ELEC VIDEO BIOS ROUTINES

ELEC VIDEO BIOS ROUTINES It is less confusing to the user if we remove unnecessary messages from the display before giving information or instructions. At the command prompt, we do this with the DOS command CLS. However, this

More information

Topics Introduction to Microprocessors. Chapter 5 Macros and modules. What is macro? How to use macro? (I) How to use macro?

Topics Introduction to Microprocessors. Chapter 5 Macros and modules. What is macro? How to use macro? (I) How to use macro? Topics 2102440 Introduction to Microprocessors Macros Subroutines Modules Chapter 5 Macros and modules Suree Pumrin,, Ph.D. 1 2102440 Introduction to Microprocessors 2 What is macro? It is used to automate

More information

Experiment N o 1. 1 Introduction to Assembly Language Programming

Experiment N o 1. 1 Introduction to Assembly Language Programming Experiment N o 1 1 Introduction to Assembly Language Programming Introduction: This experiment introduces the student to assembly language programming. In order to illustrate the basic concepts of assembly

More information

Video processing The INT instruction enables program to interrupt its own processing. Use INT instruction to handle inputs and outputs

Video processing The INT instruction enables program to interrupt its own processing. Use INT instruction to handle inputs and outputs Video processing The INT instruction enables program to interrupt its own processing. Use INT instruction to handle inputs and outputs INT 10H: screen handling INT 21H: for displaying screen output and

More information

CSCI516: Program 1 - October 11, 2010 The Program is due: October 25, 2010 in the beginning of the class

CSCI516: Program 1 - October 11, 2010 The Program is due: October 25, 2010 in the beginning of the class CSCI516: Program 1 - October 11, 2010 The Program is due: October 25, 2010 in the beginning of the class For Late Submissions 10 out of 100 points will be taken off. For your first program, you are to

More information

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

db 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 information

Memory Organization. 27 December 2016 Pramod Ghimire. Slide 1 of 21

Memory Organization. 27 December 2016 Pramod Ghimire. Slide 1 of 21 Memory Organization Slide 1 of 21 The assembler uses two basic formats for developing software. One method uses memory models and the other uses fullsegment definitions. MASM uses memory models. The TASM

More information

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures. Chapter Overview. The Book's Link Library

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures. Chapter Overview. The Book's Link Library Assembly Language for Intel-Based Computers, 4 th Edition Kip R Irvine Chapter 5: Procedures Slides prepared by Kip R Irvine Revision date: 10/3/2003 Chapter corrections (Web) Assembly language sources

More information

Week /8086 Microprocessor Programming II

Week /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 information

Experiment 8 8 Subroutine Handling Instructions and Macros

Experiment 8 8 Subroutine Handling Instructions and Macros Introduction Experiment 8 8 Subroutine Handling Instructions and Macros In this experiment you will be introduced to subroutines and how to call them. You will verify the exchange of data between a main

More information

Libraries and Procedures

Libraries and Procedures Computer Organization and Assembly Language Computer Engineering Department Chapter 5 Libraries and Procedures Presentation Outline Link Library Overview The Book's Link Library Runtime Stack and Stack

More information

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition

More information

ORG ; TWO. Assembly Language Programming

ORG ; TWO. Assembly Language Programming Dec 2 Hex 2 Bin 00000010 ORG ; TWO Assembly Language Programming OBJECTIVES this chapter enables the student to: Explain the difference between Assembly language instructions and pseudo-instructions. Identify

More information

Lab 2: Introduction to Assembly Language Programming

Lab 2: Introduction to Assembly Language Programming COE 205 Lab Manual Lab 2: Introduction to Assembly Language Programming - page 16 Lab 2: Introduction to Assembly Language Programming Contents 2.1. Intel IA-32 Processor Architecture 2.2. Basic Program

More information

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

Marking 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 information

Chapter 3: Addressing Modes

Chapter 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 information

Lecture (06) x86 programming 5

Lecture (06) x86 programming 5 Lecture (06) x86 programming 5 By: Dr. Ahmed ElShafee 1 TOC Format of DOS programs Format of the.com programs Addressing Modes 1> Immediate Addressing Mode 2> Register Addressing Mode 3> Direct Addressing

More information

Programming in Module. Near Call

Programming in Module. Near Call Programming in Module Main: sub1: call sub1 sub ax,ax sub1 sub1 proc near sub ax,ax endp sub1 sub1 proc Far sub ax,ax endp Near Call sub1 sub1 Main: call sub1 sub1: sub ax,ax proc near sub ax,ax endp SP

More information

Lecture 13: I/O I/O. Interrupts. How?

Lecture 13: I/O I/O. Interrupts. How? Lecture 13: I/O I/O Interrupts MS-DOS Function Calls Input,Output, File I/O Video Keyboard Getting data into your program: define it in the data area use immediate operands Very limiting Most programs

More information

Lecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET

Lecture 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 information

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut dthiebaut@smith.edu Homework Solutions Outline Review Hexdump Pentium Data Registers 32-bit, 16-bit and 8-bit quantities (registers

More information

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

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات 1) Input/output In computing, input/output or I/O, is the communication between an information processing system (such as a computer) and the outside world, possibly a human or another information processing

More information

EXPERIMENT NINE DEVELOPING MACRO SEQUENCES

EXPERIMENT NINE DEVELOPING MACRO SEQUENCES EXPERIMENT NINE DEVELOPING MACRO SEQUENCES INTRODUCTION Although not essential to programming, macro sequences relieve the programmer of retyping the same instructions and also allow additional instructions

More information

.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]

.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 information

COE 205 Lab Manual Experiment N o 12. Experiment N o Using the Mouse

COE 205 Lab Manual Experiment N o 12. Experiment N o Using the Mouse Experiment N o 12 12 Using the Mouse Introduction The mouse is an I/O device that replaces the arrow keys on the keyboard for graphical and text style programs. This experiment shows how to add the mouse

More information

Assembly Language: g Part III. First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Assembly Language: g Part III. First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University System Programming with Assembly Language: g Part III First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University Outline A Few Basic Instructions Translation of high Level

More information

Transfer of Control. Lecture 10 JMP. JMP Formats. Jump Loop Homework 3 Outputting prompts Reading single characters

Transfer of Control. Lecture 10 JMP. JMP Formats. Jump Loop Homework 3 Outputting prompts Reading single characters Lecture 10 Jump Loop Homework 3 Outputting prompts Reading single characters Transfer of Control The CPU loads and executes programs sequentially. You d like to be able to implement if statements, gotos,

More information

Assembly Language LAB

Assembly Language LAB Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Created by: Eng. Ahmed M. Ayash Modified and Presented By: Eihab

More information

Basic Assembly SYSC-3006

Basic 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 information

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 3: Assembly Language Fundamentals (c) Pearson Education, 2002. Chapter Overview Basic Elements of Assembly Language Example:

More information

Assembly Language for Intel-Based Computers, 4 th Edition

Assembly Language for Intel-Based Computers, 4 th Edition Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 5: Procedures Lecture 18 Linking to External Library The Book s Link Library Stack Operations Slides prepared by Kip R. Irvine

More information

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

SPRING 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 information

BLDEA S V.P. DR. P.G. HALAKATTI COLLEGE OF ENGINEERING & TECHNOLOGY, VIJAYAPURA

BLDEA S V.P. DR. P.G. HALAKATTI COLLEGE OF ENGINEERING & TECHNOLOGY, VIJAYAPURA EXPERIMENT NO.:- 1. BINARY SEARCH Work Space: Register Used Memory Address Data DI 10000H 11H 10001H 11H 10002H 22H 10003H 22H BX 10004H 33H 10005H 33H 10006H 44H 10007H 44H CX 10008H 55H 10009H 55H 24

More information

The Stack. Lecture 15: The Stack. The Stack. Adding Elements. What is it? What is it used for?

The Stack. Lecture 15: The Stack. The Stack. Adding Elements. What is it? What is it used for? Lecture 15: The Stack The Stack What is it? What is it used for? A special memory buffer (outside the CPU) used as a temporary holding area for addresses and data The stack is in the stack segment. The

More information

UNIVERSITY OF CALIFORNIA, RIVERSIDE

UNIVERSITY OF CALIFORNIA, RIVERSIDE Final Page 1 of 7 UNIVERSITY OF CALIFORNIA, RIVERSIDE Computer Science Department CS61 Machine Organization & Assembly Language Final September 1, 2000 53 Name: Solution Key Student ID#: Please print legibly

More information

Libraries and Procedures

Libraries and Procedures Libraries and Procedures COE 205 Computer Organization and Assembly Language Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Link Library Overview The

More information

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

We 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 information

8086 ALP TOOLS (CH 2) CHAPTER 2

8086 ALP TOOLS (CH 2) CHAPTER 2 1 CHAPTER 2 In this chapter, we shall discuss the Assembly Language Program development tools, PC memory structure and Assembler directives. Books to be Referred: 1. Microprocessors and Interfacing 2nd

More information

EE 314 Spring 2003 Microprocessor Systems

EE 314 Spring 2003 Microprocessor Systems EE 314 Spring 2003 Microprocessor Systems Laboratory Project #3 Arithmetic and Subroutines Overview and Introduction Review the information in your textbook (pp. 115-118) on ASCII and BCD arithmetic. This

More information

Objectives. Saving Interrupt Vectors. Writing a Custom Interrupt Handler. Examples of use of System functions for Input-Output and Interrupts

Objectives. Saving Interrupt Vectors. Writing a Custom Interrupt Handler. Examples of use of System functions for Input-Output and Interrupts ICT106 Fundamentals of Computer Systems Week 11 Practical Examples of use of System functions for Input-Output and Interrupts Objectives To illustrate how to write interrupt service routine (ISR) for Intel

More information

By: Dalbir Singh, Computer Science Dep't

By: Dalbir Singh, Computer Science Dep't Assembly language is essentially the native language of your computer. Technically the processor of your machine understands machine code (consisting of ones and zeroes). But in order to write such a machine

More information

Assembly Language Fundamentals. Chapter 3

Assembly Language Fundamentals. Chapter 3 Assembly Language Fundamentals Chapter 3 1 Numeric Constants 2 Numeric constants are made of numerical digits with, possibly, a sign and a suffix. Ex: -23 (a negative integer, base 10 is default) 1011b

More information

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Marking 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 information

CSE 505 Lecture 8: Introduction to Assembly Language

CSE 505 Lecture 8: Introduction to Assembly Language Page1 Advantages of Assembly Language Low-level access to the computer Higher speed Total control over CPU (Must know what you are doing in order to make these advantages work) Disadvantages of assembly

More information

Ethical Hacking. Assembly Language Tutorial

Ethical Hacking. Assembly Language Tutorial Ethical Hacking Assembly Language Tutorial Number Systems Memory in a computer consists of numbers Computer memory does not store these numbers in decimal (base 10) Because it greatly simplifies the hardware,

More information

16-bit MS-DOS and BIOS Programming

16-bit MS-DOS and BIOS Programming CS2422 Assem bly Language and System Programming 16-bit MS-DOS and BIOS Programming Department of Computer Science National Tsing Hua University Overview Chapter 13: 16-bit MS-DOS Programming MS-DOS and

More information

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad Introduction to MS-DOS Debugger DEBUG In this laboratory, we will use DEBUG program and learn how to: 1. Examine and modify the contents of the 8086 s internal registers, and dedicated parts of the memory

More information

EC 333 Microprocessor and Interfacing Techniques (3+1)

EC 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 information

Q1: Define a character string named CO_NAME containing "Internet Services" as a constant?

Q1: Define a character string named CO_NAME containing Internet Services as a constant? CS 321 Lab Model Answers ١ First Lab : Q1: Define a character string named CO_NAME containing "Internet Services" as a constant? ANS: CO_NAME EQU ' Internet Services' Q2: Define the following numeric values

More information

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil Microprocessor By Mrs. R.P.Chaudhari Mrs.P.S.Patil Chapter 1 Basics of Microprocessor CO-Draw Architecture Of 8085 Salient Features of 8085 It is a 8 bit microprocessor. It is manufactured with N-MOS technology.

More information

The registers(di,si) are automatically incremented or decremented depending on the value of the direction flag:

The registers(di,si) are automatically incremented or decremented depending on the value of the direction flag: String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures being accessed or manipulated. The operation

More information

CPU. IBM PC and compatible Memory Structure

CPU. IBM PC and compatible Memory Structure CPU The CPU is usually organised in three parts: The Arithmetic and Logic Unit or ALU (which performs computations and comparisons) and the Control Unit which fetches information from and stores information

More information

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 5: Procedures Slides prepared by the author Revision date: June 4, 2006 (c) Pearson Education, 2002. All rights reserved.

More information

ELEC 242 Time Delay Procedure

ELEC 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 information

COE 205: Computer Organization & Assembly Language Introductory Experiment-B By Louai Al-Awami

COE 205: Computer Organization & Assembly Language Introductory Experiment-B By Louai Al-Awami COE 205: Computer Organization & Assembly Language Introductory Experiment-B By Louai Al-Awami Introduction A computer system consists mainly of three components: a Central Processing Unit (CPU), a memory

More information

COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh Libraries i and Procedures COE 205 Computer Organization and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted from

More information

Computer Architecture and System Software Lecture 07: Assembly Language Programming

Computer Architecture and System Software Lecture 07: Assembly Language Programming Computer Architecture and System Software Lecture 07: Assembly Language Programming Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements New assembly examples uploaded to

More information

LABORATORY WORK NO. 8 WORKING WITH MACROS AND LIBRARIES

LABORATORY WORK NO. 8 WORKING WITH MACROS AND LIBRARIES LABORATORY WORK NO. 8 WORKING WITH MACROS AND LIBRARIES 1. Object of laboratory Getting used to defining and using macros, procedure defining and using LIB library librarian. 2. Theoretical considerations

More information

5. Using Signed Numbers and Look-up Tables

5. Using Signed Numbers and Look-up Tables 5. Using Signed Numbers and Look-up Tables Macro Library for BIOS and DOS Services (save as exp5.inc) ; ASCII code for carriage return CR equ 0Dh ; ASCII code for line feed LF equ 0Ah al2asc macro buffer

More information

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals.

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals. Assembly Language for Intel-Based Computers, 4 th Edition Chapter 3: Assembly Language Fundamentals Slides prepared by Kip R. Irvine Revision date: 09/15/2002 Kip R. Irvine Chapter Overview Basic Elements

More information

Assembly Fundamentals

Assembly Fundamentals Chapter Overview Assembly Fundamentals Basic Elements of Assembly Language Example: Adding and Subtracting Integers Assembling, Linking, and Running Programs Defining Data Symbolic Constants Computer Organization

More information

Section 1: C Programming Lab

Section 1: C Programming Lab Course Code : MCSL-017 Course Title : C and Assembly Language Programming (Lab Course) Assignment Number : MCA(1)/015/Assignment/17-18 Maximum Marks : 100 Weightage : 25% Last Dates for Submission : 15th

More information

CS-202 Microprocessor and Assembly Language

CS-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 information

Assignment 3. Problem Definition:

Assignment 3. Problem Definition: Att (2) Perm(5) Oral(3) Total(10) Sign with Date Assignment 3 Problem Definition: Write x86 ALP to convert 4-digit Hex number into its equivalent BCD number and 4-digit BCD number into its equivalent HEX

More information

EEL 3801 Introduction to Computer Engineering Summer Home Work Schedule

EEL 3801 Introduction to Computer Engineering Summer Home Work Schedule EEL 3801 Introduction to Computer Engineering Summer 2005 Home Work Schedule Schedule of Assignments: Week HW# Due Points Title 1 07/05/05 3% Memory dump in assembly 2 07/19/05 3% Solve a Maze 3 08/02/05

More information

Macros. Introducing Macros Defining Macros Invoking Macros Macro Examples Nested Macros Example Program: Wrappers

Macros. Introducing Macros Defining Macros Invoking Macros Macro Examples Nested Macros Example Program: Wrappers Macros Introducing Macros Defining Macros Invoking Macros Macro Examples Nested Macros Example Program: Wrappers Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. 1 Introducing Macros A

More information

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 1: Assembly Language Terms & Directives

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 1: Assembly Language Terms & Directives Introduction: US06CCSC04: Introduction to Microprocessors and A microprocessor is the chip containing some control and logic circuits that is capable of a making arithmetic and logical decision based on

More information

Unit 5 DOS INTERRPUTS

Unit 5 DOS INTERRPUTS Unit 5 DOS INTERRPUTS 5.1 Introduction The DOS (Disk Operating System) provides a large number of procedures to access devices, files and memory. These procedures can be called in any user program using

More information

Assembly Language Each statement in an assembly language program consists of four parts or fields.

Assembly 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 information

Midterm Exam #2 Answer Key

Midterm Exam #2 Answer Key Midterm Exam #2 Answer Key Name: Student ID #: I have read and understand Washington State University s policy on academic dishonesty and cheating YOU Signed: Problem 1) Consider the following fragment

More information

COMPUTER ENGINEERING DEPARTMENT

COMPUTER 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 information

Intel 8086: Instruction Set

Intel 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 information

LABORATORY 8: USING BIOS ROUTINES FOR KEYBOARD INPUT AND DISPLAY OUTPUT

LABORATORY 8: USING BIOS ROUTINES FOR KEYBOARD INPUT AND DISPLAY OUTPUT LABORATORY 8: USING BIOS ROUTINES FOR KEYBOARD INPUT AND DISPLAY OUTPUT NAME: STUDENT ID#: Objectives Learn how to: Use the read keyboard and display character BIOS routines. Display prompt messages on

More information

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language The x86 Microprocessors Introduction 1.1 Assembly Language Numbering and Coding Systems Human beings use the decimal system (base 10) Decimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Computer systems use the

More information

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 10 Advanced Procedures May, 2014 1 Assembly Language LAB Stack Parameters There are

More information

Assembler Programming. Lecture 10

Assembler Programming. Lecture 10 Assembler Programming Lecture 10 Lecture 10 Mixed language programming. C and Basic to MASM Interface. Mixed language programming Combine Basic, C, Pascal with assembler. Call MASM routines from HLL program.

More information

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 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 information

3: 4: 5: 9: ',0 10: ',0 11: ',0 12: 13:.CODE 14: INCLUDE

3: 4: 5: 9: ',0 10: ',0 11: ',0 12: 13:.CODE 14: INCLUDE 1: TITLE Parameter passing via registers PROCEX1.ASM 2: COMMENT 3: Objective: To show parameter passing via registers 4: Input: Requests two integers from the user. 5: Output: Outputs the sum of the input

More information

INT 21H and INT 10H Programming and Macros

INT 21H and INT 10H Programming and Macros Dec Hex Bin 4 4 00000100 ORG ; FOUR INT 21H and INT 10H Programming and Macros OBJECTIVES this chapter enables the student to: Use INT 10H function calls to: Clear the screen. Set the cursor position.

More information

Assembly Language Lab #5

Assembly Language Lab #5 Islamic University of Gaza Computer Engineering Department 2009 Assembly Language Lab #5 Eng. Tahani Z. Fourah Islamic University of Gaza Lab 5 Addressing Modes The addressing modes are different ways

More information