Add a function forth_printf() which prints to openbios stdout.

Signed-off-by: Laurent Vivier <Laurent@vivier.eu>



git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@628 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Laurent Vivier
2009-11-22 09:50:54 +00:00
parent 26c129730b
commit 144d172001
2 changed files with 25 additions and 0 deletions

View File

@@ -16,6 +16,8 @@
#include "openbios/config.h"
#include "libc/string.h"
#include "libc/vsprintf.h"
#include "openbios/bindings.h"
/* strncpy without 0-pad */
char *
@@ -24,3 +26,24 @@ strncpy_nopad( char *dest, const char *src, size_t n )
int len = MIN( n, strlen(src)+1 );
return memcpy( dest, src, len );
}
/* printf */
int forth_printf( const char *fmt, ... )
{
char buf[512];
va_list args;
int i;
va_start(args, fmt);
i = vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
PUSH((ucell)buf);
PUSH(i);
fword("type");
return i;
}