Due date: See Class Webpage
Observe the Emory Honor Code when doing this (and all other) homework.
Use project code hw9
You will have create a hw9 folder containing these program files:
hw9.s Skeleton assembler program for HW9 |
|
In depth understanding about (1) how a computer accesses variables (especially structured varaibles) in memory and (2) using registers in computations forms the basis of assembler programming.
To get you going with programming in ARM, I have provided the skeletal program hw9.s. In the preparation step, you have made a copy of this file into your CS255 project directory.
The skeletal program hw9.s has 10 sections, labeled as Q1, Q2, ..., Q10 corresponding to questions 1 through 10 (see below).
Write the assembler instructions the each answer in the corresponding section of the hw9.s file.
The variables definition section of the skeletal program hw9.s contains the following "high level language" variable:
byte ans_b; // Variables containing answers to the questions short ans_s int ans_i byte b = 2; // Variables used as index to arrays short s = 3; int i = 4; // 3 arrays byte A[] = {11, -22, 33, -44, 55, -66, 77, -88, 99, -123}; short B[] = {111, -222, 333, -444, 555, -666, 777, -888, 999, -5432} int C[] = {1111, -2222, 3333, -4444, 5555, -6666, 7777, -8888, 9999, -9876} // One linked list class list { int value1; // 4 bytes short value2; // 2 bytes short value3; // 2 bytes list next; } list head; // The linked list has been set up |
These variables are defined in assembler as follows:
************************************** * Variables used to display output ************************************** ans_b: .skip 1 * In Java: byte ans_b; ans_w: .skip 2 * In Java: short ans_b; ans_l: .skip 4 * In Java: int ans_b; **************************************** * Indices used to select array elements **************************************** i: .byte 2 * In Java: byte i = 2; j: .2byte 3 * In Java: short w = 3; k: .4byte 4 * In Java: int k = 4; **************************************** * 3 arrays of 10 elements **************************************** A: .byte 11, -22, 33, -44, 55, -66, 77, -88, 99, -123 B: .2byte 111, -222, 333, -444, 555, -666, 777, -888, 999, -5432 C: .4byte 1111, -2222, 3333, -4444, 5555, -6666, 7777, -8888, 9999, -9876 Comment: A is an array of 10 bytes, Comment: B is an array of 10 shorts and Comment: C is an array of 10 integers. ******************************************************** * One linked list starting at head * * head ->[1234,89,-11]->[2345,78,66]->[-3456,67,44] * ->[4567,56,77]->[5678,45,44] ******************************************************** head .4byte list1 Comment: head points to the first element of a linked list. The linked list has been set up already. Each linked list element has the following structure: class list { int value1; // 4 bytes short value2 // 2 bytes short value3 // 2 bytes list next; // points to the next list element } |
The homework assignment questions will ask you to:
|
Be very careful and use the correct operand size.
Q1: ans_s = B[5]; (ans_s: -666) Q2: ans_b = A[3]; (ans_b: -44) Q3: ans_i = C[j]; (ans_i: -4444) Q4: ans_i = B[k - j]; (ans_i: -222) Q5: ans_s = C[i + j]; (ans_s: -6666) Q6: ans_i = A[k] - B[k]; (ans_i: 55 - 555 = -500) Q7: ans_s = B[A[i] - 30]; (ans_s: B[33 - 30] = B[3] = -444) Q8: ans_s = B[18]; (ans_s: 5555, can you explain why ?) Q9: ans_b = head.value2; (ans_b: 89) Q10: ans_s = head.next.next.value3; (ans_s: 44) |
The following is a general guideline for debugging assembler programs:
|
(More information on debug: read the Egtapi documentation)
A concrete Example:
|
You must make the extenion request before the deadline of the homework
Your request will be successful if you have not exceeded the maximum number of "free" (no-questions-asked) requests allowed