Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a syntactically correct 68HS12 assembly language program that will sort ou

ID: 3669520 • Letter: W

Question

Write a syntactically correct 68HS12 assembly language program that will sort out the positive and negative numbers from 8 signed 16-bit integers stored in Array1 and store the positive and negative values to two different locations in memory. The base address of the data Array1 is $1000. Array1 Contents: $AA84, $F9BD, $5A6B, $127A, $2180, $FFC5, $D763, $7833 The positive value should be stored starting at address $1100. The negative value should be stored starting at address $1180. Your source code should include the data arrays initialized with the data words desired. You can allocate space for your program variables as needed. The program should be terminated by the appropriate command that returns control to the DBug12 Monitor. Commented code is required

Explanation / Answer

n equ 15 ; array count

key equ 83 ; key to be searched

org $1500

max rmb 1 ; maximum index value for comparison

min rmb 1 ; minimum index value for comparison

mean rmb 1 ;the average of max and min

result rmb 1 ; search result

org $2000

clra

staa min ; initialize min to 0 (i.e., point to first number in array)

staa result ; initialize result to 0

ldaa #n-1

staa max ; initialize max to n-1 (i.e., point to last number in array)

ldx #arr ; use X as the pointer to the array

loop ldab min

cmpb max

lbhi notfound ;Long Branch to notfound if min > max

addb max ;compute mean

lsrb ; “ (max + min)/2

stab mean ; save mean

ldaa b,x ; A Å element arr[mean] uses B, mean, as offset

cmpa #key

beq found

bhi search_lo

ldaa mean

inca

staa min ; place mean+1 in min to continue

bra loop

search_lo ldaa mean

deca

staa max

bra loop

found ldaa #1

staa result

notfound swi

arr db 1,3,6,9,11

db 61,63,64,65,67

db 80,83,85,88,90

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote