Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.hardware > #2541 > unrolled thread

NASM Programing

Started byriverbourne14 <riverbourne14@gmail.com>
First post2014-10-08 03:30 -0500
Last post2014-10-08 13:58 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.os.linux.hardware


Contents

  NASM Programing riverbourne14 <riverbourne14@gmail.com> - 2014-10-08 03:30 -0500
    Re: NASM Programing Joe Beanfish <joebeanfish@nospam.duh> - 2014-10-08 13:58 +0000

#2541 — NASM Programing

Fromriverbourne14 <riverbourne14@gmail.com>
Date2014-10-08 03:30 -0500
SubjectNASM Programing
Message-ID<O9adnT4VJIiQa6nJnZ2dnUU7-U-dnZ2d@giganews.com>
Consider a sequence of 19 strictly positive decimal digits, which have been
stored in an array.  There are obviously duplicates, and the sequence is
unsorted.  You may use the (a priori) sequence length in your program.

Your job is to compute and print the _median_ of this sequence.  Since the
sequence length is odd, the median occupies the central position when the
sequence is sorted.

Sorting the sequence might be challenging as your first assembly-language
program, but there is an easier way.  All you need to master is looping,
array indexing, adding 1, and comparing.

Give yourself an auxiliary array 'count' that records the number of times
each digit appears in the sequence.

A linear scan through the sequence is sufficient to compute 'count'.
A second linear scan through 'count' is sufficient to compute the median.

This program is to be written in NASM.

Here is an outline of the NASM source text:
                           
segment .data           
  seq   dd 0, 1, 9, 1, 9, 1, 9, 3, 8, 3,
           3, 8, 4, 7, 5, 7, 5, 6, 5, 4 ; array of length 20
  count dd 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; array of length 10

segment .text
  ...

---


Please send answer to below email address
riverbourne14@gmail.com

Thanks

[toc] | [next] | [standalone]


#2542

FromJoe Beanfish <joebeanfish@nospam.duh>
Date2014-10-08 13:58 +0000
Message-ID<m13ftd$ob$1@dont-email.me>
In reply to#2541
On Wed, 08 Oct 2014 03:30:05 -0500, riverbourne14 wrote:
> Consider a sequence of 19 strictly positive decimal digits, which have
> been stored in an array.  There are obviously duplicates, and the
> sequence is unsorted.  You may use the (a priori) sequence length in
> your program.
> 
> Your job is to compute and print the _median_ of this sequence.  Since
> the sequence length is odd, the median occupies the central position
> when the sequence is sorted.
> 
> Sorting the sequence might be challenging as your first
> assembly-language program, but there is an easier way.  All you need to
> master is looping, array indexing, adding 1, and comparing.
> 
> Give yourself an auxiliary array 'count' that records the number of
> times each digit appears in the sequence.
> 
> A linear scan through the sequence is sufficient to compute 'count'.
> A second linear scan through 'count' is sufficient to compute the
> median.


Ask your prof. if he wants the median value of the numbers or the median
element of the list. They may be different. (If the above wording is that
of the prof. it sounds like you want the median element.)
Then go do your own homework.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.linux.hardware


csiph-web