34
ImageCraft Assembly Language Guide, Document # 001-44475 Rev. *B
ImageCraft Assembler
The following is an example of a PSoC device HEX file for a very small program.
3.6
Convention for Restoring Internal Registers
When calling PSoC user module APIs and library functions, it is the caller's responsibility to preserve
the CPU_A and CPU_X registers. This means that if the current context of the code has a value in
the CPU_X and/or CPU_A register that must be maintained after the API call, then the caller must
save (
push
on the stack) and then restore (
pop
off the stack) them after the call has returned.
Even though some of the APIs do preserve the CPU_X and CPU_A register, Cypress reserves the
right to modify the API in future releases in such a manner as to modify the contents of the CPU_X
and CPU_A registers. Therefore, it is very important to observe the convention when calling from
assembly. Note that the C compiler observes this convention.
3.7
Compiling a File into a Library Module
Each library module is simply an object file. Therefore, to create a library module, you need to com-
pile a source file into an object file. There are several ways that you can create a library.
One method is to create a brand new project. Add all the necessary source files that you wish to be
added to your custom library to this project. You then add a project-specific MAKE file action to add
those project files to a custom library.
For example, a blank project is created for any type of part, since interest is only in using 'C' and/or
assembly, the Application Editor, and the Debugger. The goal for creating a custom library is to cen-
tralize a set of common functions that can be shared between projects. These common functions, or
primitives, have deterministic inputs and outputs. Another goal for creating this custom library is to
be able to debug the primitives using a sequence of test instructions (e.g., a regression test) in a
source file that should not be included in the library. No user modules are involved in this example.
Example Code:
mov
A, reg[0x04]
inc
A
mov
reg[0x04], A
Example ROM File:
5D 04 74 60 04
Example HEX File:
:400000005d0474600430303030303030303030303030303030303
030303030303030303030303030303030303030303030303030303
0303030303030303030303030303077
:40004000303030303030303030303030303030303030303030303
030303030303030303030303030303030303030303030303030303
0303030303030303030303030303080
Records removed to make example compact.
:403fc000303030303030303030303030303030303030303030303
030303030303030303030303030303030303030303030303030303
03030303030303030303030303030c1
:020000040010ea
:40000000fffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffff
fffffffffffffffffffffffffffff00
:020000040020da
:020000000049b5
:00000001ff
Summary of Contents for PSoC DESIGNER ImageCraft M8C
Page 6: ...6 ImageCraft Assembly Language Guide Document 001 44475 Rev B Contents Feedback ...
Page 10: ...10 ImageCraft Assembly Language Guide Document 001 44475 Rev B Introduction Feedback ...
Page 24: ...24 ImageCraft Assembly Language Guide Document 001 44475 Rev B M8C Microprocessor Feedback ...
Page 95: ...ImageCraft Assembly Language Guide Document 001 44475 Rev B 95 Assembler Directives Feedback ...
Page 96: ...96 ImageCraft Assembly Language Guide Document 001 44475 Rev B Assembler Directives Feedback ...
Page 104: ...104 ImageCraft Assembly Language Guide Document 001 44475 Rev B Feedback ...
Page 108: ...108 ImageCraft Assembly Language Guide Document 001 44475 Rev B Index Feedback ...