doc.docx

download doc.docx

of 54

Transcript of doc.docx

Activity No. 1

Debug

Course Code:Cp413L1Program:

Course Title:Computer Systems Organization with Assembly LanguageDate Performed:

Section:Date Submitted:

Name:Instructor:

1. Objective:

This activity aims to demonstrate how Debug can be used as an assembler and disassembler.

2. Intended Learning Outcomes (ILOs):

After completion of this activity the students should be able to:2.1 Examine memory contents2.2 Execute program in Debug2.3 Write short assembly language sequence using Debug

3. Discussion :

The DEBUG program

To create a program in assembler two options exist: the first one is to use an assembler, and the second one is to use the debugger. The debugger that comes with both Windows and DOS is debug.exe or DEBUG program.

The DEBUG program can allow users to:

control and monitor execution of programs interactively display, examine memory contents, and view registers and variables as they change. alter and selectively load COM, EXE and other file types access specific sectors, I/O ports and memory addresses

The Debug CommandsDebug commands are issued at its command prompt, the hyphen(-), either as a single letter, in uppercase or lowercase, or with a combination of parameter.Table 1.1 shows the summary of the Debug commands. The ?can be used to show the long name of each command.

Table 1.1 -The Summary of the Debug Commands

A C D E F G H I L M N O P Q R S T U W ?

Depending on the command, the debug can display an assembly code in either in mnemonic form and machine code form as shown in Table1-2.Table 1.2- Assembly code in mnemonic and machine code formats

Mnemonic formMachine code

MOV AX,0009B80900

ADD [SI],DH0034

INT 21CD21

Once a Debug command has been issued, the key must be pressed so that the command becomes effective.

4. Resources:

Computer with 32-bit Operating SystemDebug.exe

5. Procedure:

Sample Problem A.1. Open Debug.exe. Type the following at the DOS command prompt of your computer: C:/>Debug Note: The BOLDtexts are user inputs and non-Bold texts are computer response.2. Type E at the Debug command prompt ( - ) to place bytes in the memory,- E CS:100 Welcome to Assembly Programming!3. Use the D command to view contents at CS:0100-D 100Describe how your data are stored in the memory of the computer. In what number system are they stored?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________Record all results in Table 1.3.4. Display the contents of a range, type-D 110 11FWhat does it mean by 110 11f in the command?______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________5. Type Q to quit from Debug.- QSample Problem B.1. Open Debug.exe.2. Assemble the following program at address CS:0100. Type the given program, note that in the xxxx in the given is whatever value of the CS ( code segment ) register. -A 100xxxx:0100 mov ah,02 ; use service 02 to display a single characterxxxx:0102 mov dl,49 ; dl register is used to hold the value 49 characterxxxx:0104 int 21 ; interrupt used for service 02xxxx:0106 mov dl,20xxxx:0108 int 21xxxx:010A mov dl,03xxxx:010C int 21xxxx:010E mov dl,20xxxx:0110 int 21xxxx:0112 mov dl,54xxxx:0114 int 21xxxx:0116 mov dl,49xxxx:0118 int 21xxxx:011A mov dl,50xxxx:011C int 21xxxx:011E int 20 ; terminates the programxxxx:0120 [Enter]-

3. Execute the program, type Gat the debug prompt.-G4. Analyze the output and record all results in Table 1.45. Unassemble the program at address 100 to 11e, type U 100 11E6. Observe the output and record all results in Table 1.5.7. Edit the values of address 107 and 10f, type-E CS:107 20.0A-E CS:10F20.0A8. Unassemblethe program at address 100-U 100Observe what happened to the output and record all results in Table 1.6. What changes have you observed in the values of the memory?________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________9. Execute the program. Type, -G10. Save the program as Prog1.com, type-N c:\CompOrg\Prog1.com Note: You should have had created CompOrg directory in C: drive.11. Use H command to get the sum and difference of the addresses 0120 and 0100. Type,H 0120 0100 0220 0020 12. Change the value of the CX register to 0020. Type, -R CX CX 0000:002013. Type W to write the file Prog1.com,-W The computer should display Writing 00020 bytes.14. Exit from Debug.

Sample Problem C..1. Check the created Prog1.com file. Open the DOS command prompt. Click START-type CMD-press ENTER.2. Change directory to CompOrg. c:\cd CompOrg>3. Execute Prog1.com. c:\CompOrg>Prog1.com 4. Record your output in Table 1.7.

