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
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
;...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
Get step-by-step solutions from verified subject matter experts
