Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microprocessor Lab CSL1543 0:0:2

Similar presentations


Presentation on theme: "Microprocessor Lab CSL1543 0:0:2"— Presentation transcript:

1 Microprocessor Lab CSL1543 0:0:2
Week 1 : Introduction

2 Steps for Executing an ALP
An assembly language program(ALP) has to be executed after these steps. (a) Creation of the source file. (b) Assembling the source file into object file. (c) Linking the object file to create executable. Department of CSE, MSRIT

3 Steps for Executing an ALP
Creation of the source file: Edit the program using a text editor. MS-DOS includes such an editor. type EDIT at the DOS prompt. Once the DOS editor is open, the program can be typed and saved. It is absolutely necessary that this file be saved with an .ASM extension. Eg: firstprog.ASM This tells the assembler that such a file is an assembly language source program. Department of CSE, MSRIT

4 Steps for Executing an ALP
(b) Assembling the source file into object file: MASM(Microsoft Macro Assembler) is used. To assemble a source file, the following command has to be given (at the DOS prompt). MASM/ZI firstprog.ASM where firstprog is the name of the source file. This command uses the option ZI. There now exists a file named firstprog.OBJ, where firstprog is the name of the source file and .OBJ tells that this is an Object file. Department of CSE, MSRIT

5 Steps for Executing an ALP
(c) Linking the object file to create executable: The last is the linking which is used to create an executable file from the object file. The executable file is the one that can be run. The linking is done by typing (at DOS prompt) LINK/CO firstprog.OBJ where firstprog is the name of the source file. This command uses CO as an option. Department of CSE, MSRIT

6 Steps for Executing an ALP
Now we have an executable file myfile.exe which can be run or executed in any of the following three ways: (i) Directly run the executable file at DOS prompt. (ii) Run the executable file using the debug tool. (iii) Run the executable file using the CV tool. Department of CSE, MSRIT

7 Steps for Executing an ALP
(b) Run the executable file using the debug tool: This method enables to execute the program one instruction at a time. After each instruction has been executed, we can view memory/register contents or continue execution. Type DEBUG firstprog.exe to start. To execute an instruction press F10 key this executes the next instruction and pauses. At the left edge of the screen, you see a > symbol with the cursor blinking next to it. Type the following ?location: where location is either a register name (AX ,BX ,etc) or a memory location that you have defined (VALUE 1 , RESULT etc). will display the memory contents or register data Department of CSE, MSRIT

8 Steps for Executing an ALP
c)Using the CV tool: This tool is the most effective to use while executing the program CV stands for CodeView. Type CV firstprog where firstprog is the name of the source file . This will open the CodeView tool. A listing of source file along with line numbers can be seen. Pressing F1O will execute one instruction at a time (single stepping). A window at the right hand side appears showing the contents of each register as the execution progresses. Pressing the F5 key will run the program all at once till the last instruction. At the bottom a short window appears with the > symbol. Here D commands can be typed to view the memory dump, memory locations and watches etc. For a complete set of commands the help section can be consulted. Department of CSE, MSRIT

9 Steps for Executing an ALP
Department of CSE, MSRIT

10 8086 Register set Department of CSE, MSRIT

11 Assembler Directives .DATA directive This directive is used to define data segment necessary for our program. Data can be of different types like byte, word, double word or quad They can be declared using directives as follows: DB – Define Byte DW – Define Word DD – Define Double Word DQ – Define Quad Word DT – Define Ten Bytes Department of CSE, MSRIT

12 MOV Instruction MOV REG, memory memory, REG REG, REG memory, immediate REG, immediate SREG, memory memory, SREG REG, SREG SREG, REG Copy operand2 to operand1. Algorithm: operand1 = operand2 Ex: Mov AX,BX ;Copy contents of BX to AX Mov si,00h ;load Si with 00h Department of CSE, MSRIT

13 ADD Instruction ADD REG, memory memory, REG REG, REG memory, immediate REG, immediate Algorithm: operand1 = operand1 + operand2 Department of CSE, MSRIT

14 SUB Instruction SUB REG, memory memory, REG REG, REG memory, immediate REG, immediate Algorithm: operand1 = operand1 - operand2 Department of CSE, MSRIT

15 MUL Instruction MUL REG / Memory Unsigned multiply. Multiply the contents of REG/Memory with contents of AL register. Algorithm: When operand is a byte: AX = AL * operand. When operand is a word: (DX: AX) = AX * operand Department of CSE, MSRIT

16 DIV Instruction DIV REG / Memory Unsigned divide. Algorithm:
DIV  REG / Memory Unsigned divide. Algorithm: when operand is a byte: AL = AX / operand AH = remainder (modulus) when operand is a word: AX = (DX AX) / operand DX = remainder (modulus) Department of CSE, MSRIT

17 Program to add 2 16-bit numbers
.MODEL SMALL .DATA N1 DW 0009H N2 DW 0002H RES DW 4 DUP (0) .CODE START: MOV MOV DS, AX MOV AX, N1 MOV BX, N2 MOV DX, 0000H ADD AX, BX JNC LAB1 INC DX LAB1: MOV RES, AX MOV RES+2, DX MOV AH, 04CH INT 21H END START Department of CSE, MSRIT


Download ppt "Microprocessor Lab CSL1543 0:0:2"

Similar presentations


Ads by Google