0% found this document useful (0 votes)
46 views8 pages

COAL Lab 7 (22k-4136)

The document contains 6 tasks that demonstrate various programming concepts in x86 assembly language. Task 1 copies elements from one array to another. Task 2 calculates the sum of 3 numbers. Task 3 calculates the sum of elements in two arrays and displays the total. Task 4 prints a pattern of stars with spaces based on a user-input number of columns. Task 5 is similar but prints the alphabet. Task 6 calculates and displays the sum of numbers from 1 to a user-input number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views8 pages

COAL Lab 7 (22k-4136)

The document contains 6 tasks that demonstrate various programming concepts in x86 assembly language. Task 1 copies elements from one array to another. Task 2 calculates the sum of 3 numbers. Task 3 calculates the sum of elements in two arrays and displays the total. Task 4 prints a pattern of stars with spaces based on a user-input number of columns. Task 5 is similar but prints the alphabet. Task 6 calculates and displays the sum of numbers from 1 to a user-input number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

LAB 7 (22k-4136)

Task 1

INCLUDE Irvine32.inc

.data

arr WORD 1,2,3,4,5,6,7,8,9,10


duplicate WORD 10 DUP(?)
var WORD ?
.code
main PROC
mov esi,0
mov ecx,10
L1:

PUSH arr[esi]
POP ax
mov duplicate[esi],ax
add esi,2

Loop L1

mov ebx,TYPE duplicate


mov ecx,LENGTHOF duplicate
mov esi,OFFSET duplicate
call DumpMem
exit
main ENDP
END main
Task 2

INCLUDE Irvine32.inc

.data

number1 DWORD 23
number2 DWORD 90
number3 DWORD 44
var DWORD ?

prompt BYTE "The sum of three integers are: ",0

.code
main PROC

PUSH number1
PUSH number2
PUSH number3
mov ecx,3
L1:

POP eax
add var,eax

Loop L1
mov eax,var

mov edx,OFFSET prompt


call writestring
call WriteDEC
exit
main ENDP
END main
Task 3
INCLUDE Irvine32.inc

.data

arr1 WORD 1,2,3,4,5


arr2 WORD 10,20,30,40,50
arr3 WORD 5 DUP(?)
prompt byte "The sum of two array is: ",0
sum1 WORD ?
sum2 WORD ?

.code
main PROC

call SumOfArr1
call SumOfArr2
call SumOfArr3
exit
main ENDP

SumOfArr1 PROC

mov esi,OFFSET arr1


mov eax, 0
mov ecx, LENGTHOF arr1
L1:
add ax,[esi]
add esi,2
Loop L1
mov sum1,ax
ret
SumOfArr1 ENDP

SumOfArr2 PROC
mov esi,OFFSET arr2
mov eax, 0
mov ecx, LENGTHOF arr2
L1:
add ax,[esi]
add esi,2
Loop L1
mov sum2,ax
ret
SumOfArr2 ENDP

SumOfArr3 PROC

mov eax,0
add ax,sum1
add ax,sum2
mov edx,OFFSET prompt
call WriteString
call writeDec
call Crlf

ret
SumOfArr3 ENDP

END main

Task 4
INCLUDE Irvine32.inc

.data

prompt byte "Write the number of columns: ",0


gap byte " ",0
star byte "*",0
number DWORD ?
count DWORD ?
temp DWORD ?

.code
main PROC

mov edx,OFFSET prompt


call writeSTRING
call readDec
mov number,eax
call PrintStar
exit
main ENDP

PrintStar PROC

mov ecx,number
mov temp,1

L1:

mov count,ecx
mov ecx,number
L2:

mov edx,OFFSET gap


call WriteString

Loop L2

sub number,1
mov ecx,temp
L3:

mov edx,OFFSET star


call WriteString

Loop L3

add temp,1
call Crlf
mov ecx,count
Loop L1

ret
PrintStar ENDP

END main
Task 5
INCLUDE Irvine32.inc

.data

prompt byte "Write the number of columns: ",0


gap byte " ",0
char DWORD ?
number DWORD ?
count DWORD ?
temp DWORD ?
temp2 DWORD ?

.code
main PROC

mov edx,OFFSET prompt


call writeSTRING
call readDec
mov number,eax
call PrintAlphabets
exit
main ENDP

PrintAlphabets PROC

mov ecx,number
mov temp,1
mov char, 'A'
mov eax ,char
L1:

mov count,ecx
mov ecx,number
L2:

mov edx,OFFSET gap


call WriteString
Loop L2

sub number,1
mov ecx,temp
mov temp2,ecx

L3:

call WriteChar
add eax,1
mov edx,OFFSET gap
call WriteString

Loop L3

add temp,1
call Crlf
mov ecx,count
Loop L1

ret
PrintAlphabets ENDP

END main

Task 6
INCLUDE Irvine32.inc

.data

prompt byte "Write the number for sum: ",0


prompt2 byte "The sum is: ",0
number DWORD ?
.code
main PROC

mov edx,OFFSET prompt


call writeSTRING
call readDec
mov number,eax
call SumNumbers
exit
main ENDP

SumNumbers PROC

mov ecx,number
mov eax,0
L1:

add eax,ecx

Loop L1

mov edx,OFFSET prompt2


call writestring
call writeDec
call Crlf

ret
SumNumbers ENDP

END main

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy