Skip to main content

Printing like a pro

Printing in TempleOS means printing to the screen(not to paper). If you want to print a string,just type the string like this:

"Hello World\n";

Basic formatting

The print routine in TempleOS takes some (or no) arguments,you provide arguments like this:


The arguments are 1,2, and 3 here and the format code is d(Integer decimal). There are various formatting codes for different types of data,to use a floating point number,use n

"Pi is %n\n",3.14;

The basic formatting codes are:

SDefine stringU8*
CUppercase charactorU8/U64
p or PPointer to named symbolPointer
x or XHexidecimalPointer/I64
qQuoted string(turns '"' into escape sequences)U8*
QReverse quoted stringU8*
ZDefineLst entry(Takes 2 arguments)U8 * and I64
zSub-entry of \0 terminated string(Takes 2 arguments)U8 * and I64

z/Z Formating

DefineLst's are things whose items are separated by \0s,they look like this:


We can use the list like this:

I64 i;

Auxiliary value

The auxiliary value does various things for different format codes. For c,it repeats the character X times,we can do it like this:


For numbers,it will set the decimal point of the number(useful for F64's). For example if we want to view a number in units of 1000,we can do this

"%h3n\n",1234567.; //Be sure to use a . to get a F64

We get do negative numbers too for "milli" units


We can have the Print routine choose the auxiliary for us using "?".


This is really cool. We can use an arbitrary value as the auxiliary value using *.

 I64 repeat=10;