COEN 122 Lecture Notes - Lecture 9: Machine Code

9 views2 pages

Document Summary

Void swap(long long int v[], long long int k){ //copy temp to (k + 1)th long long int temp; temp = v[k] v[k] = v[k+1] v[k+1] = temp; //x10 = k * 8 (find offset of the v[k]) //x10 = address of v[k] = address of v[0] + offset of v[k] //x9 = v[k] (save content of v[k] into x9 temp reg) //x11 = v[k+1] (load content of v[k+1] into x11) //v[k] = v[k+1] (overwrite v[k] mem location with v[k+1]) //v[k+1] = v[k] (overwrite v[k+1] mem location with v[k]) Quiz 2 question 2 (version 1; check slides) your quiz version is fine. //x0 = i, x1 = j, x2 = a[0], x3 = b[0] //assumption: elements in a and b are 1 word each. //multiply by 4 to convert word offset to byte offset. //compute the address of a[i-j] (base address + byte offset)

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