Sample Problem D.1. Open Debug.exe2. Type ?-? Describe what happened after you typed ? at the prompt. ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Which of the commands does not have a parameter? _____________________________________________________________Use Table 1.8 to write the long names of the commands and given the examples,give the function of each of the commands used in this activity.

6. DATA AND RESULTS:

Table 1.3-Sample Problem A.3

xxxx:0100 ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ Welcome to Assemxxxx:0110 ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ bly Programming!xxxx:0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................xxxx:0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................xxxx:0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................xxxx:0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................xxxx:0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................xxxx:0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................--

Table 1.4- Output of Sample Problem B.3

Table 1.5 -Result of Sample Problem B.4

AddressContents (Hex)Mnemonics

: 0100MOV AH,02

: 0102MOV DL,49

:0104INT 21

:0106MOV DL,20

:0108INT 21

:010AMOV DL,03

:010CINT 21

:010EMOV DL,20

:0110INT 21

:0112 MOV DL,54

:0114INT 21

:0116MOV DL,49

:0118INT 21

:011AMOV DL,50

:011CINT 21

:011EINT 20

Table 1.6 -Result of Sample Problem B.6

AddressContents (Hex)Mnemonics

: 0100B4 02MOV AH,02

: 0102MOV DL,49

:0104INT 21

:0106

:0108INT 21

:010AMOV DL,03

:010CINT 21

:010E

:0110INT 21

:0112 MOV DL,54

:0114INT 21

:0116MOV DL,49

:0118INT 21

:011AMOV DL,50

:011CINT 21

:011EINT 20

Table 1.7- Output of Procedure C.4

Table 1.8- Debug Commands

CommandSyntaxFunctionExample

A [Starting Address]

A 100

D [Start Addr] [End Addr]

D 100D 110 11F

E [Address] [Data]

E CS:107E CS:100 Welcome to Assembly Programming!

G [Starting Addr] [Breakpoint Addr]

GG=CS:100 11F

H value1 value2

H 0120 0100

N [C:] [filename] [.ext]

N c:\CompOrg\Prog1.com

Q

Q

RegisterR [Register name]Examine or modify the contents of internal CPU register. R R CX

U [Starting Addr]

U 100U 100 11E

W

W

PROBLEMS:

1. Make a DEBUG program that will display your name, program, and course, on the computer screen. Save you program as Prog2.com.Sample Output:Juan dela CruzBS CpECp413L1

2. Using the ASCII table as a reference,create a screen design of your choice. Save the program as Prog3.com

8. Assessment (Rubric for Laboratory Performance):

Activity No. 2

Registers

Course Code: Cp413L1Program:

Course Title: Computer Systems Organization with Assembly LanguageDate Performed:

Section:Date Submitted:

Name:Instructor:

1. Objective:

This activity aims to demonstrate how the CPU registers are used for addition, subtraction, multiplication and division operations and how the flags are affected by these operations

2. Intended Learning Outcomes (ILOs):

After completion of this activity the students should be able to:

2.1 Examine the contents internal CPU registers 2.2 Modify internal CPU register contents2.3 Demonstrate addition, subtraction, multiplication and division operations

3. Discussion :

The RegistersEvery computer contains registers or small areas that can store data temporarily. These registers are too small to store files instead they are used to store information while the program is running. These registers are specific for every computer manufacturer. Before one can program in assembly language one should be familiar with the registers inside their computer and the width of these registers because assembly language is machine-dependent or machine-specific programming language.

The 8088 CPU for example, has fourteen 16 bit registers to process the data in a computer.

Four are for data: AX,BX,CX,DXFour are for segment addresses: ES,DS,SS,CSFour are for index addressing: SP,BP,SI,DIOne is the instruction pointer:- IPOne is the flag register : Flag The 8086, 8088 and 80286 computers are characterized by a 16-bit architecture. The computers from the 80386 to the Pentium use the complete 32-bit architecture.

The registers are divided in three categories namely: General-purpose registers Segment Registers Other Registers

The general-purpose registers are primarily used for arithmetic and data movement. Each register can be addressed as either a single 32-bit value or two 16-bit values. Portions of some registers can be addressed as 8-bit values. For example, the 32-bit EAX register has a 16-bit lower half named AX. The AX register, in turn, has an 8-bit upper half named AH (A-High) and an 8-bit lower half named AL(A-Low).

The same overlapping relationship exists for the EAX, EBX, ECX, and EDX registers.

The remaining general-purpose registers only have specific names for their lower 16 bits, these are used when writing real-address mode programs.

THE FLAGS The FLAG (or just Flags) register consists of individual binary bits that control the operation of the CPU or reflect the result of arithmetic and logical instructions. Some instructions test and manipulate individual processor flags.

A flag is set when it equals 1; it is clear (or reset) when it equals 0. Table 2-1 shows how each flag is represented by DEBUG.

Table 2.1- The Flag Register bit representation in DEBUG

Set ( 1 )Clear ( 0 )

OV= OverflowNV=No Overflow

DN= Direction DownUP=Direction Up

EI= Enable InterruptDI=Disable Interrupt

NG= Sign Flag NegativePL=Sign Flag Positive

ZR=ZeroNZ=Not Zero

AC=Auxiliary CarryNA=No Auxiliary Carry

PE=Parity EvenPO=Parity Odd

CY=CarryNC=No Carry

The ARITHMETIC OPERATORSThe four basic arithmetic operators are the ADD, SUB, MUL, DIV. The ADD is used for addition.Syntax:ADD destination, source ;dest operand = dest operand + source operandThe destination operand can be a register or in memory. The source operand can be a register, in memory or immediate data. ADC, which means to add the two operands plus the carry. SyntaxADC destination, source ;dest = dest + source + CF (carry flag)The SUB is used for subtraction.The form of the two equivalent subtraction operations (subtract and subtract with borrow) are:Syntax :SUB dest, souce ;dest = dest - sourceSBB dest, source ;dest = dest - source CFIf the Carry Flag is set after the operation, then a larger number was subtracted from a smaller number, and a 'borrow' occurred which sets the carry flag.The MUL is used for multiplication.The DIV is used for division.In multiplication and division operations, the x86 microprocessor use the registers AX, AL, AH, EAX, DX and EDX as used as shown in Table 2.1 and Table 2.2Table 2.2- Default Operands for Multiplication

No. of BitsMultiplicandMultiplierProduct

8 bits x 8 ALregister or memoryAX (16 bits)

16 bits x 16 AXregister or memoryDX:AX (32 bits)

32 bits x 32 EAXregister or memoryEDX:EAX (64 bits)

Table 2.3- Default Operands for Division

No. of BItsDividendDivisorQuotientRemainder

16 bits / 8 AXregister, memory (8-bit)ALAH

32 bits / 16 DX:AXregister, memory (16-bit)AXDX

64 bits / 32 EDX:EAXregister, memory (32-bit)EAXEDX

The operands can be considered as signed numbers or unsigned numbers. The unsigned multiplication and division operations are MUL, DIV.

The signed multiplication/division operations are IMUL, IDIV.For signed multiplication, if the two numbers have the same sign the result is always positive. Ifthe operands are different signs then the result will be negative.For signed division, if the signs of the dividend and divisor are the same, then the quotient sign ispositive. If the signs of the dividend and divisor are different, then quotient sign is negative. Theremainder sign is always the same sign as the dividend. You can always check your work viaquotient*divisor + remainder = dividend)

4. Resources:

Computer with 32-bit Operating SystemDebug.exe

5. Procedure:

Sample Problem A.1. Run DEBUG.EXE.2. Examine the register contents, type-R Observe the output and record all results in Table 2.4.What did you observe as the default values of the flags? Why?__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________3. Modify the value of the AX register, type-R AXAX 0000:1234_ 4. Trace if the contents of register AX changed. Type,-T

What happened to the value of AX register?______________________________________________________________________________5. Change the value of the Parity flag, from Parity Odd (default) to Parity Even. Type-R FNV UP EI PL NZ NA PO NC -PE6. Check if the value of the Parity flag changed. Type,-R FWhat is now the new value in of the flag register?______________________________________________________________________________7. Reset the values of the registers. Type,-Q

Sample Problem B:1. Open Debug.exe2. Assemble the following program:-A 100movax,ffffadd ax,01int 213. Trace the values of the registers starting at address 0100-T=100 24. Observe the output.What did you observe in the output? Why?_________________________________________________________________________________________________________________________________________________________________________________________________________________________________5. Record all results in Table 2.5.6. Reset the values of the registers.

Sample Problem C. 1. Open Debug.exe. 2. Assemble the following program: -A 100mov al,00sub al,01int 213. Trace the values of the registers.4. Observe the output.Which flag/flags was/were affected by the given? Why?_________________________________________________________________________________________________________________________________________________________________________________________________________________________________5. Record all results in Table 2.6.6. Reset the values of the registers.

