Now that the project's configuration is set, you can assemble an assembly-code file. However, the project does not contain any source-code files at this point. You could create assembly *.asm and include *.inc files from scratch for this project. However, for simplicity's sake, you can copy and paste the main.asm and the derivative.inc files from the previous CodeWarrior project.
For this project, you should have a project directory named Model T. Within this folder, you should have another folder named Sources, which contains the two files described above. Using a text editor of your choice, modify the main.asm file so that it appears as the following listing shows:
;********************************************************************* ;* This stationery serves as the framework for a user application. * ;* For a more comprehensive program that demonstrates the more * ;* advanced functionality of this processor, please see the * ;* demonstration applications, located in the examples * ;* subdirectory of the "CodeWarrior for Microcontrollers V6.1" * ;* program directory. * ;********************************************************************* ; export symbols XDEF _Startup, main ; we use export '_Startup' as symbol. This allows us to ; reference '_Startup' either in the linker .prm file ; or from C/C++ later on XREF __SEG_END_SSTACK ; symbol defined by the linker ; for the end of the stack ; Include derivative-specific definitions INCLUDE 'derivative.inc' ; variable/data section MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition Counter: DS.B 1 FiboRes: DS.B 1 ; code section MyCode: SECTION main: _Startup: LDHX #__SEG_END_SSTACK ; initialize the stack pointer TXS CLI ; enable interrupts mainLoop: CLRA ; A contains counter cntLoop: INCA CBEQA #14,mainLoop ; larger values cause overflow. STA Counter ; update global. BSR CalcFibo STA FiboRes ; store result LDA Counter BRA cntLoop ; next round. ; Function to calculate fibonacci numbers. Argument is in A. CalcFibo: DBNZA fiboDo ; fiboDo INCA RTS fiboDo: PSHA ; the counter CLRX ; second last = 0 LDA #$01 ; last = 1 FiboLoop: PSHA ADD 1,SP PULX DBNZ 1,SP,FiboLoop FiboDone: PULH ; release counter RTS ; result in A
Now there are three files in the project: