Write a program to find the maximum element from an array of N 8- bit elements u
ID: 3598546 • Letter: W
Question
Write a program to find the maximum element from an array of N 8- bit elements using the DoWhile (or repeat –until) looping construct. ( Code provided in the pic )
But the Prof. asked to write the same code but instead of the ldaa 0,X hilighted, we should use an off set of ( b ) instead. I don't understnad how. Can someone help with providing the code please?
Example 3: looping cont. equ 20 org $1000 ; array count ; starting address of on-chip SRAM ; memory location to hold array max ; starting address of program ; set array[0] as the temporary max max max val ds.b1 org ldaa staa Idx ldab Idaa cmpa bge Idaa staa $1500 array max val #array+N-1 #N-1 max val 0,x chk_end 0,x max val ; start from the end of the array ; set loop count to N - 1 loop ; update the array max ; move to the next array element ; finish all the comparison yet? chk end dex dbne b,loop forever bra forever arraydc 8,3,5,6,19,41,53,28,13,42,76,14,20,54,64,74,29,33,41,45 endExplanation / Answer
offset is the signed value of 5 bit , 9 bit or 16 bits or the value stored in accumulator A, B or D.
So yur professor meant instead of using the location of register X use the offset of sccumulator b to load the accumulator a for the max value in array.
so you just have to add an offset to the value of b
and replace ldaa with
ldaa offset,b
offfset would take you to the end of the arry for the first value as done using index register X
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.