mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-26 15:26:43 +00:00
337 lines
30 KiB
HTML
Executable file
337 lines
30 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V1.07">
|
|
<style type="text/css">
|
|
body {background-color:#1f1f1f;}
|
|
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
|
|
.cF1{color:#4f84a6;background-color:#1f1f1f;}
|
|
.cF2{color:#73a255;background-color:#1f1f1f;}
|
|
.cF3{color:#297582;background-color:#1f1f1f;}
|
|
.cF4{color:#b34f4b;background-color:#1f1f1f;}
|
|
.cF5{color:#8a52c3;background-color:#1f1f1f;}
|
|
.cF6{color:#b7822f;background-color:#1f1f1f;}
|
|
.cF7{color:#444444;background-color:#1f1f1f;}
|
|
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
|
|
.cF9{color:#94bfde;background-color:#1f1f1f;}
|
|
.cFA{color:#a1ce97;background-color:#1f1f1f;}
|
|
.cFB{color:#6db4be;background-color:#1f1f1f;}
|
|
.cFC{color:#e88e88;background-color:#1f1f1f;}
|
|
.cFD{color:#ca94e8;background-color:#1f1f1f;}
|
|
.cFE{color:#d4b475;background-color:#1f1f1f;}
|
|
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF5> ZealC</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a>ZealC is a fork of HolyC. The only changes to Terry's HolyC compiler are reformatting, label renames, bugfixes, and additions.
|
|
<a name="l4"></a>Little to no functionality is removed, and nothing is fundamentally altered. Code incompatibilities are usually due to Kernel,
|
|
<a name="l5"></a>System, or user methods changing in name and/or functionality, rather than any differences in the Compiler. See the </span><span class=cF4>
|
|
<a name="l6"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/System/Utils/ConversionScript.ZC.html#l1"><span class=cF4>Conversion Script</span></a><span class=cF0> for help porting HolyC code to ZealC.
|
|
<a name="l7"></a>
|
|
<a name="l8"></a>
|
|
<a name="l9"></a>* See </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/CompilerOverview.DD.html#l1"><span class=cF4>::/Doc/CompilerOverview.DD</span></a><span class=cF0>.
|
|
<a name="l10"></a>
|
|
<a name="l11"></a>* See </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/ScopingLinkage.DD.html#l1"><span class=cF4>Scoping and Linkage</span></a><span class=cF0> for details on </span><span class=cF2>extern</span><span class=cF0>, </span><span class=cF2>import</span><span class=cF0>, </span><span class=cF2>_extern</span><span class=cF0>, </span><span class=cF2>_import</span><span class=cF0>, etc.
|
|
<a name="l12"></a>
|
|
<a name="l13"></a>* Built-in types include </span><span class=cF2>I0, I8, I16, I32, I64</span><span class=cF0> for signed 0-8 byte ints and </span><span class=cF2>U0, U8, U16, U32, U64</span><span class=cF0> for unsigned 0-8 byte ints
|
|
<a name="l14"></a>and </span><span class=cF2>F64</span><span class=cF0> for 8 byte floats.
|
|
<a name="l15"></a>
|
|
<a name="l16"></a></span><span class=cF2> U0 void, but ZERO size!
|
|
<a name="l17"></a> I8 char
|
|
<a name="l18"></a> U8 unsigned char
|
|
<a name="l19"></a> I16 short
|
|
<a name="l20"></a> U16 unsigned short
|
|
<a name="l21"></a> I32 int
|
|
<a name="l22"></a> U32 unsigned int
|
|
<a name="l23"></a> I64 long (64-bit)
|
|
<a name="l24"></a> U64 unsigned long (64-bit)
|
|
<a name="l25"></a> F64 double</span><span class=cF0>
|
|
<a name="l26"></a> </span><span class=cF4>no F32 float.</span><span class=cF0>
|
|
<a name="l27"></a>
|
|
<a name="l28"></a>* Function with no args, or just default args can be called without parentheses.
|
|
<a name="l29"></a>
|
|
<a name="l30"></a> ></span><span class=cF2>Dir("*");</span><span class=cF0>
|
|
<a name="l31"></a> ></span><span class=cF2>Dir();</span><span class=cF0>
|
|
<a name="l32"></a> ></span><span class=cF2>Dir;</span><span class=cF0>
|
|
<a name="l33"></a>
|
|
<a name="l34"></a>* Default args don't have to be on the end. This code is valid:
|
|
<a name="l35"></a> </span><span class=cF2>U0 Test(I64 i=4, I64 j, I64 k=5)
|
|
<a name="l36"></a> {
|
|
<a name="l37"></a> Print("%X %X %X\n", i, j, k);
|
|
<a name="l38"></a> }
|
|
<a name="l39"></a>
|
|
<a name="l40"></a> Test(, 3);</span><span class=cF0>
|
|
<a name="l41"></a>
|
|
<a name="l42"></a>* A char const all alone is sent to </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KeyDev.ZC.html#l23"><span class=cF4>PutChars</span></a><span class=cF0>(). A string with or without args is sent to </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/StrPrint.ZC.html#l1110"><span class=cF4>Print</span></a><span class=cF0>(). An empty string literal
|
|
<a name="l43"></a>signals a variable format_str follows.
|
|
<a name="l44"></a>
|
|
<a name="l45"></a> </span><span class=cF2>void DemoC(char drv, char *format, char *name, int age)
|
|
<a name="l46"></a> {
|
|
<a name="l47"></a> printf("Hello World!\n");
|
|
<a name="l48"></a> printf("%s age %d\n", name, age);
|
|
<a name="l49"></a> printf(format, name, age);
|
|
<a name="l50"></a> putchar(drv);
|
|
<a name="l51"></a> putchar('*');
|
|
<a name="l52"></a> }
|
|
<a name="l53"></a>
|
|
<a name="l54"></a> U0 DemoZealC(U8 drive, U8 *format, U8 *name, I64 age)
|
|
<a name="l55"></a> {
|
|
<a name="l56"></a> "Hello World!\n";
|
|
<a name="l57"></a> "%s age %d\n", name, age;
|
|
<a name="l58"></a> "" format, name, age;
|
|
<a name="l59"></a> '' drive;
|
|
<a name="l60"></a> '*';
|
|
<a name="l61"></a> }
|
|
<a name="l62"></a></span><span class=cF0>
|
|
<a name="l63"></a>* When dealing with function addresses such as for callbacks, precede the name with "</span><span class=cF2>&</span><span class=cF0>".
|
|
<a name="l64"></a>
|
|
<a name="l65"></a>* Type casting is postfix. To typecast int or F64, use </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l92"><span class=cF4>ToI64</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l90"><span class=cF4>ToBool</span></a><span class=cF0>() or </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l91"><span class=cF4>ToF64</span></a><span class=cF0>(). (ZealOS follows normal C float<-->int
|
|
<a name="l66"></a>conversion, but sometimes you want to override. These functions are better than multiplying by "1.0" to convert to float.)
|
|
<a name="l67"></a>
|
|
<a name="l68"></a>* There is no </span><span class=cF2>main()</span><span class=cF0> function. Any code outside of functions gets executed upon start-up, in order.
|
|
<a name="l69"></a>
|
|
<a name="l70"></a>* There are no bit fields, but there are </span><span class=cF4><u>bit access</u></span><span class=cF0> routines and you can access bytes or words within any int. See </span><span class=cF4>
|
|
<a name="l71"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l103"><span class=cF4>I64 declaration</span></a><span class=cF0>. A class can be accessed as a whole are subints, if you put a type in front of the </span><span class=cF2>class</span><span class=cF0> declaration.
|
|
<a name="l72"></a>
|
|
<a name="l73"></a> </span><span class=cF2>public I64i union I64 //"I64i" is intrinsic. We are defining "I64".
|
|
<a name="l74"></a> {
|
|
<a name="l75"></a> I8i i8[8];
|
|
<a name="l76"></a> U8i u8[8];
|
|
<a name="l77"></a> I16 i16[4];
|
|
<a name="l78"></a> U16 u16[4];
|
|
<a name="l79"></a> I32 i32[2];
|
|
<a name="l80"></a> U32 u32[2];
|
|
<a name="l81"></a> };
|
|
<a name="l82"></a>
|
|
<a name="l83"></a> I64 i = 0x123456780000DEF0;
|
|
<a name="l84"></a> i.u16[1] = 0x9ABC;
|
|
<a name="l85"></a></span><span class=cF0>
|
|
<a name="l86"></a>* Variable arg count functions (</span><span class=cF2>...</span><span class=cF0>) can access their args with built-in variables similar to '</span><span class=cF2>this</span><span class=cF0>' in C++. They are '</span><span class=cF2>I64
|
|
<a name="l87"></a>argc</span><span class=cF0>' and '</span><span class=cF2>I64 argv[]</span><span class=cF0>'.
|
|
<a name="l88"></a>
|
|
<a name="l89"></a> </span><span class=cF2>I64 AddNums(...)
|
|
<a name="l90"></a> {
|
|
<a name="l91"></a> I64 i, res = 0;
|
|
<a name="l92"></a>
|
|
<a name="l93"></a> for (i = 0; i < argc; i++)
|
|
<a name="l94"></a> res += argv[i];
|
|
<a name="l95"></a>
|
|
<a name="l96"></a> return res;
|
|
<a name="l97"></a> }
|
|
<a name="l98"></a>
|
|
<a name="l99"></a> </span><span class=cF0>></span><span class=cF2>AddNums(1, 2, 3);</span><span class=cF0>
|
|
<a name="l100"></a> ans = 6
|
|
<a name="l101"></a> </span><span class=cF2>
|
|
<a name="l102"></a>
|
|
<a name="l103"></a> public U0 GrPrint(CDC *dc, I64 x, I64 y, U8 *format, ...)
|
|
<a name="l104"></a> {
|
|
<a name="l105"></a> U8 *buf = </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/StrPrint.ZC.html#l249"><span class=cF4>StrPrintJoin</span></a><span class=cF2>(NULL, format, argc, argv); //SPrintF() with </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF2>()ed string.
|
|
<a name="l106"></a>
|
|
<a name="l107"></a> </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrBitMap.ZC.html#l1084"><span class=cF4>GrPutS</span></a><span class=cF2>(dc, x, y, buf); //Plot string at x,y pixels. GrPutS is not public.
|
|
<a name="l108"></a> Free(buf);
|
|
<a name="l109"></a> }
|
|
<a name="l110"></a>
|
|
<a name="l111"></a> ...
|
|
<a name="l112"></a>
|
|
<a name="l113"></a> GrPrint(gr.dc, (GR_WIDTH - 10 * FONT_WIDTH) >> 1, (GR_HEIGHT - FONT_HEIGHT) >> 1, "Score:%4d", score);
|
|
<a name="l114"></a> //Print score in the center of the screen.
|
|
<a name="l115"></a> ...
|
|
<a name="l116"></a>
|
|
<a name="l117"></a></span><span class=cF0>
|
|
<a name="l118"></a>* Allows "</span><span class=cF2>5 < i < j + 1 < 20</span><span class=cF0>" instead of "</span><span class=cF2>5 < i && i < j + 1 && j + 1 < 20</span><span class=cF0>".
|
|
<a name="l119"></a>
|
|
<a name="l120"></a> </span><span class=cF2>if (13 <= age < 20)
|
|
<a name="l121"></a> "Teen-ager";
|
|
<a name="l122"></a></span><span class=cF0>
|
|
<a name="l123"></a>* if you know a switch statement will not exceed the lowest or highest case values. </span><span class=cF2>switch []</span><span class=cF0> is a little faster because it
|
|
<a name="l124"></a>doesn't check.
|
|
<a name="l125"></a>
|
|
<a name="l126"></a>* </span><span class=cF2>switch</span><span class=cF0> statements always use a jump table. Don't use them with cases with really big, sparse ranges.
|
|
<a name="l127"></a>
|
|
<a name="l128"></a>* Allows ranges like "</span><span class=cF2>case 4...7:</span><span class=cF0>" in </span><span class=cF2>switch</span><span class=cF0> statements.
|
|
<a name="l129"></a>
|
|
<a name="l130"></a>* A no case number causes next higher int case in </span><span class=cF2>switch</span><span class=cF0> statements. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/NullCase.ZC.html#l1"><span class=cF4>::/Demo/NullCase.ZC</span></a><span class=cF0>.
|
|
<a name="l131"></a>
|
|
<a name="l132"></a> </span><span class=cF2>I64 i;
|
|
<a name="l133"></a>
|
|
<a name="l134"></a> for (i = 0; i < 20; i++)
|
|
<a name="l135"></a> switch (i)
|
|
<a name="l136"></a> {
|
|
<a name="l137"></a> case: "Zero\n"; break; //Starts at zero
|
|
<a name="l138"></a> case: "One\n"; break; //One plus prev case.
|
|
<a name="l139"></a> case: "Two\n"; break;
|
|
<a name="l140"></a> case: "Three\n"; break;
|
|
<a name="l141"></a> case 10: "Ten\n"; break;
|
|
<a name="l142"></a> case: "Eleven\n"; break; //One plus prev case.
|
|
<a name="l143"></a> }</span><span class=cF0>
|
|
<a name="l144"></a>
|
|
<a name="l145"></a>* Switch statements can be nestled with a single switch expression! This is known as a "sub_switch" statement. </span><span class=cF2>start</span><span class=cF0>/</span><span class=cF2>end</span><span class=cF0> are
|
|
<a name="l146"></a>used to group cases. Don't goto out of, throw an exception out of, or return out of the </span><span class=cF2>start</span><span class=cF0> front porch area. See </span><span class=cF4>
|
|
<a name="l147"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/SubSwitch.ZC.html#l1"><span class=cF4>::/Demo/SubSwitch.ZC</span></a><span class=cF0>.
|
|
<a name="l148"></a>
|
|
<a name="l149"></a> </span><span class=cF2>I64 i;
|
|
<a name="l150"></a>
|
|
<a name="l151"></a> for (i = 0; i < 10; i++)
|
|
<a name="l152"></a> switch (i)
|
|
<a name="l153"></a> {
|
|
<a name="l154"></a> case 0: "Zero "; break;
|
|
<a name="l155"></a> case 2: "Two "; break;
|
|
<a name="l156"></a> case 4: "Four "; break;
|
|
<a name="l157"></a> start:
|
|
<a name="l158"></a> "[";
|
|
<a name="l159"></a> case 1: "One"; break;
|
|
<a name="l160"></a> case 3: "Three"; break;
|
|
<a name="l161"></a> case 5: "Five"; break;
|
|
<a name="l162"></a> end:
|
|
<a name="l163"></a> "] ";
|
|
<a name="l164"></a> break;
|
|
<a name="l165"></a> }</span><span class=cF0>
|
|
<a name="l166"></a> OutPut:
|
|
<a name="l167"></a> ></span><span class=cF2>Zero [One] Two [Three] Four [Five]</span><span class=cF0>
|
|
<a name="l168"></a>
|
|
<a name="l169"></a>* A </span><span class=cF2>no_warn</span><span class=cF0> statement will suppress an unused variable warning.
|
|
<a name="l170"></a>
|
|
<a name="l171"></a>* You can have multiple member variables of a class named "</span><span class=cF2>pad</span><span class=cF0>" or "</span><span class=cF2>reserved</span><span class=cF0>", and it won't issue warnings.
|
|
<a name="l172"></a>
|
|
<a name="l173"></a>* </span><span class=cF2>noreg</span><span class=cF0> or </span><span class=cF2>reg</span><span class=cF0> can be placed before a function local variable name. You can, optionally, specify a register after the </span><span class=cF2>reg</span><span class=cF0>
|
|
<a name="l174"></a>keyword.
|
|
<a name="l175"></a>
|
|
<a name="l176"></a> </span><span class=cF2>U0 Main()
|
|
<a name="l177"></a> {
|
|
<a name="l178"></a> //Only use </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1939"><span class=cF4>REGG_LOCAL_VARS</span></a><span class=cF2> or </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1940"><span class=cF4>REGG_LOCAL_NON_PTR_VARS</span></a><span class=cF2> for register variables or else clobbered.
|
|
<a name="l179"></a> I64 reg R15 i = 5, noreg j = 4;
|
|
<a name="l180"></a> no_warn i;
|
|
<a name="l181"></a> asm {
|
|
<a name="l182"></a> MOV RAX, R15
|
|
<a name="l183"></a> CALL &PUT_HEX_U64
|
|
<a name="l184"></a> MOV RAX, '\n'
|
|
<a name="l185"></a> CALL &PUT_CHARS
|
|
<a name="l186"></a> MOV RAX, U64 &j[RBP]
|
|
<a name="l187"></a> CALL &PUT_HEX_U64
|
|
<a name="l188"></a> MOV RAX, '\n'
|
|
<a name="l189"></a> CALL &PUT_CHARS
|
|
<a name="l190"></a> }
|
|
<a name="l191"></a> }
|
|
<a name="l192"></a></span><span class=cF0>
|
|
<a name="l193"></a>* </span><span class=cF2>interrupt</span><span class=cF0>, </span><span class=cF2>haserrcode</span><span class=cF0>, </span><span class=cF2>public</span><span class=cF0>, </span><span class=cF2>argpop</span><span class=cF0> or </span><span class=cF2>noargpop</span><span class=cF0> are function flags. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/SerialDev/Keyboard.ZC.html#l477"><span class=cF4>IRQKbd</span></a><span class=cF0>().
|
|
<a name="l194"></a>
|
|
<a name="l195"></a>* A single quote can encompass multiple characters. </span><span class=cF2>'ABC'</span><span class=cF0> is equ to </span><span class=cF2>0x434241</span><span class=cF0>. </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KeyDev.ZC.html#l23"><span class=cF4>PutChars</span></a><span class=cF0>() takes multiple characters.
|
|
<a name="l196"></a>
|
|
<a name="l197"></a> </span><span class=cF2>asm {
|
|
<a name="l198"></a> HELLO_WORLD::
|
|
<a name="l199"></a> PUSH RBP
|
|
<a name="l200"></a> MOV RBP, RSP
|
|
<a name="l201"></a> MOV RAX, 'Hello '
|
|
<a name="l202"></a> CALL &PUT_CHARS
|
|
<a name="l203"></a> MOV RAX, 'World\n'
|
|
<a name="l204"></a> CALL &PUT_CHARS
|
|
<a name="l205"></a> LEAVE
|
|
<a name="l206"></a> RET
|
|
<a name="l207"></a> }
|
|
<a name="l208"></a> Call(HELLO_WORLD);
|
|
<a name="l209"></a> PutChars('Hello ');
|
|
<a name="l210"></a> PutChars('World\n');
|
|
<a name="l211"></a></span><span class=cF0>
|
|
<a name="l212"></a>* The "</span><span class=cF2>`</span><span class=cF0>" operator raises a base to a power.
|
|
<a name="l213"></a>
|
|
<a name="l214"></a>* There is no question-colon operator.
|
|
<a name="l215"></a>
|
|
<a name="l216"></a>* ZealOS </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/CInit.ZC.html#l509"><span class=cF4>operator precedence</span></a><span class=cF0>
|
|
<a name="l217"></a> </span><span class=cF2>`</span><span class=cF0>, </span><span class=cF2>>></span><span class=cF0>, </span><span class=cF2><<</span><span class=cF0>
|
|
<a name="l218"></a> </span><span class=cF2>*</span><span class=cF0>, </span><span class=cF2>/</span><span class=cF0>, </span><span class=cF2>%</span><span class=cF0>
|
|
<a name="l219"></a> </span><span class=cF2>&</span><span class=cF0>
|
|
<a name="l220"></a> </span><span class=cF2>^</span><span class=cF0>
|
|
<a name="l221"></a> </span><span class=cF2>|</span><span class=cF0>
|
|
<a name="l222"></a> </span><span class=cF2>+</span><span class=cF0>, </span><span class=cF2>-</span><span class=cF0>
|
|
<a name="l223"></a> </span><span class=cF2><</span><span class=cF0>, </span><span class=cF2>></span><span class=cF0>, </span><span class=cF2><=</span><span class=cF0>, </span><span class=cF2>>=</span><span class=cF0>
|
|
<a name="l224"></a> </span><span class=cF2>==</span><span class=cF0>, </span><span class=cF2>!=</span><span class=cF0>
|
|
<a name="l225"></a> </span><span class=cF2>&&</span><span class=cF0>
|
|
<a name="l226"></a> </span><span class=cF2>^^</span><span class=cF0>
|
|
<a name="l227"></a> </span><span class=cF2>||</span><span class=cF0>
|
|
<a name="l228"></a> </span><span class=cF2>=</span><span class=cF0>, </span><span class=cF2><<=</span><span class=cF0>, </span><span class=cF2>>>=</span><span class=cF0>, </span><span class=cF2>*=</span><span class=cF0>, </span><span class=cF2>/=</span><span class=cF0>, </span><span class=cF2>&=</span><span class=cF0>, </span><span class=cF2>|=</span><span class=cF0>, </span><span class=cF2>^=</span><span class=cF0>, </span><span class=cF2>+=</span><span class=cF0>, </span><span class=cF2>-=</span><span class=cF0>
|
|
<a name="l229"></a>
|
|
<a name="l230"></a>* You can use </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.ZC.html#l1"><span class=cF4>Option</span></a><span class=cF0>(</span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1679"><span class=cF4>OPTf_WARN_PAREN</span></a><span class=cF0>, ON) to find unnecessary parentheses in code.
|
|
<a name="l231"></a>
|
|
<a name="l232"></a>* You can use </span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.ZC.html#l1"><span class=cF4>Option</span></a><span class=cF0>(</span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1680"><span class=cF4>OPTf_WARN_DUP_TYPES</span></a><span class=cF0>, ON) to find duplicate local variable type statements.
|
|
<a name="l233"></a>
|
|
<a name="l234"></a>* With the </span><span class=cF2>#exe{}</span><span class=cF0> feature in your src code, you can place programs that insert text into the stream of code being compiled.
|
|
<a name="l235"></a>See </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KMain.ZC.html#l257"><span class=cF4>#exe {}</span></a><span class=cF0> for an example where the date/time and compile-time prompting for configuration data is placed into a program. </span><span class=cF4>
|
|
<a name="l236"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Compiler/CMisc.ZC.html#l71"><span class=cF4>StreamPrint</span></a><span class=cF0>() places text into a src program stream following the conclusion of the </span><span class=cF2>#exe{}</span><span class=cF0> block.
|
|
<a name="l237"></a>
|
|
<a name="l238"></a>* No </span><span class=cF2>#define</span><span class=cF0> functions exist (Terry was not a fan)
|
|
<a name="l239"></a>
|
|
<a name="l240"></a>* No </span><span class=cF2>typedef</span><span class=cF0>, use </span><span class=cF2>class</span><span class=cF0>.
|
|
<a name="l241"></a>
|
|
<a name="l242"></a>* No type-checking
|
|
<a name="l243"></a>
|
|
<a name="l244"></a>* Can't use </span><span class=cF2><></span><span class=cF0> with </span><span class=cF2>#include</span><span class=cF0>, use </span><span class=cF2>""</span><span class=cF0>.
|
|
<a name="l245"></a>
|
|
<a name="l246"></a>* "</span><span class=cF2>$</span><span class=cF0>" is an escape character. Two dollar signs signify an ordinary $. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/DolDocOverview.DD.html#l1"><span class=cF4>DolDoc</span></a><span class=cF0>. In </span><span class=cF2>asm</span><span class=cF0> or </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/ZealC.DD.html#l1"><span class=cF4>ZealC</span></a><span class=cF0> code, it also refers to
|
|
<a name="l247"></a>the instruction's address or the offset in a </span><span class=cF2>class</span><span class=cF0> definition.
|
|
<a name="l248"></a>
|
|
<a name="l249"></a>* </span><span class=cF2>union</span><span class=cF0> is more like a class, so you don't reference it with a </span><span class=cF2>union</span><span class=cF0> label after you define it. Some common unions are
|
|
<a name="l250"></a>declared in </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l65"><span class=cF4>KernelA.HH</span></a><span class=cF0> for 1,2,4 and 8 byte objects. If you place a type in front of a union declaration, that is the type
|
|
<a name="l251"></a>when used by itself. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/SubIntAccess.ZC.html#l1"><span class=cF4>::/Demo/SubIntAccess.ZC</span></a><span class=cF0>.
|
|
<a name="l252"></a>
|
|
<a name="l253"></a>* </span><span class=cF2>class</span><span class=cF0> member variables can have meta data. </span><span class=cF2>format</span><span class=cF0> and </span><span class=cF2>data</span><span class=cF0> are two meta data types now used. All compiler structures are
|
|
<a name="l254"></a>saved and you can access the compiler's info about classes and variables. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/ClassMeta.ZC.html#l1"><span class=cF4>::/Demo/ClassMeta.ZC</span></a><span class=cF0> and </span><a href="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocForm.ZC.html#l263"><span class=cF4>DocForm</span></a><span class=cF0>().
|
|
<a name="l255"></a>
|
|
<a name="l256"></a>* There is a keyword </span><span class=cF2>lastclass</span><span class=cF0> you use as a default arg. It is set to the class name of the prev arg. See </span><span class=cF4>
|
|
<a name="l257"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/LastClass.ZC.html#l1"><span class=cF4>::/Demo/LastClass.ZC</span></a><span class=cF0>, </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Debug.ZC.html#l216"><span class=cF4>ClassRep</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocForm.ZC.html#l263"><span class=cF4>DocForm</span></a><span class=cF0>() and </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Disk/BlkDevRep.ZC.html#l1"><span class=cF4>::/Demo/Disk/BlkDevRep.ZC</span></a><span class=cF0>.
|
|
<a name="l258"></a>
|
|
<a name="l259"></a>* See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Exceptions.ZC.html#l1"><span class=cF4>::/Demo/Exceptions.ZC</span></a><span class=cF0>. </span><span class=cF2>try{} catch{}</span><span class=cF0> and </span><span class=cF2>throw</span><span class=cF0> are different from C++. </span><span class=cF2>throw</span><span class=cF0> is a function with an 8-byte or less char
|
|
<a name="l260"></a>arg. The char string passed in </span><span class=cF2>throw()</span><span class=cF0> can be accessed from within a </span><span class=cF2>catch{}</span><span class=cF0> using the </span><span class=cF2>Fs->except_ch</span><span class=cF0>. Within a </span><span class=cF2>catch {}</span><span class=cF0>
|
|
<a name="l261"></a>block, set the variable </span><span class=cF2>Fs->catch_except</span><span class=cF0> to </span><span class=cF2>TRUE</span><span class=cF0> if you want to terminate the search for a handler. Use </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KExcept.ZC.html#l46"><span class=cF4>PutExcept</span></a><span class=cF0>() as a
|
|
<a name="l262"></a>handler, if you like.
|
|
<a name="l263"></a>
|
|
<a name="l264"></a>* A function is available similar to </span><span class=cF2>sizeof</span><span class=cF0> which provides the offset of a member of a class. It's called </span><span class=cF2>offset</span><span class=cF0>. You place
|
|
<a name="l265"></a>the class name and member inside as in </span><span class=cF2>offset(classname.membername)</span><span class=cF0>. It has nothing to do with 16-bit code. Both </span><span class=cF2>sizeof</span><span class=cF0>
|
|
<a name="l266"></a>and </span><span class=cF2>offset</span><span class=cF0> only accept one level of member variables. That is, you can't do </span><span class=cF2>sizeof(classname.membername.submembername)</span><span class=cF0>.
|
|
<a name="l267"></a>
|
|
<a name="l268"></a>* There is no </span><span class=cF2>continue</span><span class=cF0> statement. Use </span><span class=cF2>goto</span><span class=cF0>.
|
|
<a name="l269"></a>
|
|
<a name="l270"></a>* </span><span class=cF2>lock{}</span><span class=cF0> can be used to apply asm </span><span class=cF2>LOCK</span><span class=cF0> prefixes to code for safe multicore read-modify-write accesses. The code bracked with
|
|
<a name="l271"></a>have </span><span class=cF2>LOCK</span><span class=cF0> asm prefix's applied to relevant insts within. It's a little shoddy. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/MultiCore/Lock.ZC.html#l1"><span class=cF4>::/Demo/MultiCore/Lock.ZC</span></a><span class=cF0>.
|
|
<a name="l272"></a>
|
|
<a name="l273"></a>* There is a function called </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l388"><span class=cF4>MSize</span></a><span class=cF0>() which gives the size of an object alloced off the heap. For larger size allocations,
|
|
<a name="l274"></a>the system rounds-up to a power of two, so </span><span class=cF2>MSize()</span><span class=cF0> lets you know the real size and you can take full advantage of it.
|
|
<a name="l275"></a>
|
|
<a name="l276"></a>* You CAN </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l387"><span class=cF4>Free</span></a><span class=cF0>() a </span><span class=cF2>NULL</span><span class=cF0> pointer. Useful variants of </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>() can be found </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.ZC.html#l399"><span class=cF4>Here</span></a><span class=cF0>. Each task has a heap and you can </span><span class=cF2>MAlloc</span><span class=cF0> and </span><span class=cF2>
|
|
<a name="l277"></a>Free</span><span class=cF0> off-of other task's heaps, or make an independent heap with </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/HeapCtrl.ZC.html#l1"><span class=cF4>HeapCtrlInit</span></a><span class=cF0>(). See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Utils/HeapLog.ZC.html#l83"><span class=cF4>HeapLog</span></a><span class=cF0>() for an example.
|
|
<a name="l278"></a>
|
|
<a name="l279"></a>* The stack does not grow because virtual mem is not used. It's recommended to allocate large local variables from the heap.
|
|
<a name="l280"></a>You can change </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3540"><span class=cF4>MEM_DEFAULT_STACK</span></a><span class=cF0> and recompile </span><span class=cF2>Kernel</span><span class=cF0> or request more when doing a </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KTask.ZC.html#l264"><span class=cF4>Spawn</span></a><span class=cF0>(). You can use </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KTask.ZC.html#l129"><span class=cF4>CallStackGrow</span></a><span class=cF0>(), but
|
|
<a name="l281"></a>it's odd. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/StackGrow.ZC.html#l1"><span class=cF4>::/Demo/StackGrow.ZC</span></a><span class=cF0>.
|
|
<a name="l282"></a>
|
|
<a name="l283"></a>* Only one base class is allowed.
|
|
<a name="l284"></a>
|
|
<a name="l285"></a>* </span><span class=cF2>printf()</span><span class=cF0> has new codes. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/Print.DD.html#l1"><span class=cF4>Print("") Format Strings</span></a><span class=cF0>.
|
|
<a name="l286"></a>
|
|
<a name="l287"></a>* All values are extended to 64-bit when accessed. Intermediate calculations are done with 64-bit values.
|
|
<a name="l288"></a>
|
|
<a name="l289"></a> </span><span class=cF2>U0 Main()
|
|
<a name="l290"></a> {
|
|
<a name="l291"></a> I16 i1;
|
|
<a name="l292"></a> I32 j1;
|
|
<a name="l293"></a>
|
|
<a name="l294"></a> j1 = i1 = 0x12345678; //Resulting i1 is 0x5678 but j1 is 0x12345678
|
|
<a name="l295"></a>
|
|
<a name="l296"></a> I64 i2 = 0x8000000000000000;
|
|
<a name="l297"></a> Print("%X\n", i2 >> 1); //Res is 0xC000000000000000 as expected
|
|
<a name="l298"></a>
|
|
<a name="l299"></a> U64 u3 = 0x8000000000000000;
|
|
<a name="l300"></a> Print("%X\n", u3 >> 1); //Res is 0x4000000000000000 as expected
|
|
<a name="l301"></a>
|
|
<a name="l302"></a> I32 i4 = 0x80000000; //const is loaded into a 64-bit register variable.
|
|
<a name="l303"></a> Print("%X\n", i4 >> 1); //Res is 0x40000000
|
|
<a name="l304"></a>
|
|
<a name="l305"></a> I32 i5 = -0x80000000;
|
|
<a name="l306"></a> Print("%X\n", i5 >> 1); //Res is 0xFFFFFFFFC0000000
|
|
<a name="l307"></a> }
|
|
<a name="l308"></a></span><span class=cF0>
|
|
</span></pre></body>
|
|
</html>
|