CPSC 355 Lecture Notes - Lecture 19: Assembly Language

110 views3 pages

Document Summary

Cpsc 355 - lecture 19 oct 26th. Array elements are accessed using load and store instructions: eg: ia[2] = 13; define(ia_base_r, x19) define(index_r, x20) define(offset_r, x21) add mov lsl mov str ia_base_r, x29, ia_s index_r, 2 offset_r, index_r, 2. // offset = i * element size w22, 13 w22, [ia_base_r, offset_r]// ia[2] = 13: can be optimized by doing the lsl in the str instruction move index_r, 2 mov str w22, 13 w22, [ia_base_r, index_r, lsl 2] // ia[2] = 13: if index is a w register, one must sign extend first define(index_r, w20) (same as above) str w22, [ia_base_r, index_r, sxtw 2] // ia[2] = 13. Use 2 or more indices to access individual array elements: most languages use row major order when storing arrays in ram. I. e. first all elements of row 0, then row 1, etc: eg: int ia[2][3];

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