Sample Problem D. 1. Open Debug.exe. 2. Assemble the following program:-A 100mov al,0amov bl,05mulblint 213. Trace the values of the registers. 4. Observe the output.What did you observe in the output? Why?_________________________________________________________________________________________________________________________________________________________________________________________________________________________________5. Record all results in Table 2.7.6. Reset the values of the registers.

Sample Problem E.

1. Open Debug.exe. 2. Assemble the following program:-A 100mov dx,0mov ax,8003mov cx,100div cxint 213. Trace the values of the registers. 4. Observe the output.What did you observe in the output? Why?_________________________________________________________________________________________________________________________________________________________________________________________________________________________________5. Record all results in Table 2.8.6. Reset the values of the registers.

6. DATA AND RESULTS:

Table 2.4- Result of Sample Problem A.2

AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000DS=_______ ES=_______ SS=_______ CS=_______ IP=0100 NV UP EI PL NZ NA PO NC

Table 2.5 -Result of Sample Problem B.5

InstructionRegister ContentFlag Register

AXBXCXDXIP

MOV AX,FFFF

ADD AX,01

INT 21h

Table 2.5 -Result of Sample Problem C.5

InstructionRegister ContentFlag Register

AXBXCXDXIP

MOV AL,00

SUB AL,01

INT 21h

Table 2.5 -Result of Sample Problem D.5

InstructionRegister ContentFlag Register

AXBXCXDXIP

MOV DX,00

MOV AX,8003

MOV CX, 100

DIV CX

INT 21h

Table 2.5 -Result of Sample Problem C.5

InstructionRegister ContentFlag Register

AXBXCXDXIP

MOV AL,0a

MOV BL,05

MUL BL

INT 21h

PROBLEMS:

1. Determine two 8-bit numbers that will cause the following flag conditions to occur after the addition. Verify that your numbers cause thespecified flag conditions by modifying your program with your new numbers, executing it, andrecording the flag values. Use HEX numbers.a. Carry = 0, Overflow = 0, Zero = 0, Sign = 0: ___________ + ___________ = ___________

b. Carry = 0, Overflow = 0, Zero = 0, Sign = 1: ___________ + ___________ = ___________

c. Carry = 1, Overflow = 1, Zero = 0, Sign = 0: ___________ + ___________ = ___________

d. Carry = 0, Overflow = 1, Zero = 0, Sign = 1: ___________ + ___________ = ___________

e. Carry = 1, Overflow = 0, Zero = 0, Sign = 1 : ___________ + ___________ = ___________

f. Carry = 1, Overflow = 0, Zero = 0, Sign = 0 : ___________ + ___________ = ___________

g. Carry = 0, Overflow = 0, Zero = 1, Sign = 0 : ___________ + ___________ = ___________

2. Make a program that shows a division overflow.3. Make a program that would implement the expression : var4 = (var1 * -5) / (-var2 + var3);

8. Assessment (Rubric for Laboratory Performance):

Activity No. 3

DATA DEFINITION AND TRANSFER

Course Code: Cp413L1Program:

Course Title: Computer Systems Organization with Assembly LanguageDate Performed:

Section:Date Submitted:

Name:Instructor:

1. Objective:

This activity aims to demonstrate how characters and string of charactersmove from one location to another.

2. Intended Learning Outcomes (ILOs):

After completion of this activity the students should be able to:2.1 Show how to define data in Assembly2.2 Declare a group of characters2.3 Write programs applying Service 09 , Int 21

3. Discussion :

Data DefinitionThe basic storage unit for data in a computer is a byte, containing 8 bits(1 byte), other storage sizes are word (2 bytes), doubleword (4 bytes) , and quadword (8 bytes). String is stored in memory as a succession of bytes containing ASCII codes. They must be defined in the computer through directives. Table 3-1 shows how they are defined using directives.

Table 3-1-Data Directives

TermNumber of bitsDirective

Byte8DB (Define Byte)

Word16DW (Define Word)

Doubleword32DD (Define Double Word)

Quadword64DQ ( Define Quadword)

DISPLAYING A STRINGThere are two ways to display a string: Using Service 09HRequired:1. The string must be defined in DATA segment.2. The string must be terminated by '$'.3. AH = 09h4. DX = Offset address of the beginning of the stringExample:.DATASTRING_NAME DB 'THE STRING TO BE DISPLAYED$'.CODEMOV AH , 09HMOV DX , OFFSET STRING_NAMEINT 21HNote: If the terminating $ is omitted after the string, the operation displays characters in the memory, until it finds a $ character, if any. To move the cursor to the beginning of the next output line, put 0Dh and 0Ah after the string and before the terminating $.

