Question: Write an assembly program that sorts 50 different numbers and prints them to the screen smallest to largest. One function to sort the numbers and

Write an assembly program that sorts 50 different numbers and prints them to the screen smallest to largest. One function to sort the numbers and one function to print to screen. Please use the template below:

;nasm -f elf32 .asm ;gcc -m32 .o -o

section .data fileName: db "input.dat",0 format: db "%d",10,0 section .text extern printf extern exit global main

;DO NOT MODIFY loadArray: push ebp mov ebp, esp sub esp, 0x4 ; stack space for file descriptor

mov eax, 0x5 ; open file command mov ebx, fileName ; file name mov ecx, 0x0 ; read only mode mov edx, 0x309 ; file permissions 0777 int 0x80 ; execute command

mov [esp], eax ; save the file descriptor

mov eax, 0x3 ; read the file mov ebx, [esp] ; the returned file descriptor lea ecx, [ebp+0x8] ; top of the buffer mov edx, 0xc8 ; size of the buffer int 0x80 ; execute command

mov eax, 0x6 ; close the file mov ebx, dword [esp] ; file descriptor int 0x80 ; execute command add esp, 0x4 ; clean up pop ebp ret

; Outline code to be completed. printArray: ;...missing code

; push push format ; don't change call printf ; don't change add esp, 0x8 ; don't change

;...missing code

main: push ebp mov ebp, esp sub esp, 0xc8 ; stack space for numbers push dword [esp] call loadArray add esp, 0x4 add esp, 0xc8 pop ebp call exit

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 Databases Questions!