;
;  This program asks the user for ten numbers and displays then
;  the smallest followed by the biguest.
;
;  Five diferent variables are going to be used:
;    Count -> keeps a counter from 9 to 0
;    Min   -> Keeps a record of the smallest number inputed so far
;    Max   -> keeps a record of the biggest number inputed so far
;    First -> is the first number inputed by the user
;    Num   -> is the number inputed by the user inside the loop
;
;  The stack is going to be:
;    Count  Max  Min  First/Num  ->
;
;


# 9                 ;Count:=9;
                    ;{names in stack .. .. Count -> }
InInt               ;Write('Please input an integer:');
                    ;ReadLn(First);
Bring R0            ;{duplicate}
                    ;Max:=First;
                    ;Min:=First;
                    ;{names in stack .. ..  Count  Max  Min  ->  }
                    ;{forget First}

:LOOP               ;repeat LOOP
InInt               ;  Write('Please Input an integer:');
                    ;  ReadLn(Num);
                    ;  {names in stack .. .. Count  Max  Min  Num -> }
Bring R0            ;
Bring R3            ;
Sub                 ;  if Num>Max then
Jrn BigTestDone     ;
Bring R0            ;    Max:=Num
Store R3


:BigTestDone        ;
Bring R0            ;
Bring R2            ;  if Num<Min then
Sub                 ;
Jrp SmallTestDone   ;
Bring R0            ;    Min:=Num;
Store R2            ;

:SmallTestDone
Store R0            ;  {forget the number inputed}
                    ;  {names in stack .. .. Count  Max  Min  -> }
Bring R2
# 1
Sub
Store R3            ;  Count:=Count-1;

Bring R2
Jrnz LOOP           ;until Count=0;

OutMsg2             ;Write('The smallest is : ');
OutNum              ;Write(Min); {and forget it}
OutCR               ;WriteLn;
OutMsg3             ;Write('The biggest is : ');
OutNum              ;Write(Max); {and forget it}
OutCR               ;WriteLn;
Store R0            ;{forget count}
Halt                ;end.

; After compiling it was found that:
;
; Instructions : 31
; Total bits ocupied : 226
;       bytes : 28.25
; Bits/instruction :7.29 
