Question: Write an assembly language program that contains function SelectionSort ( float [ ] a , int len ) . This function must take an array

Write an assembly language program that contains function SelectionSort(float[] a, int len). This function must take an array of single precision floating point values (allocated in RAM) and its length (both passed in stack) and sort the array in ascending order by using the selection-sort method. Make sure to allocate and initialize an array to sort in ROM and copy its values into RAM prior calling your sorting routine. Print the original (unsorted) array and the sorted one. You may use selection-sort project for sorting integers from Module 3 and make necessary adjustments in it for f.p. processing.
Hint: use the following method to print floating-point numbers:
WriteFloat2 PROC push {R0, LR} vpush.f {S1} vmov.f R0, S0 tst R0, #0x10000000 beq wf1 movs R0, #'-' bl WriteChar vneg.f S0, S0 wf1 vcvt.u32.f S1, S0 ; S1= integer part vmov.f R0, S1 bl WriteInt vcvt.f.u32 S1, S1 vsub.f S0, S1 ; S0= fraction movw R0, #'.' bl WriteChar vldr.f S1,=1000 vmul.f S0, S1 vcvt.u32.f S1, S0 vmov.f R0, S1 bl WriteInt vpop.f {S1} pop {R0, PC} ENDP
WRITE IT IN THIS FORMAT
INCLUDE EFR32BG22.inc ; CPU register definitions
INCLUDE terminal.inc ; terminal function definitions
EXPORT main
IMPORT LETIMER_setup ; import names from other code files
IMPORT GPIO_setup
;------------------------------------- ; non-initialized DATA segment in RAM
AREA RAM, DATA, NOINIT, READWRITE, ALIGN=3
;myWord SPACE 4 ; 32-bit variable (MUST BE ALIGHED!)
;myHalf SPACE 2 ; 16-bit variable (MUST BE ALIGHED!)
;myByte SPACE 1 ; 8-bit variable (NO alighment required)
;------------------------------------- ; CODE segment in flash (ROM)
AREA |.text|, CODE, READONLY
main PROC ; main user code
bl Terminal_setup ; setup TeraTerm communication
; bl GPIO_setup ; configure port pins
; bl LETIMER_setup ; start 1-sec timer for periodic events
; your code starts here
loop ; periodic task starts here
b loop ; repeat periodic task
ENDP
;-------------------------------------
;prompt DCB "Enter a number: ",0 ; allocate constant strings here
ALIGN
;constW DCD 15 ; initialized 32-bit constant
;constH DCW 23 ; initialized 16-bit constant
;constB DCB 17 ; initialized 8-bit constant
ALIGN
END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!