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

We need help with the bubble sorter we can\'t figure how to go about doing it. W

ID: 3797475 • Letter: W

Question

We need help with the bubble sorter we can't figure how to go about doing it. We got some of it. HELP Your Sorting lab starts here Memory allocation of Arrays must be done before the RESET and StopWDT ARY1. set 0x0200 Memory allocation ARY1 set 0x0210 Memory allocation ARYS ARY1S 0x0220 ARY2. Memory allocation ARY2 set ARY2S 0x0230 Memory allocation AR2S set clr clearing all register being use is a good clr programming practice R5 clr R6 HARY1 R4 initialize R4 as a pointer to arrayl SORT1 MOV. VARY1S, R6 initialize R4 as a pointer to arrayl sorted MOV.W call ArraySetupl then call subroutine ArraySetupl call COPY Copy elements from ARY1 to ARY1S space call USORT Sort elements in ARAY1 SORT2 mov w HARY2 R4 ;initialize R4 as a pointer to array mov w WARY2S R6 initialize R4 as a pointer to array sorted call ArraySetup2 then call subroutine ArraySetup2 call COPY ;Copy elements from ARY2 to ARY space call USORT Sort elements in ARAY2 Main loop jmp Ma loop Infinite Loop Array setupl mov.b #10 0(R4) Array element initialization Subroutine mov.b #17 1 (R4) First start with the number of elements mov.b #55 2(R4) and then fill in the 10 elements ret Array Setup2 Similar to Array Setupl subroutine ret COPY Copy original Array to allocated Array- Sorted space ret Subroutine SORT sorts array from SORT lowest to highest value ret Your Sorting lab ends here

Explanation / Answer

LXI H,5000 ;Set pointer for array   
MOV C,M ;Load the Count
DCR C ;Decrement Count
REPEAT: MOV D,C
LXI H,5001
LOOP: MOV A,M ;copy content of memory location to Accumulator
INX H
CMP M
JC SKIP ;jump to skip if carry generated
MOV B,M ;copy content of memory location to B - Register
MOV M,A ;copy content of Accumulator to memory location
DCX H ;Decrement content of HL pair of registers
MOV M,B ;copy content of B - Register to memory location
INX H ;Increment content of HL pair of registers
SKIP: DCR D ;Decrement content of Register - D
JNZ LOOP ;jump to loop if not equal to zero
DCR C ;Decrement count
JNZ REPEAT ;jump to repeat if not equal to zero
HLT ;Terminate Program

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