advertisement
Assembler
The Output Status (or error-tracking) window of Code Editor is where the status of file compiling and assembling resides. Each time you compile and assemble files, the Output Status window is cleared and the current status is entered as the process occurs.
Figure 5-1. Output Status Window
5.8
When compiling is complete, you the see the number of errors. Zero errors signify that the compilation and assemblage was successful. One or more errors indicate problems with one or more files.
This process reveals syntax errors. Such errors include missing input data and undeclared identifier . For a list of all identified compile (and build) errors with solutions see the PSoC
Designer Assembly Language User Guide. For further details on compiling and building see
“Building a Project” on page 103
in this guide.
At any time you can ensure a clean compile and assemble (or build) by accessing Project > Clean, then clicking the Compile/Assemble or Build icon. The “clean” deletes all lib\libPSoc.a, obj\*.o
, and lib\obj\*.o files. These files are regenerated upon a compile or build (in addition to normal compile and build activity).
Calling Assembly Functions From C
When one C function calls another, the compiler uses a simple layout for passing arguments that the caller and callee use to initialize and the access the values. Although you can use the same layout when a C function calls an assembly language routine, it is best to use of the alternate fastcall16 calling convention. Fastcall16 is directly supported by the C compiler though use of a pragma directive and is often more efficient than the convention used by C. In fact, fastcall16 is identical to the C calling convention except for simple cases when the parameters are passed and/or returned in the
CPU A and X registers. All user module API functions implement the fastcall16 interface for this reason.
■
■
■
There are four conditions to meet when using the fastcall16 interface:
The function must be tagged with a C #pragma fastcall16 directive
The function needs a C function prototype
■
The assembly function name must be the C function name prefixed with an underscore character (_).
The assembly function name must be exported.
100 PSoC Designer IDE Guide, Document # 001-42655 Rev *B
Assembler
For example, an assembly function that is passed a single byte as a parameter and has no return value looks like this:
C function declaration (typically in a .h header file)
#pragma fastcall16 send_byte void send_byte( char val);
C function call (in a .c file) send_byte( 0x37);
Assembly function definition (in an .asm file) export _send_byte
; Fastcall16 inputs (single byte)
; A – data value
; Fastcall16 return value (none)
_send_byte: mov reg[ PRT1DR],A ret
An assembly function that is passed two bytes and returns one byte might look like this:
C function declaration (typically in a .h header file)
#pragma fastcall16 read_indexed_reg char read_indexed_reg( char bank, char index);
C function call (in a .c file) val = read_indexed_reg( 0x01, index);
Assembly function definition (in an .asm file) export read_indexed_reg
; Read byte from specified IO register
; Fastcall16 inputs (two single bytes)
; A – bank number (0 or non-zero)
; X – register number
; Fastcall16 return value (single byte)
; A – read data
_read_indexed_reg:
cpl A
jnz get_data:
or F, FLAG_XIO_MASK; switch to bank 1 get_data:
mov A, reg[X]
and F, ~FLAG_XIO_MASK; make sure we’re in bank 0
ret
PSoC Designer IDE Guide, Document # 001-42655 Rev *B 101
Assembler
Functions with more complex input parameters or return values can be written using these tables.
Table 5-6. Pragma Fastcall16 Conventions for Argument Passing
Argument Type
Single Byte
Two Single Bytes
Double Byte
Pointer
All Others
A
A, X
X, A
A, X
Register
None
Argument Register
The argument is passed in A.
The first argument is passed in A, the second in X.
The MSB is passed in X, the LSB in A.
The MSB is passed in A, the LSB in X.
Arguments are stored on the stack in standard byte order and in reverse order or appearance. In other words, the MSB of the last actual parameter is pushed first and the LSB of the first actual parameter is pushed last.
Table 5-7. Pragma Fastcall16 Conventions for Return Value
Return Type
Single Byte
Double Byte
Pointer
All Others
A
X, A
A, X
Return
Register
None
Comment
The argument is returned in A.
The MSB is passed in X, the LSB in A.
The MSB is passed in A, the LSB in X.
Use a pass-by-reference parameter or global variable instead of returning arguments longer than 16 bits.
Note that the #pragma fastcall16 has replaced #pragma fastcall and use of #pragma fastcall is deprecated.
102 PSoC Designer IDE Guide, Document # 001-42655 Rev *B
advertisement
Related manuals
advertisement
Table of contents
- 8 Application Overview
- 8 Chip-Level Editor
- 9 System-Level Editor
- 9 Code Editor
- 10 Build Manager
- 10 Board Monitor
- 11 Debugger
- 11 Getting Help
- 11 Chapter Overviews
- 12 Support
- 12 Technical Support Systems
- 12 Product Upgrades
- 12 Conventions
- 13 Acronyms
- 14 References
- 14 Revision History
- 16 Chip-Level Editor Overview
- 17 Create a Project
- 19 Clone a Project
- 19 Updating Existing Projects
- 19 Placing User Modules
- 21 Rotating a Placement
- 21 Setting User Module Parameters
- 22 Global Resources
- 27 Project Backup Folder
- 27 Specifying Interconnects
- 28 Connecting User Modules
- 34 Digital Interconnect Row Input Window
- 35 Digital Interconnect Row Output Window
- 37 Specifying the Pinout
- 37 Port Connections
- 42 Port Drive Modes
- 43 Port Interrupts
- 44 Tracking Device Space
- 45 Design Rule Checker
- 46 Generating Application Files
- 47 Source Files Generated by Generate Project Operation
- 47 2.10.1 About the boot.asm File
- 48 Configuration Data Sheets
- 48 APIs and ISRs
- 49 2.12.1 Working with ISRs
- 50 2.12.2 Interrupt Vectors and the Chip-Level Editor
- 52 Dynamic Reconfiguration
- 52 2.13.1 Adding Configurations
- 53 2.13.2 Deleting Configurations
- 54 2.13.3 Renaming Configurations
- 54 2.13.4 Employing Dynamic Reconfiguration
- 60 System-Level Editor Overview
- 61 Create a New Project
- 61 Add Design Elements
- 62 Use Pop Up Menus
- 63 Use Navigation Tools
- 63 Use the Design Toolbar
- 64 Delete Elements
- 64 Save a Design
- 64 Simulating Your Design
- 64 Widgets
- 64 Navigation Tools
- 65 LOG.csv File
- 65 Simulation Controls
- 65 Drivers
- 65 Driver Types
- 66 Valuators
- 66 Interface Valuator
- 66 Transfer Function Valuator
- 67 Transfer Functions
- 67 Transfer Function Types
- 69 Authoring New Design Elements
- 70 Selecting a Configuration
- 70 Configuration Properties
- 71 BOM Vendor
- 71 Assign Pins Automatically
- 71 Assigning Pins
- 72 Pin Color Legend
- 72 Lock Pins
- 72 Unassign All Pins
- 72 Auto Assign
- 72 Generating Output
- 73 Developing Complex Designs
- 73 3.11.1 Preparing Your Design
- 78 Programming PSoC Flash Memory
- 79 Monitoring Your Design
- 80 3.13.1 Monitoring Your Board With the I2C-USB Bridge
- 82 3.13.2 Monitoring Your Board with Other Interfaces
- 82 Tuning Your Design
- 87 File Definitions and Recommendations
- 88 File Types and Extensions
- 89 Project File System
- 90 boot.asm
- 90 main.asm/main.c
- 90 PSoCConfig.asm
- 90 Additional Generated Files
- 92 Working in Code Editor
- 92 Modifying Files
- 93 Adding New Files
- 93 Adding Existing Files
- 93 Removing Files
- 94 Searching Files
- 95 Accessing the Assembler
- 95 The M8C Microprocessor (MCU)
- 96 Address Spaces
- 96 Instruction Format
- 96 Addressing Modes
- 97 Destination of Instruction Results
- 97 Assembly File Syntax
- 97 List File Format
- 98 Assembler Directives
- 99 Instruction Set
- 99 Compile and Assemble Files
- 100 Calling Assembly Functions From C
- 103 Building a Project
- 104 C Compiler
- 104 ImageCraft Compiler Options
- 105 HI-TECH Compliler Options
- 105 Linker
- 106 ImageCraft Specific Linker Options
- 106 HI-TECH Specific Linker Configuration Options
- 106 Customizing Linker Actions
- 107 Librarian
- 109 Debugger Components
- 111 Menu Options
- 112 Connecting to the ICE
- 113 Downloading to the Pod
- 114 Debug Strategies
- 115 Trace
- 116 Break Points
- 117 CPU and Register Views
- 118 Watch Variables
- 119 Dynamic Event Points
- 123 End Point Data
- 124 C Debugger
- 124 Connecting to the ICE
- 124 Enable Debug Mode
- 125 Downloading to the Device
- 125 C Debugger
- 125 Break Points
- 126 Watch Variables
- 130 Programming the Part
- 133 FPMP and PSoC Designer
- 134 About flashsecurity.txt
- 135 FPMP File Errors