Sei sulla pagina 1di 11

ACTIVITY6: Jump and Compare Instruction

6.1 Program Outcomes (POs) Addressed by the Activity

• ability to apply knowledge of mathematics and science to solve engineering


problems

• ability to design and conduct experiments, as well as to analyze and interpret data

• ability to design a system, component, or process to meet desired needs within


realistic constraints such as economic, environmental, social, political, ethical, health
and safety, manufacturability, and sustainability, in accordance with standards

• ability to identify, formulate, and solve engineering problems

• ability to use techniques, skills, and modern engineering tools necessary for
engineering practice.

• knowledge and understanding of engineering and management principles as a


member and leader in a team, to manage projects and in multidisciplinary
environments

6.2 Activity’s Intended Learning Outcomes (AILOs)


At the end of this activity, the student shall be able to:
• Discuss the functions of JMP and CMP.
• Apply and Demonstrate the Jump and Compare Instructions in Assembly Language
Code.

6.3 Objectives of the Activity

The objectives of this activity are to:

• Understand how compare and jump works in assembly language programming.


• Create a program that can perform comparison operations.

6.4 Principle of the Activity


An assembly program consists of a set of statements. The two type of statements are the
instructions and directives.

Instruction:
Program control transfer instructions change or modify the flow of a program.

UNCONDITIONAL JUMPS
The basic instruction that transfers control to another point in the program is
JMP.

JMP INSTRUCTION
Syntax:
JMP label
Jump is usually an indication of a change in program counter that is not
directly related to the current program counter and is often free of distance limits from the
current program counter.

CMP Instruction
The CMP instruction performs an implied subtraction of a source
operand from a destination operand. Neither operand is modified:
Syntax:
CMP <destination>, <source>
Flags: the CMP instruction changes the overflow, sign , zero, carry, auxiliary
carry, and parity flags according to the destination operand would have had if the SUB
instruction were used.

Directives:
Which tell the assembler to perform specific action, such as define a data item.
An assembly language supports a number of statements that enable you to control
the way in which a source program assembles and list.
6.5 Materials/Equipment

1 unit Personal Computer


DOS / Command Prompt
Text Editor (SK, Notrepad, Wordpad)
Assembler (TASM.EXE)
• Linker (TLINK.EXE )
• Storage unit

6.6 Circuit Diagrams / Figures / Source Codes (if Applicable)

Figure 1. Title

6.7 Procedure/s

• Encode the given program.


(Filename: initialactivity6.asm)

• Write the following program using SK’s notepad or any of your text editor using the
(initialactivity6.asm)

.model small
.code
org 100h
start: jmp main
msg1 db "Enter a number:$"
msg2 db "Equal to 5$"
msg3 db "More than 5$"
msg4 db "Less than 5$"
newline db 0ah, 0dh, 24h
main:

mov ah, 09
lea dx, msg1
int 21h

mov ah, 01
int 21h

mov bl, al

call down

cmp bl, '5'


jE equaltofive
jG morethanfive
jL lessthanfive

equaltofive:
mov ah, 09
lea dx, msg2
int 21h
jmp exit

morethanfive:
mov ah, 09
lea dx, msg3
int 21h
jmp exit

lessthanfive:
mov ah, 09
lea dx, msg4
int 21h

exit:
int 20h

down proc
mov ah, 09
lea dx, newline
int 21h
ret
down endp
end start

• Execute the given program.

• Does the expected output appear? Attached the picture of the output.

Challenge Activity

• Create a program that input a character and display if it is a small letters, capital
letters or if it is special/numeric character..

6.8 Activity Report


Section: X23 Date Performed: 10/30/19
Course Code: IT0047 Date Submitted: 10/30/19
Course Title: IT Elective

Instructor: Engr. Joaquin

Activity No.: 6
Student Name (LN, FN MI) Castillo, Juan Signature:
Carlo Q.

6.8.1 Data and Results

• Given the sample output coming from your instructor, write down and compile the
required program that will provide the expected sample output using expt6.asm as
the filename.

• Encode the program.

Activity Code

.model small

.code

org 100h

start: jmp main

msg1 db "Press a key:$"

msg2 db "Capital$"

msg3 db "Small Letter$"

msg4 db "Numeric or Special$"

newline db 0ah, 0dh, 24h

main:
mov ah, 09

lea dx, msg1

int 21h

mov ah, 01

int 21h

mov bl, al

call down

cmp bl, 41h

jE Capital

jG TestMore

jL NumericSpecial

Capital:

mov ah, 09

lea dx, msg2

int 21h

jmp exit

SmallLetter:

mov ah, 09

lea dx, msg3


int 21h

jmp exit

TestMore:

cmp bl, 5bh

jE equaltoA

jG Testmore1

jL equaltoA

Testmore1:

cmp bl, 61h

jE SmallLetter

jG Testmore2

jL NumericSpecial

Testmore2:

cmp bl, 7ah

jE SmallLetter

jG NumericSpecial

jL SmallLetter

NumericSpecial:

mov ah, 09

lea dx, msg4

int 21h
exit:

int 20h

down proc

mov ah, 09

lea dx, newline

int 21h

ret

down endp

end star

Screenshots:

• Ask your instructor to check your work.

• Save the program to your data disk.

6.8.2 Observations
________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

________________________________________________________________________

6.8.3 Conclusion/s

6.8.4 Rating (include Rubric)


Criteria Grade

Activity Conduct (1-5)

Correctness of Command(s)/Program(s) (1-5) x 2

Completeness of Tasks (1-5)

Data Analysis and Results Interpretation (1-5)

Total Score

Mean Score = (Total Score / 5)

Percentage Score = (Total Score/25) * 100


Other Comments:

Potrebbero piacerti anche