Skip to contentSkip to conversation

how to include mips assembly in c code?

DISCUSSION durai 5 participants 5 messages Oct 9, 2003 MIPS

lore
Share & tools
lore

durai

author
#0 lore raw

hello,
I am having the following assembly code and i wanted to call this function from a c code. can anybody tell me how to include this code in a c program?

/****************************************************************************** *
* sysWbFlush - flush the write buffer
*
* This routine flushes the write buffers, making certain all
* subsequent memory writes have occurred. It is used during critical periods
* only, e.g., after memory-mapped I/O register access.
*
* RETURNS: N/A

* sysWbFlush (void)

*/
.ent sysWbFlush
sysWbFlush:

        li      t0, K1BASE              /* load uncached address        */
        lw      t0, 0(t0)               /* read in order to flush       */
        j       ra                      /* return to caller             */
        .end    sysWbFlush

regards
durai

#1 lore raw
Quoted 3 lines · durai

I am having the following assembly code and i wanted to call this function from a c code.
can anybody tell me how to include this code in a c program?

Several solutions:

  #define sysWbFlush()	 do { (*(volatile unsigned int *)K1BASE) } while (0)

Or using your existing code:

  extern void sysWbFlush(void);

the call as

  sysWbFlush();

No point in using inline assembler for such a small fragment.

Anyway - I suggest you dump this code and look at <asm/wbflush.h>.

Ralf

#2 lore raw
In reply to durai

I feel compelled to point out that the source file you are quoting looks suspiciously like it came from VxWorks, which means it is likely copyright Wind River Systems. Using their code without permission would be illegal.

Matt

Quoted 27 lines · durai

hello,
I am having the following assembly code and i wanted to call this function from a c code. can anybody tell me how to include this code in a c program?

/****************************************************************************** *
* sysWbFlush - flush the write buffer
*
* This routine flushes the write buffers, making certain all
* subsequent memory writes have occurred. It is used during critical periods
* only, e.g., after memory-mapped I/O register access.
*
* RETURNS: N/A

* sysWbFlush (void)

*/
.ent sysWbFlush
sysWbFlush:

        li      t0, K1BASE              /* load uncached address        */
        lw      t0, 0(t0)               /* read in order to flush       */
        j       ra                      /* return to caller             */
        .end    sysWbFlush

regards
durai

Signature · 2 lines
Matthew Dharm                              Work: [email protected]
Senior Software Designer, Momentum Computer
#3 lore raw

Here we go - whole six lines of code! What a terrible copyright infigement!

Quoted 39 lines · Matthew Dharm

I feel compelled to point out that the source file you are quoting looks suspiciously like it came from VxWorks, which means it is likely copyright Wind River Systems. Using their code without permission would be illegal.

Matt

Quoted 27 lines · durai

hello,
I am having the following assembly code and i wanted to call this function from a c code. can anybody tell me how to include this code in a c program?

/****************************************************************************** *
* sysWbFlush - flush the write buffer
*
* This routine flushes the write buffers, making certain all
* subsequent memory writes have occurred. It is used during critical periods
* only, e.g., after memory-mapped I/O register access.
*
* RETURNS: N/A

* sysWbFlush (void)

*/
.ent sysWbFlush
sysWbFlush:

        li      t0, K1BASE              /* load uncached address        */
        lw      t0, 0(t0)               /* read in order to flush       */
        j       ra                      /* return to caller             */
        .end    sysWbFlush

regards
durai

Signature · 2 lines
Matthew Dharm                              Work: [email protected]
Senior Software Designer, Momentum Computer
#4 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

Here we go - whole six lines of code! What a terrible copyright infigement!

Six lines of code, and 12 lines of obvious comments, and pretty obvious function names - this is exactly what the Evil Empire (like SCO et al) is looking for.

Please try and be a little less ignorant.

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: [email protected]
In Nature there are neither rewards nor punishments, there are conse-
quences.                                            -- R.G. Ingersoll