@c+@s-@o-
-- change the - to a + to see compiler options
-- these may be placed anywhere
-- Always use @c+ for tests submitted to instructor
-- test of gcl skeleton features

-- This program becomes illegal after module headers are added.
-- Uncomment next two lines to make it legal again.
--module test0
--private
-- test of GCL features
 integer a,b,x;
$        LDA     R15, V1
$        LDA     R14, C1
$        LD      R13, #16000
Not found: a
 -- a offset:0
Not found: b
 -- b offset:2
Not found: x
 -- x offset:4
 [integer, integer] pair;
Not found: pair
 -- pair offset:6
 begin
@s+

------ Symbol Table ------

Variable id:= pair with scope: 1 at: 6 type: tupleType:[ : integer type. : integer type.] with size: 4
Variable id:= b with scope: 1 at: 2 type: integer type.
Variable id:= a with scope: 1 at: 0 type: integer type.
Variable id:= x with scope: 1 at: 4 type: integer type.

------ Symbol Table End ------

 read b; -- use 2 as input value
$        RDI     +2(R15)
 x := 1;
$        LD      R0, +0(R14)
$        STO     R0, +4(R15)
 a := b + x;
$        LD      R0, +2(R15)
$        IA      R0, +4(R15)
$        STO     R0, +0(R15)
 pair := [a, b + x];
$  Tuple component of size 2 at 10
$        LD      R0, +0(R15)
$        STO     R0, +10(R15)
$        LD      R0, +2(R15)
$        IA      R0, +4(R15)
$  Tuple component of size 2 at 12
$        STO     R0, +12(R15)
$        IS      R13, #4
$        LDA     R0, +10(R15)
$        LD      R1, #4
$        BKT     R0, *R13
$        LD      R0, R13
$        LD      R1, #4
$        BKT     R0, +6(R15)
$        IA      R13, #4
 if b = 2 ->	a := 1;
$        LD      R1, +2(R15)
$        LD      R0, #1
$        IC      R1, +2(R14)
$        JEQ     &4
$        LD      R0, #0
$        IC      R0, #1
$        JNE     J2
$        LD      R0, +4(R14)
$        STO     R0, +0(R15)
 		b := 1;
$        LD      R0, +6(R14)
$        STO     R0, +2(R15)
 [] b = 100 ->	a := 6;
$        JMP     J1
$    LABEL J2
$        LD      R1, +2(R15)
$        LD      R0, #1
$        IC      R1, +8(R14)
$        JEQ     &4
$        LD      R0, #0
$        IC      R0, #1
$        JNE     J3
$        LD      R0, +10(R14)
$        STO     R0, +0(R15)
		b := 100 / a;
$        LD      R0, +12(R14)
$        ID      R0, +0(R15)
$        STO     R0, +2(R15)
 [] b # 2  -> skip;
$        JMP     J1
$    LABEL J3
$        LD      R1, +2(R15)
$        LD      R0, #1
$        IC      R1, +14(R14)
$        JNE     &4
$        LD      R0, #0
$        IC      R0, #1
$        JNE     J4
 fi;
$        JMP     J1
$    LABEL J4
$        HALT    
$    LABEL J1
 write a, b, x, b*x ; --1111
$        WRI     +0(R15)
$        WRI     +2(R15)
$        WRI     +4(R15)
$        LD      R0, +2(R15)
$        IM      R0, +4(R15)
$        WRI     R0
$        WRNL    
 end.
 
$        HALT    
$    LABEL C1
$        INT     1
$        INT     2
$        INT     1
$        INT     1
$        INT     100
$        INT     6
$        INT     100
$        INT     2
$    LABEL V1
$        SKIP    14
  <end of compilation> 	There were 0 errors detected
