Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Having trouble with a homework question for NASM using ALong32. You are to read in N integers, terminated by a value of zero, which will

Having trouble with a homework question for NASM using ALong32.

You are to read in N integers, terminated by a value of zero, which will not be used. You are to sort these numbers into ascending order and print them out. You must produce an error message if either no data is entered prior to a value of zero, or if too much data is entered and would overflow your array. You should plan on handling at least 100 integer values to properly size your array.

Here is what I have so far:

%include "ALong32.inc" global main section .data

MYARRAY TIMES 100 DW 0;1 ROW * 100 COLUMNS counter dq 0 ;counter firstInt dq 0 ;input number that will be added to intTotal four dq 0; 4 int constant result dq 0

input1 dd "Input integer: ",0 noData dd "No data entered",0 tooMuch dd "Too much data",0 section .text

_start: mov word [four], 4; four=4 mov edx, input1 ;input1=edx call WriteString call ReadInt mov [firstInt], eax ;firstInt=eax cmp eax, 0 ;is eax = 0? jz exit ;if so, exit program cmp edx, 0x00 je none jmp continue

none: mov edx, noData call WriteString call Crlf

continue: mov [firstInt], edx imul ecx,ebx,four mov [result],ecx ;add to array inc ebx cmp ebx, 100 je exit mov [counter],ebx jmp continue exit: mov eax, 01h ; exitC) mov ebx, 0h ; errno

int 80h

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions