Presentation is loading. Please wait.

Presentation is loading. Please wait.

L AB 2. P ROGRAM STRUCTURE The assembly language program consist of code, data and stack. Data segment: contains all the variable definition..Data Code.

Similar presentations


Presentation on theme: "L AB 2. P ROGRAM STRUCTURE The assembly language program consist of code, data and stack. Data segment: contains all the variable definition..Data Code."— Presentation transcript:

1 L AB 2

2 P ROGRAM STRUCTURE The assembly language program consist of code, data and stack. Data segment: contains all the variable definition..Data Code segment: contains a program’s instructions..code name (name is optional) Stack segment: to set aside a block of memory to store the stack.stack size

3 P ROGRAM STRUCTURE.MODEL SMALL.STACK 100H.DATA ; data definition go here.CODE MAIN PROC ;instruction go here MAIN ENDP ;other procedures go here END MAIN

4 P ROGRAMMING S TEPS Editor.ASM File Assembler Linker.OBJ File.EXE File Create source program Assemble source program Link object program

5 Q4: Complete the following assembly program: This program should load the value 6438h in AX and the value 9BC8h in BX, then add the two registers and store the result in CX. A) Write the assembly program in notepad++ and save it as PGM7.asm

6 Q4:.MODEL SMALL.STACK 100H.CODE MAIN PROC MOV AX, 6438h ; Store 6438h in AX MOVBX, 9BC8h ; Store 9BC8h in BX ADD AX,BX ; Adding AX and BX MOV CX,AX ; Store the result in CX ;DOS Exit MOV AH,4CH INT 21H MAIN ENDP END MAIN

7 Q4: Use the usual steps to run the program, then using the DEBUG program, follow and answer the following: How to use DEBUG : C:\ DEBUG PGM7.EXE 1.Display the register by write command –R 2.What are the content of AX, BX, CX and DX registers at the beginning ? 3.Trace Instructions by typing –T. 4.After each instruction, write down the changes in registers and the values of the flags (refer to the table below). 5.When you reach INT 21h, press: P, after that complete tracing using T command. 6.Finally exit the DEBUG by typing -Q

8 Q4: Display the register by write command –R What are the content of AX, BX, CX and DX registers at the beginning ? Next instruction

9 Q4: Trace Instructions by typing –T. After each instruction, write down the changes in registers and the values of the flags (refer to the table below). Addition result Addition affects on flags 1111 8346 +8CB9 0000

10 FLAGSSYMBOLSET (1)SET (0) OVERFLOW FLAG OFOVNV DIRECTION FLAG DFDNUP INTERRUPT FLAG IFEIDI SIGN FLAG SFNGPL ZERO FLAG ZFZRNZ AUXILIARY FLAG AFACNA PARITY FLAG PFPEPO CARRY FLAG CFCYNC TRAP FLAG TF

11 Q4: When you reach INT 21h, press: P, after that complete tracing using T command. Finally if you want to exit the DEBUG, type :Q


Download ppt "L AB 2. P ROGRAM STRUCTURE The assembly language program consist of code, data and stack. Data segment: contains all the variable definition..Data Code."

Similar presentations


Ads by Google