PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
asm_echo.s
Go to the documentation of this file.
1 /** \file
2  Demonstrates how to call C functions from assembly lanaguage.
3  Implements a UART1 character echo, and calls the
4  \ref configBasic, \ref inChar, and \ref outChar functions.
5 */
6 /** \cond nodoxygen */
7 .include "p24Hxxxx.inc" ; Include processor-specific headers
8 
9 .global _main ; Make _main visible outside
10  ; this file so C startup code
11  ; can call it
12 
13  .section psv psv ; Place following statements in PSV space
14 HELLO_MSG: .asciz "asm_echo.s ready!\n" ; Define a null-terminated ASCII string
15 
16 
17 ;..............................................................................
18 ;Code Section in Program Memory
19 ;..............................................................................
20 
21 .text ;Start of Code section
22 
23 _main: ; _main called after C startup code runs
24  mov #HELLO_MSG,W0 ; Equivalent to
25  call _configBasic ; configBasic(HELLO_MSG) in C
26 
27 while1: ; while (1) {
28  call _inChar ; W0 = inChar();
29  inc W0, W0 ; W0 = W0 + 1;
30  call _outChar ; outChar(W0);
31  goto while1 ;}
32 
33 .end ;End of program code in this file
34 
35 /** \endcond */