Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!ut-sally!seismo!mcvax!cernvax!ethz!claudio From: claudio@ethz.UUCP (Claudio Nieder) Newsgroups: net.micro.amiga Subject: Re: printf does not take 10K Message-ID: <374@ethz.UUCP> Date: Thu, 3-Jul-86 19:45:22 EDT Article-I.D.: ethz.374 Posted: Thu Jul 3 19:45:22 1986 Date-Received: Fri, 4-Jul-86 08:48:22 EDT References: <8606242147.AA12273@pavepaws> Reply-To: claudio@ethz.UUCP (Claudio Nieder) Organization: CS Department, ETH Zuerich, Switzerland Lines: 120 Hello Matt, you asked about printf and its restrictions. I disassembled AMIGA.LIB and saw that there are a few of the stdio-routines. These implementations use exec's private function "RawDoFmt" which does the output conversion according to the format string. RawDoFmt supports - d signed decimal - x hexadecimal - s string - c character left- and right adjust and leading nulls are supported. Below you find a small program running with the PD Modula-2 Compiler which shows the use of RawDoFmt. The parameters of RawDoFmt are: - a buffer - the format string - the pointer to the arguments (some kind of stack pointer) - a subroutine to handle the output character, very flexible! Note: RawDoFmt is a PRIVATE and UNDOCUMENTED exec-function, be carefull. PS: With the PD Modula-2 Compiler (Fish Disk #24) a program that I wrote to disassemble any object files of the amiga is included. The program is called "ObjDump". I used this program to disassemble AMIGA.LIB and LC.LIB and it was very informal to read this code. Hope that helps, from the home of the amiga modula-2 compiler kussi (****************************************************************************** Name : RawDoFmtTest.MOD Version : 1.0 Purpose : Access To Exec's Private Procedure RawDoFmt Author : ms Created : 12.4.86 11:15 ms Modified : Comment : Used to implement c-procedure [s, f] printf not all standard types are supported! no floating point args! ******************************************************************************) MODULE RawDoFmtTest; FROM Terminal IMPORT WriteString, Write, WriteLn; FROM AMIGABase IMPORT Regs, LibCall, ExecBase; FROM SYSTEM IMPORT ADR, LONG, ADDRESS; TYPE Arguments = ARRAY [0..15] OF CARDINAL; VAR s, st: ARRAY [0..127] OF CHAR; args: Arguments; PROCEDURE RawDoFmt(VAR s: ARRAY OF CHAR; format: ARRAY OF CHAR; args: ADDRESS); VAR r: Regs; stuffChar: LONGCARD; (* stuffChar is a routine that handles the output character stream, here stuffChar stores the characters into the output string *) BEGIN format[HIGH(format)]:=0C; stuffChar:=LONG(16C0H, (* MOVE.B D0, (A3)+ *) 4E75H); (* RTS *) r.d[0]:=32; r.a[3]:=ADR(s); r.a[0]:=ADR(format); r.a[1]:=args; r.a[2]:=ADR(stuffChar); LibCall(ExecBase(), -522, r); END RawDoFmt; BEGIN WriteString('Using RawDoFmt to get formatted output'); WriteLn; WriteString('======================================'); WriteLn; WriteLn; args[0]:=000FFH; args[1]:=0AAAAH; args[2]:=01234H; args[3]:=05678H; RawDoFmt(s, "Hex Long: %8lx Hex Short: %5x Hex Leading Nulls: %08x ", ADR(args)); WriteString(s); WriteLn; args[0]:=SHORT(SHIFT(7777777D, -16)); args[1]:=SHORT( 7777777D); args[2]:=1001; args[3]:=1002; RawDoFmt(s, "Dec Long: %8ld Dec Short: %5d Dec Leading Nulls: %08d ", ADR(args)); WriteString(s); WriteLn; WriteLn; st:="This is a test"; args[0]:=SHORT(SHIFT(ADR(st), -16)); args[1]:=SHORT(ADR(st)); RawDoFmt(s, "string left adj >%-30s< ", ADR(args)); WriteString(s); WriteLn; RawDoFmt(s, "string right adj >%30s< ", ADR(args)); WriteString(s); WriteLn; RawDoFmt(s, "string as it is >%s< ", ADR(args)); WriteString(s); WriteLn; WriteLn; END RawDoFmtTest. -- claudio@ethz.uucp (* --------------------------------------------------------------------- Disclaimer: I'm not working for ETH-Zurich! I'm just a student of computer science. --------------------------------------------------------------------- *)