FIT1008 Lecture 2: Week 2 - arrays + iteration

96 views1 pages
="list"with"fixed"length,"with"each"item"being"the"same"size
All"elements"initialised"to"zero.
**"length"is"stored"in"address"block"before"items.
Eg."[0,"-1,"4,"-9,"16]
len(a)
5
0x10012FBC
a[0]
0
0X10012FC0
a[1]
-1
0X10012FC4
a[2]
4
0X10012FC8
a[3]
-9
0X10012FCC
a[4]
16
To"specify"an"address,"
Directly/using"a"label
lw"$t1,"N
Label"plus"offset
lw"$t1,"N+4
Using"a"GPR"to"store"address
lw"$t1,"($s0)
GPR"+"offset
lw"$t1,"4($s0)
Label,"offset"and"GPR"etc
lw"$t1,"N+4($s0)
To"create"array,
the_array = [0]*size -allocates"memory"on"the"Heap"for"the"list"tgt"with"
length"of"list
(for"integers,"space"required)"4*size"+"4
Store"address"of"first"byte"of"memory allocated"in"the_array
Iteration
="the"repetition"of"a"section"of"code."Achieved"by"sending"control"from"the"end"of"a"
loop"back"to"the"beginning.
While"-condition"tested"before"loop"is"entered
For"-simpler"version"of"while"loop
Week$2:$arrays$+$iteration
Thursday,"14"June"2018
12:08
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Document Summary

= list with fixed length, with each item being the same size. ** length is stored in address block before items. [0, -1, 4, -9, 16] len(a) a[0] a[1] a[2] a[3] a[4] Using a gpr to store address lw , () Label, offset and gpr etc lw , n+4() To create array, the_array = [0]*size - allocates memory on the heap for the list tgt with length of list (for integers, space required) 4*size + 4. Store address of first byte of memory allocated in the_array. = the repetition of a section of code. Achieved by sending control from the end of a loop back to the beginning. While - condition tested before loop is entered.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents