130 likes | 169 Views
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 How to Mix Languages Implementation – Apply Methods to the Serial to Parallel Lab
E N D
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 How to Mix Languages • Implementation – Apply Methods to the Serial to Parallel Lab • Improvements – Minimize Code and Include Other Capabilities
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.
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.
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.
Original Code New Code Changes to the C Code
Changes to the C Code Original Code New Code *Comment out shiftOut and blinkAll entirely
Changes to the C Code Original Code New Code
Changes to the Assembly Code Original Code New Code
Changes to the Assembly Code Original Code New Code
Improvements • Minimize spiTx • Incorporate blinkAll • Pass Parameter from Assembly to C:
References • 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 Syntax http://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