You are on page 1of 2

Saylo, Jerlen Chesil D.

Sir Regie Ellana

BSIT31E2 January 5, 2022

IT ELECTIVE 2 FINALS Assignment 1

Research the following:

1. Selection and Looping Constructs in Assembly


In general, Selection and Loops are basics of Computer Science. A Selection doesn’t follow
a sequence of events but provides question as to what will be the next step of the program. Loops,
on the other hand, ask the same question repeatedly until a certain task is complete.
In Assembly Language:
• Selection – gives selection between alternatives. There are three types of selection
construct: the If statements, Case statements and Pattern matching (the latter being
generally not being used as much).
• Looping – or some may call the repetition construct, causes a group of one or more
program statements to be implemented repeatedly until some end condition is met. This
construct is used to step through arrays or linked lists.

2. Types of Selection Statements


• If statements – are sometimes referred to as conditional statement, can be used in two
forms:
If condition then action1
If condition then action1 else action2

• Case statements – may often viewed as a shorter version of the if…then…else


statement. It allows selection from many alternatives where each alternative is linked to
a predicate which is the selector.

3. Commands reference to different operations


o EAX – arithmetic operations
o ECX – known as the counter and used to hold a loop index
o ESP – stack pointer
o EBP – base pointer
o Add, sub, mul, div – arithmetic operations
o And, or, xor - These instructions perform the specified logical operation (logical
bitwise and, or, and exclusive or, respectively) on their operands, placing the
result in the first operand location.
o Jcondition – conditional jump
je <label> (jump when equal)
jc<label>(jump if carry)
jne <label> (jump when not equal)
jz <label> (jump when last result was zero)
jg <label> (jump when greater than)
jge <label> (jump when greater than or equal to)
jl <label> (jump when less than)
jle <label> (jump when less than or equal to)
jo<label>(jump if overflow)
js<label>(jump if sign)
jp<label>(jump on even parity)

4. Associated flags for selection instruction.


Status flags have six types to monitor the outcome of arithmetic, logical, and related operations.
▪ Zero flag – indicates zero result
Related with the jcondition jz
▪ Carry flag - records the fact that the result of an arithmetic operation on unsigned numbers
is out of range
Related with the jcondition jc

▪ Overflow flag - indicates out-of-range result on signed numbers


Signed number counterpart of the carry flag
Related with the jcondition jo

▪ Sign flag - Indicates the sign of the result


Useful only when dealing with signed numbers
Simply a copy of the most significant bit of the result
Related with the jcondition js

▪ Auxiliary flag - Indicates whether an operation produced a carry or borrow in the low-order
4 bits (nibble) of 8-, 16-, or 32- bit operands (i.e. operand size doesn’t matter)

▪ Parity flag - Indicates even parity of the low 8 bits of the result
Related with the jcondition jp

References:

https://cgi.csc.liv.ac.uk/~frans/OldLectures/2CS45/progCons/progCons.html

https://www.cs.virginia.edu/~evans/cs216/guides/x86.html

https://www.geeksforgeeks.org/flag-register-8086-microprocessor/

You might also like