Example:PROMPT DB 'PLEASE, ENTER YOUR NAME: ' , 0Dh , 0Ah , '$' Another way of moving the cursor to the beginning of the next output line is to display , using DOS function 09H, a string of the form:STRING1 DB 0Dh , 0Ah , '$' Using Service 40HRequired:1. Set AH = 40h2. BX = 13. CX = string length4. DX = offset address of the beginning of the string

Example:.DATASTRING_NAME DB 'THE STRING TO BE DISPLAYED'STRINGLEN EQU $ STRING_NAME .CODEMOV AH , 40HMOV BX , 01HMOV CX , STRINGLEN; string lengthMOV DX , OFFSET STRING_NAMEINT 21H The EQU directive defines a value that the assembler can use to substitute in other instructions. An operand containing a dollar symbol, $, refers to the current value in the location counter. Thus, in the above example $ - STRING_NAME evaluates to the number of bytes between STRING_NAME and STRINGLEN which is the number of bytes (i.e., characters) in THE STRING TO BE DISPLAYEDREADING A STRING (SERVICE 0Ah)To read a string, we have to do two steps:a. Define an array to store that string in DATA segment.b. Invoke DOS function 0AH in CODE segment.One way of defining the array is:BUFFER_NAME DB Num1 , Num2 DUP(?)

where:a. Num1 = the maximum number of string characters to be read + 1b. Num2 = Num1 + 1c. The maximum value for Num1 is FFh i.e., 255d. The last string character is the Carriage Return (0Dh).The program will wait for the input. The user must press "Enter" key to end the inputting process. inpExample: Define an array called STRING to store a string of maximum length 50 characters to be used by the service 0Ah of INT 21h.Actual string length is stored in this byte To read a string from the keyboard into an array called BUFFER as defined above, we invoke DOS function 0AH as:MOV AH , 0AHMOV DX , OFFSET STRINGINT 21HThe operation echoes the entered characters on the screen and advances the cursor. To display the above array generally by using DOS function 40H:MOV AH, 40HMOV BX, 01H; file handle for the screenMOVZX CX, STRING[1]; Initialize CX with the string lengthMOV DX, OFFSET STRING[2]INT 21H

4. Resources:

Computer with 32-bit Operating SystemTASM

5. Procedure:

Sample Program A.1. Type the following program using Notepad.dosseg.model small.stack.data prompt1 db 13,10,"Enter a character:$" prompt2 db 13,10,"The character you entered is:$".codemain procmovax,@datamovds,ax

lea dx,prompt1mov ah,09hint 21h

mov ah,01hint 21hmovbl,al lea dx,prompt2mov ah,09hint 21h

movdl,blmov ah,02hint 21hmov ax,4c00hint 21h

main endpend

2. Save the file inside the TASM directory as progA.asm.3. Open the DOS command prompt.4. Change directory to TASM. Type,C:\>cd TASM 5. Assemble Proga.asm. Type,C:\tasm>tasmprogA.asmThe following message will appear if you assembled your program successfully.Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland InternationalAssembling file: proga.ASMError messages: NoneWarning messages: NonePasses: 1Remaining memory: 442k

6. Use tlink to link all files created from assembling. Type,C:\tasm>tlink ProgA.objTurbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International7. Execute the program created. Type,C:\tasm>ProgA8. Analyze and record the output in Table 3.2.Sample Program B. 1. Type the following program using Notepad. .model small.stack 100h.databyte1 db 1 byte2 db 0word1 dw 1234h word2 dw 0string db "Stressed!", 0dh, 0ah,"$";---- this is a comment .code MAIN PROCMov ax, @dataMov ds, ax

Mov dx, offset stringMov ah, 9Int 21hMovbx, offset stringMov al, [bx] Mov ah, [bx+1]Mov [bx], ahMov [bx+1],alMov ah,9Mov dx, offset stringInt 21hMov ax, 4c00hInt 21h Main endp End main

2. Save the program as ProgB.asm.3. Assemble, link and execute the program.4. Analyze and record the output in Table 3.3

6. DATA AND RESULTS:

Table 3.2- Output of Sample Program ATable 3.3- Output of Sample Program B

PROBLEMS:

