Replacing library functions

Replacing library functions

Post by Andrew Mil » Thu, 23 Apr 1998 04:00:00



Hi, we're using the software development kit to compile C code for an ARM
board we've developed.  We want to redirect putc and getc to use the
serial port on the board but we can't seem to get it to replace the
library functions.  Here's a simple test program we're using:

In hellow.c

#include <stdio.h>

int main(void)
{
   unsigned char value;

   value = getc(0);
   putc(value, 0);

   return(0);

Quote:}

In newstd.s:

; Replacement functions for stdio/stdlib

 GET serialm.h

 AREA |newstd|, CODE, READONLY

getc
 SWI  Serial_GetC
 MOVS PC,R14

putc
 SWI  Serial_PutC
 MOVS PC,R14

 END

Why doesn't this work?  Secondly, what kind of environment do we need to
setup before entering our code i.e. setting R13 to stack, etc.

Thanks in advance

Andrew
--
Andrew D Miles
Department of Electronics and Computer Science
Southampton University, UK

 
 
 

Replacing library functions

Post by Matthew Wilc » Thu, 23 Apr 1998 04:00:00


: Hi, we're using the software development kit to compile C code for an ARM
: board we've developed.  We want to redirect putc and getc to use the
: serial port on the board but we can't seem to get it to replace the
: library functions.  Here's a simple test program we're using:

What command line are you using to compile the code?

: Why doesn't this work?  Secondly, what kind of environment do we need to
: setup before entering our code i.e. setting R13 to stack, etc.

You need to write code which is compatible with APCS.  I don't have my APCS
docs to hand with me right now, but the caller guarantees the callee that:
r13 is a valid stack with at least 256 bytes available on it, r0-r3 may be
corrupted and some other icky things like stack limits and frame pointers.
You should have APCS docs in your SDK, if not give me a shout and I may be
able to find you a copy.

--
Set Alias$Case Set Alias$[ |||| |MSet Alias$Otherwise Set Alias$[ \ Matthew
"" |MSet Alias$When If %0=%%0 Then Set Alias$[ "" ||MIf %0=%%0    \ Wilcox
Then Set Alias$Otherwise Set Alias$[ |||||||||||||||| ||MIf       \
%0=%%0 Then Set Alias$When Set Alias$[ ||||||||||||||||

 
 
 

Replacing library functions

Post by Andrew Mil » Fri, 24 Apr 1998 04:00:00



: : Hi, we're using the software development kit to compile C code for an ARM
: : board we've developed.  We want to redirect putc and getc to use the
: : serial port on the board but we can't seem to get it to replace the
: : library functions.  Here's a simple test program we're using:

Duh! Not EXPORTing the functions within the assembly listing.

: : Why doesn't this work?  Secondly, what kind of environment do we need to
: : setup before entering our code i.e. setting R13 to stack, etc.

: You need to write code which is compatible with APCS.  I don't have my APCS
: docs to hand with me right now, but the caller guarantees the callee that:
: r13 is a valid stack with at least 256 bytes available on it, r0-r3 may be
: corrupted and some other icky things like stack limits and frame pointers.
: You should have APCS docs in your SDK, if not give me a shout and I may be
: able to find you a copy.

Cheers, I've got all the APCS in my PRMs somewhere so thats no problem.

Andrew
--

 
 
 

1. Function Library

I have now finished coding my magnum opus, which is a large data display
and saving application. It is written in BASIC, and has a really good set
of functions, which, since in two weeks time I will no longer have any
access to an Acron machine, I would be pleased if somebody else found
useful :) Little things like interactive help on menus or dynamic areas
(THHeap) or the window iconise protocol  - all these often come up on this
newsgroup...

PS The program writes a graph and text to a Drawfile, and the graph only
to a DXF file for PC compatibility (before you say anything, part of my
brief was to design a program for acorn - PC translation).

Hope this lot is of use to somebody out there...

Will

2. Purchasing Curriculum

3. C library functions and _kernel_oserror

4. CGI's in RealBasic or C

5. Adding a function to a C/C++ library

6. Electronic parts Fleamarket 03-18-2000

7. libraries for "special" drawing functions?

8. Java in !Fresco

9. Class library: ARMage library

10. Replace bulky monitors with LCDs

11. A4 replacing cells in battery pack

12. Replacing A4 battery cells

13. Replacing original 420MB with 2GB IDE drive - Help required