Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: Complete the missing code to sort array from smallest to largest and print.

;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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is an internal exchange transaction, and how is it reported?

Answered: 1 week ago

Question

4. Explain how to price managerial and professional jobs.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago