Skip to content

Commit

Permalink
Added basic array functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Warren Toomey committed Oct 27, 2019
1 parent fc809d1 commit 7d02ad3
Show file tree
Hide file tree
Showing 64 changed files with 3,413 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 19_Arrays_pt1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SRCS= cg.c decl.c expr.c gen.c main.c misc.c scan.c stmt.c \
sym.c tree.c types.c

ARMSRCS= cg_arm.c decl.c expr.c gen.c main.c misc.c scan.c stmt.c \
sym.c tree.c types.c

comp1: $(SRCS)
cc -o comp1 -g -Wall $(SRCS)

comp1arm: $(ARMSRCS)
cc -o comp1arm -g -Wall $(ARMSRCS)
cp comp1arm comp1

clean:
rm -f comp1 comp1arm *.o *.s out

test: comp1 tests/runtests
(cd tests; chmod +x runtests; ./runtests)

armtest: comp1arm tests/runtests
(cd tests; chmod +x runtests; ./runtests)

test20: comp1 tests/input20.c lib/printint.c
./comp1 tests/input20.c
cc -o out out.s lib/printint.c
./out

armtest20: comp1arm tests/input20.c lib/printint.c
./comp1 tests/input20.c
cc -o out out.s lib/printint.c
./out
23 changes: 23 additions & 0 deletions 19_Arrays_pt1/Notes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
int ary[5];
int *ptr;

ary[3]= 63; // Set ary[3] (lvalue) to 63
ptr = ary; // Point ptr to base of ary
// ary= ptr; // error: assignment to expression with array type
ptr = &ary[0]; // Also point ptr to base of ary, ary[0] is lvalue
ptr[4]= 72; // Use ptr like an array, ptr[4] is an lvalue

.globl z
z: .quad 1
.quad 2
.quad 3
.quad 4
.globl zc
zc: .byte 1
.byte 2
.byte 3
.byte 4
.byte 0
.byte 0
.byte 0
.byte 0
Loading

0 comments on commit 7d02ad3

Please sign in to comment.