please write it within mips instructions do not use mov and these stuff Consider
ID: 3911224 • Letter: P
Question
please write it within mips instructions do not use mov and these stuff
Consider ah array A of size 5 and containing the integers33, 20, 18, 45 and 100 respectively Wire an Assembly code that sorts this array in an ascending manner and stores the sorted integers in ahew array BYthat is, the elements of A remain in their same order). The elements of B are then divided by 100. Keep in mind that you can use within your code any assembly instruction is supported by assembler regardless of whether it is being used in the course (i.e. mul, div, 3. .. etc.) 4. Run and test your code. write it in java first then assembly language (mips) not high language please!Explanation / Answer
DATA SEGMENT
NUM_ARRAY DW 0033H, 0020H, 0045H, 0100H
ARRAY_SIZE DW 0004H
MY_DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:MY_DATA
; INITIALISATION STATEMENTS
MOV AX, MY_DATA
MOV DS, AX
MOV DX, 2
FIRST: MOV CX, DX
DEC CX
; COMPARISION OF THE NUMBERS IN ARRAY
MOV SI, CX ; STORE THIS IN SI
ADD SI, SI
MOV AX, NUM_ARRAY[SI] ; GET THE NUMBER
BACK: CMP NUM_ARRAY[SI-2], AX
JBE NEXT ; JUMP BELOW OR EQUAL
MOV DI, NUM[SI-2]
MOV NUM[SI], DI
; ARRANGE THE NUMBERS
DEC SI
DEC SI
DEC CX
JNZ BACK;
NEXT: MOV NUM[SI], AX
INC DX
CMP DX, ARRAY_SIZE
JBE FIRST
HLT
; SORTING OF ARRAY IN ASCENDING ORDER
; SORTING OF ARRAY IN DESCENDING ORDER
MOV CX, 2 ;{ARRAY_SIZE/2}
MOV DX, ARRRAY_SIZE ; INITIALISE DX
MOV SI, 0000H ; INITIALISE SI
; THE DESCEND BLOCK WILL JUST MOVE THE ARRANGED ARRAY IN REVERSE ORDER
DESCEND:MOV AX, NUM_ARRAY[DX]
MOV BX, NUM_ARRAY[SI]
MOV NUM_ARRAY[DX], BX
MOV NUM_ARRAY[SI], AX
INC SI
DEC DX
DEC CX
JNZ DESCEND HLT
CODE ENDS
END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.