Assembly language. Shuffle an Array . Create a sequentially numberd array of 50
ID: 3820007 • Letter: A
Question
Assembly language. Shuffle an Array . Create a sequentially numberd array of 50 integers. Then use the Random_range procedure to shuffle the array in a random order ( Each number will only appear once in the array) displays the shuffled array. Plz separate . Data and . Code section thank you ! Assembly language. Shuffle an Array . Create a sequentially numberd array of 50 integers. Then use the Random_range procedure to shuffle the array in a random order ( Each number will only appear once in the array) displays the shuffled array. Plz separate . Data and . Code section thank you !Explanation / Answer
In programming, an array is a group of related data elements that are grouped together. All of the array elements must be the same data type.
Working with Arrays- To access an array in assembly language, we use a pointer. To access an array in assembly language, we use a pointer. A pointer is simply a register or variable that contains a memory address.
The program for shuffling the array which having size 50 and data type is integer,given below.
The program is written in assembly language.
INCLUDE Irvine32.inc
This will initialize 50 array integers which is given in the problem
ARRAYSIZE = 50
.data
msg BYTE " the values are negative.", 22, 5, 8
buffer SDWORD ARRAYSIZE DUP(0) ---->This is for avoid duplicate in 50 integers
This is used to initialize the counter to 0.
counter DWORD 0
.code
Then we are calling the main procedure
main PROC
To shuffle the numbers we use Randomize function here.
call Randomize
This section fill array with random numbers
mov ecx, ARRAYSIZE
mov esi, OFFSET buffer K1:
call Random22
mov [esi], eax
add esi, TYPE buffer
loop K1
This section used to loop the array and it will show each value in loop
Also it will count the negative integers.
mov esi, OFFSET buffer
mov ecx, ARRAYSIZE K2:
mov eax, [esi]
cmp eax, 0
jge @F
The counter is used to count the integers
inc counter@@:
call WriteInt
call Crlf
add esi, TYPE buffer
loop K2
This will show the count
mov eax, counter
call WriteDec
mov edx, OFFSET msg
call WriteString
exit
main ENDP
END main