A Simple Maximum

View as PDF

Submit solution


Points: 8
Time limit: 0.2s
Memory limit: 1M
Author:

Problem type

Allowed languages
Assembly

Your computer engineering instructor gave you a simple task:

Write a program to find the largest number in a list of N signed 8-bit integers.

Since you think this is too easy a task for your programming prowess, you've decided to make life more interesting... by computing this simple maximum in assembly. To top things off, you want to show off by also finding the minimum number in the list.

Input Specification

The first line of input will contain the integer N (1 \le N \le 100).
The second line of input will contain N space-separated signed 8-bit integers, representing the list.

Output Specification

The minimum number in the list followed by the maximum, and separated by a space.

Sample Input

5
2 3 9 0 18

Sample Output

0 18

Note

To use libc in NASM, the first line of your program should be ; libc. For all others, it should be ; features: libc.

Language Constraints

Because Assembly (ARM) runs under qemu, it is allocated 0.5s and 4096kb of RAM.


Comments


  • -2
    tiger2018  commented on Dec. 31, 2017, 10:46 a.m.

    NOOOO!!! I don't use Assembly!


  • 0
    Ninjaclasher  commented on June 24, 2017, 10:12 a.m.

    If my calculations are correct, does:

    signed 8-bit integers

    mean that each integer can range from -128 to 127 (inclusive)?


    • 3
      wleung_bvg  commented on June 24, 2017, 11:20 a.m. edited

      Yes. 8 bits means there are 8 binary digits, but since the first bit is used for the sign, the range is -2^7 to 2^7 - 1.


  • 0
    root  commented on Feb. 21, 2017, 5:09 p.m. edit 2
    Hint

    For those getting CE, make sure you are using the right assembler and syntax. GAS by default uses AT&T syntax, not Intel syntax. Put this at the start of your submission to use intel syntax.

    .intel_syntax noprefix


    • 0
      quantum  commented on Feb. 21, 2017, 7:03 p.m. edit 3

      Such false rumours. GAS supports Intel® syntax perfectly fine. To use that is left as an exercise for the reader.

      By the way, your history "edit history") leaves a lot to be desired.


      • 0
        root  commented on Feb. 24, 2017, 9:22 p.m.

        Was going to ask that when I realized my mistake, unfortunately I can't delete comments, so I improvised a comment to avoid the downvotes. Might consider adding that feature to support comment self-cleanup.


  • 1
    Centurion902  commented on Feb. 8, 2017, 12:01 a.m.
    Whoops

    How many of you did this one before realising they were asking for it in assembly?


    • 3
      Xyene  commented on Feb. 8, 2017, 12:46 a.m.

      Now that you've solved the problem, go solve it in assembly!


  • 0
    root  commented on Sept. 25, 2016, 10:42 a.m.
    ???

    Please make it clear whether these are signed or unsigned. I'll assume unsigned for now.


    • 2
      Xyene  commented on Sept. 25, 2016, 10:49 a.m.

      They are signed, and I've updated the statement to reflect this.