1. How many bytes are allocated for each of the following data definitions?a. BYTE 20 DUP(0)= _____________ bytesb. BYTE 20 DUP (?)= _____________ bytesc. BYTE 4 DUP(East)= _____________ bytesd. WORD3 WORD ?= _____________ bytese. Array WORD 5 DUP(?)= _____________ bytes2. Write a program that prompts and reads a users name USERNAME (of maximum length 30 characters). The program should display a message of the form:

OUTPUT:Hello, What's your name? JMHello, JM Congratulations! Your first program is working!3. Modify ProgB such that the second string is printed !dessertS (Stressed! backwards).

4. Create a program that will display a given string two times.SAMPLE OUTPUT:Enter a String: lovelovelove

8. Assessment (Rubric for Laboratory Performance):

Activity No. 4

C TRANSLATION TO ASSEMBLY LANGUAGE

Course Code: Cp413L1Program:

Course Title: Computer Systems Organization with Assembly LanguageDate Performed:

Section:Date Submitted:

Name:Instructor:

1. Objective:

This activity aims to show the relationship of C programming language to assembly language

2. Intended Learning Outcomes (ILOs):

After completion of this activity the students should be able to:2.1 Compare C programming and Assembly programming2.2 Convert a C program to Assembly program

3. Discussion :

ASSEMBLY LANGUAGE AND THE C LANGUAGE Assembly language is the basis of the C programming language it is the reason why a program in C can be easily translated in assembly language. For example, conditional statement of C language of the form:if (expression){statement1;statement2;:statementn;}else{statement1;statement2;:statementn;}

Can be implemented in Assembly language as:CMP_ instructionConditional_loop instruction Instruction1Instruction2:InstructionJMP_instruction

The WHILE statement in C language of the form:do{Statement1;Statement2;:statementn} while (expression);

Can be implemented in Assembly language as:label: Instruction1Instruction2:InstructionCMP instructionConditional_jump instruction Label

The DO WHILE statement in C language of the form:While{Statement1;Statement2;:statementn}

Can be implemented in Assembly language as:Label1:CMP instructionConditional jmp instruction labelInstruction1:Instruction2:instructionnJMP labelConditional_jump instruction Label2:Instruction1:Instruction2:Instruction

LabelActs as an identifier that acts as a place marker for instructions and data. When placed just before an instruction implies the instructions address. If placed just before a variable implies the variables address. Loops Loops or repetition allow a set of instructions to be repeated until certain condition is reached is also used in Assembly using the LOOP command.

4. Resources:

Computer with 32-bit Operating SystemTASM

5. Procedure:

Sample Problem 1:1. Type the following programs in Notepad. TITLE prog4_1.asmDosseg.model small.stack 0100h.data.codemovax,@datamov ds, axmov cx,001Ehmov ah,02h;request display charactermov dl,'*';character to displayA:int 21h;call interrupt serviceloop Amov ax, 4c00h;endint 21hendTITLE prog4_2.asm.model small.stack .data.codemovax,@datamov ds, axmov cx,001Ehmov ah,02h;request display charactermovdl,'A';character to displayB:int 21h;call interrupt serviceinc dlloop Bmov ax, 4c00h;endint 21hend

2. Assemble and execute these programs. 3. Analyze the outputs.What did you observe about the outputs?_________________________________________________________________________________________________________________________________________________________________________________________________________________________________4. Record the outputs in Table 4.1 and Table 4.2 respectively.

Sample Problem 2:1. Type the following programs in Notepad. TITLE Equal.asm MAIN SEGMENT ASSUME CS:MAIN,DS:MAIN,ES:MAIN,SS:MAIN ORG 100h START: MOV DL,41h MOV DH,41h CMP DH,DL JE TheyAreEqual JMP TheyAreNotEqualTheyAreNotEqual: MOV AH,02h MOV DL,4Eh INT 21h INT 20hTheyAreEqual: MOV AH,02h MOV DL,59h INT 21h INT 20hMAIN ENDSEND START// Equal.c#include#includemain(){int DH,DL;DL = 41;DH = 41;if (DH == DL) printf("Y");else printf("N");getch();return 0;}

TITLE Triangle.model small.codeorg 100hstart:

mov cl,1 mov bl,0mov ch,4

looprow:cmp ch,0jgloopcoljmp quit

loopcol:cmpbl,cljldsplayjmp next

dsplay:mov ah,2hmov dl,'*' ;display asteriskint 21hincbljmploopcol

next:mov dl,0Ahint 21h ;next linemov dl,0Dhint 21h

mov bl,0decchinc cljmplooprowquit:int 20hend start//Triangle.c#include#includemain(){int z=1;int x=0;int y=4;

while (y>0){

while(x