[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Held Friday, November 6, 1998
Handouts
Notes
a in
the current frame. How do we get A[0]? We'll assume that everything
takes four bytes.
MEM(BINOP(PLUS,
MEM(BINOP(PLUS, (TEMP(FP), CONST(a)))) // Reference to array
CONST(4)))
MEM(BINOP(PLUS,
MEM(BINOP(PLUS, (TEMP(FP), CONST(a)))),
BINOP(PLUS,
CONST(4) // Offset for start of array
BINOP(MULT, exp, CONST(4)))))
a in the parent frame, and the static link is at
offset s in the current frame?
MEM(BINOP(PLUS.
MEM(BINOP(PLUS,
MEM(BINOP(PLUS, TEMP(FP), CONST(s))) // Parent frame
CONST(a))) // Reference to array
CONST(4))) // Offset for start of array
SEQs and ESEQs.
Note also that the array is given by aexp and the index is given
by iexp.
MOVE(TEMP(aref), aexp) // E.g., MEM(BINOP(PLUS,TEMP(FP),CONST(a)))
MOVE(TEMP(index), iexp)
CJUMP(EQUAL, TEMP(aref), CONST(0), NullArray, OKREFERENCE)
LABEL(OKREFERENCE)
MOVE(TEMP(size), MEM(TEMP(aref)))
CJUMP(GE, TEMP(index), TEMP(SIZE), BadIndex, BIGENUF)
LABEL(BIGENUF)
CJUMP(LT, TEMP(index), CONST(0), BadIndex, OKINDEX)
LABEL(OKINDEX)
MEM(BINOP(PLUS, TEMP(aref), // Base of the array
BINOP(PLUS, CONST(4), // Offset for size
BINOP(TIMES, TEMP(index), CONST(4))))) // Offset in array
CONST(4) that clogs up our code?
(Alternately, why doesn't Appel have it?)
A[4][5] and
alpha.beta[4].gamma.
History
Back to Detour: Type checking field variables. On to Translating control structures.
[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Fri Nov 13 12:32:10 1998.
This page generated on Fri Nov 13 12:32:34 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu