Question: 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

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!