spo600:64-bit_assembly_language_lab
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
spo600:64-bit_assembly_language_lab [2024/05/15 18:14] – external edit 127.0.0.1 | spo600:64-bit_assembly_language_lab [2025/02/11 12:26] (current) – chris | ||
---|---|---|---|
Line 5: | Line 5: | ||
Perform this lab on [[SPO600 Servers]] (you may use your own systems if they are of the right architecture and appropriately configured). | Perform this lab on [[SPO600 Servers]] (you may use your own systems if they are of the right architecture and appropriately configured). | ||
- | ===== Lab 3 ===== | + | ===== Lab 5 ===== |
==== Code Examples | ==== Code Examples | ||
Line 43: | Line 43: | ||
==== Optional Investigation | ==== Optional Investigation | ||
- | These steps were performed in the lecture class. | + | **These steps were performed in the lecture class.** |
1. Build and run the C version(s) of the program for x86_64 and aarch64, using '' | 1. Build and run the C version(s) of the program for x86_64 and aarch64, using '' | ||
Line 49: | Line 49: | ||
2. Use the '' | 2. Use the '' | ||
- | 3. Review, build, and run the x86_64 assembly language programs using '' | + | 3. Compare the disassembled output from step 2 above with the assembly language output of the C compiler, produced by running '' |
+ | |||
+ | 3. Review, build, and and run the aarch64 assembly language program (on the [[SPO600 Servers|aarch64 class server]]) using '' | ||
+ | |||
+ | 4. Review, build, and run the x86_64 assembly language programs using '' | ||
- | 4. Build and run the assembly language version of the program for aarch64 using '' | ||
==== AArch64 (Complete this part in your in-class breakout group, if possible) | ==== AArch64 (Complete this part in your in-class breakout group, if possible) | ||
- | The steps in the previous section were demonstrated in the class. Perform these steps in your breakout group using the "mob programming" | + | The steps in the previous section were demonstrated in the class. |
+ | |||
+ | Perform these steps in your breakout group using the "mob programming" | ||
+ | |||
+ | 0. Have the group driver share their screen, log into the [[SPO600 Servers|aarch64 server]], and unpack the archive (above). | ||
1. Review, build, and run the aarch64 assembly language programs. Take a look at the code using '' | 1. Review, build, and run the aarch64 assembly language programs. Take a look at the code using '' | ||
- | 2. Here is a basic loop in AArch64 assembler - this loops from 0 to 9, using r19 as the index (loop control) counter: | + | 2. Here is a basic loop in AArch64 assembler - this loops from 0 to 5, using r19 as the index (loop control) counter: |
< | < | ||
Line 65: | Line 72: | ||
| | ||
min = 0 /* starting value for the loop index; **note that this is a symbol (constant)**, | min = 0 /* starting value for the loop index; **note that this is a symbol (constant)**, | ||
- | max = 10 /* loop exits when the index hits this number (loop condition is i<max) */ | + | max = 6 /* loop exits when the index hits this number (loop condition is i<max) */ |
| | ||
| | ||
loop: | loop: | ||
+ | |||
/* ... body of the loop ... do something useful here ... */ | /* ... body of the loop ... do something useful here ... */ | ||
- | add x19, x19, 1 | + | |
- | | + | add x19, x19, 1 /* increment the loop counter */ |
- | | + | |
- | | + | |
+ | |||
+ | | ||
| | ||
| | ||
Line 80: | Line 90: | ||
< | < | ||
- | Loop | ||
- | Loop | ||
- | Loop | ||
- | Loop | ||
Loop | Loop | ||
Loop | Loop | ||
Line 99: | Line 105: | ||
Loop: 3 | Loop: 3 | ||
Loop: 4 | Loop: 4 | ||
- | Loop: 5 | + | Loop: 5</ |
- | Loop: 6 | + | |
- | Loop: 7 | + | |
- | Loop: 8 | + | |
- | Loop: 9</ | + | |
Character conversion tip: In order to print the loop index value, you will need to convert from an integer to digit character. In ASCII/ | Character conversion tip: In order to print the loop index value, you will need to convert from an integer to digit character. In ASCII/ | ||
Line 109: | Line 111: | ||
For reference, here is a [[6502 Counting Loop Example|6502 implementation of this loop]]. | For reference, here is a [[6502 Counting Loop Example|6502 implementation of this loop]]. | ||
- | 3. Extend the AArch64 code to loop from 00-30, printing each value as a 2-digit decimal number. | + | 3. Extend the AArch64 code to loop from 00-32, printing each value as a 2-digit decimal number. |
2-Digit Conversion tip: You will need to take the loop index and convert it into separate digits by dividing by 10; the quotient will be the first digit and the remainder will be the second digit. For example, if the loop index value is 25 in decimal, dividing by 10 will yield a quotient of 2 and a remainder of 5. You will then need to convert each digit into a character (using the same approach used in the single-digit loop). Read the description of the division instruction carefully. On x86_64, you need to set up specific registers before performing a division. On AArch64, you will need to use a second instruction to find the remainder after a division. | 2-Digit Conversion tip: You will need to take the loop index and convert it into separate digits by dividing by 10; the quotient will be the first digit and the remainder will be the second digit. For example, if the loop index value is 25 in decimal, dividing by 10 will yield a quotient of 2 and a remainder of 5. You will then need to convert each digit into a character (using the same approach used in the single-digit loop). Read the description of the division instruction carefully. On x86_64, you need to set up specific registers before performing a division. On AArch64, you will need to use a second instruction to find the remainder after a division. | ||
- | 4. Change the code as needed to suppress the leading zero (printing 0-30 instead of 00-30). To do this, you'll need to add a conditional into your code (the equivalent of an " | + | 4. Change the code as needed to suppress the leading zero (printing 0-32 instead of 00-32). To do this, you'll need to add a conditional into your code (the equivalent of an " |
+ | |||
+ | 5. Make a copy of the code and change it to output in hexadecimal (0-20) instead of decimal (0-32). | ||
==== x86 (Complete this part after class) ==== | ==== x86 (Complete this part after class) ==== | ||
Line 125: | Line 129: | ||
| | ||
min = 0 /* starting value for the loop index; **note that this is a symbol (constant)**, | min = 0 /* starting value for the loop index; **note that this is a symbol (constant)**, | ||
- | max = 10 /* loop exits when the index hits this number (loop condition is i<max) */ | + | max = 5 /* loop exits when the index hits this number (loop condition is i<max) */ |
| | ||
| | ||
loop: | loop: | ||
/* ... body of the loop ... do something useful here ... */ | /* ... body of the loop ... do something useful here ... */ | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
+ | | ||
+ | **Note:** The x86 division instruction is quite a bit different from the aarch64 division instructions. Read the documentation for the instructions carefully (either in the quick start notes or the reference manual). | ||
==== Deliverables | ==== Deliverables |
spo600/64-bit_assembly_language_lab.1715796870.txt.gz · Last modified: 2024/05/15 18:14 by 127.0.0.1