Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather...
-
Upload
myra-morton -
Category
Documents
-
view
212 -
download
0
Transcript of Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather...
![Page 1: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/1.jpg)
Mixed C and Assembly
By Justin Kim
![Page 2: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/2.jpg)
Mixed C and Assembly
• Set-up – Create Project and Gather Essential Files
• Strategy and Method – Assigning Tasks and How to Mix Languages
• Implementation – Apply Methods to the Serial to Parallel Lab
• Improvements – Minimize Code and Include Other Capabilities
![Page 3: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/3.jpg)
Set-up• Create a New Project named MixedC and a c-file titled
MixedC.c (Refer to the Blink Lab Instructions from the EE-347 website.)
• Go to the EE-346 website and download AmazingLab, LabC, and sketch_shiftOut_16bit. Extract the following documents from the respected files:– AmazingLab spi.inc – LabC m328Pdef.h– sketch_shiftOut_16bit sketch_shiftOut_16bit.c
• Change the spi.inc document to a .S file (spi.S) and move to the MixedC Project File. Move the m328Pdef.h to the MixedC Project File as well. Copy the code from the sketch_shiftOut_16bit.c document and paste it into the MixedC.c document.
• Add all header files and .c files from C:\arduino-0015\hardware\cores\arduino to the MixedC Project File.
![Page 4: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/4.jpg)
Strategy and Method
• Determine the operations needed• Understand the strengths of each
language• Figure out how to execute goals with each
language• Divide the tasks between the C functions
and the assembly subroutines.• Learn to globalize subroutines, use proper
syntax for the specific compiler, and pass parameters between each language.
![Page 5: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/5.jpg)
Implementation• Imitate the Serial to Parallel Lab by Mixing
C and Assembly• Learn the GCC syntax• Use C as the main program and Assembly
to send the information to the displays• Globalize the subroutines, use correct
syntax, and pass a parameter (a byte) from C to Assembly using mask and register 24
• Delete or Comment out any unnecessary code.
![Page 6: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/6.jpg)
Changes to the C Code
Original Code New Code
![Page 7: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/7.jpg)
Changes to the C Code
Original Code New Code
*Comment out shiftOut and blinkAll entirely
![Page 8: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/8.jpg)
Changes to the C Code
Original Code New Code
![Page 9: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/9.jpg)
Changes to the Assembly Code
Original Code New Code
![Page 10: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/10.jpg)
Changes to the Assembly Code
Original Code New Code
![Page 11: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/11.jpg)
Improvements
• Minimize spiTx• Incorporate blinkAll• Pass Parameter from Assembly to C:
![Page 12: Mixed C and Assembly By Justin Kim. Mixed C and Assembly Set-up – Create Project and Gather Essential Files Strategy and Method – Assigning Tasks and.](https://reader035.fdocuments.us/reader035/viewer/2022080915/56649d6e5503460f94a4fca8/html5/thumbnails/12.jpg)
• EE-346 website – Labs and References
http://www.cecs.csulb.edu/~hill/ee346/
• EE-347 website – Labs and References
http://www.cecs.csulb.edu/~hill/ee347/
• Equate Statement Syntaxhttp://www.experts-exchange.com/Programming/Languages/Assembly/Q_23559266.html
• Examples of Mixed C and Assembly
http://people.msoe.edu/~barnicks/courses/CE-2800/documents/Mixing%20C%20and%20assembly%20language%20programs.pdf
References