21K 3172 (Lab4)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

LAB 04

LAB 04

TASK 1
Declare a 32-bit signed integer val1 and initialize it with the eight thousand. If
val1 is incremented by 1 using the ADD instruction, what will be the values of
the Carry and Sign flags?
• The values of CF and SF both are zero (SF=0, CF=0)
LAB 04
TASK 2
Write down the values of the Carry, Sign, Zero, and Overflow flags after each
instruction has executed.

TASK 2A
• Following is the result after adding 10h in AL register
LAB 04
TASK 2B
• Following is the result after adding 1 in AH register
LAB 04
TASK 2C
• Following is the result after adding 2 in AX register.
LAB 04
TASK 4
Use following array declarations:
arrayB BYTE 10, 20, 30
arrayW WORD 150, 250, 350
arrayD DWORD 600, 1200, 1800
Now initialize three double word variables SUM1, SUM2, SUM3 and perform
following operation
Now initialize three double word variables SUM1, SUM2, SUM3 and perform
following operations
(expressed in pseudo-code here):
SUM1 = arrayB[0] + arrayW[0] + arrayD[0]
SUM2 = arrayB[1] + arrayW[1] + arrayD[1]
SUM3 = arrayB[2] + arrayW[2] + arrayD[2]
LAB 04
5. Initialize two arrays:
array1 BYTE 10, 20, 30, 40
array2 BYTE 4 DUP (?)
Copy elements of array1 into array2 in reverse order using either indirect
addressing or direct-offset addressing.
Copy elements of array1 into array2 in reverse order using either indirect
addressing or direct-offset Addressing. We are moving the element into lower
part of ax as it is a byte and moving back into second array in reverse order in
the second array.
• Following is the code snippet in which I am assigning reverse values to
array2 from array1 (Taking elements from end of array1 and storing in
array2)
LAB 04
6. Subtract an array of 5 double words using indirect operands.
• We created a dword array, moved offset to ESI register and used it for
indexing to access elements and subtract them. We used registers for
indirect operations.
LAB 04
7. Use following array declarations:
arrayB BYTE 60, 70, 80
arrayW WORD 150, 250, 350
arrayD DWORD 600, 1200, 1800
For each array, add its 1st and last element using scale factors and display the
result in a separate register.
• Over here I used AL register for Byte data, AX register for Word data, and
eEAX register for Dword and then by multiplying size of element of each
array and ESI value I added first and last element.

You might also like