mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-29 00:36:32 +00:00
dbf8647d59
Added top & right borders to RawDr. Improved spacing in some debug and compiler reporting. Fixed RawPutChar and EdLite tab width. Fixed Ui missing '0x' prefix syntax highlighter bug. Added 32BitPaint demo.
330 lines
29 KiB
HTML
Executable file
330 lines
29 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.08">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF5> CosmiC</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a>* See </span><a href="https://tomawezome.github.io/ZealOS/Doc/CompilerOverview.DD.html#l1"><span class=cF4>::/Doc/CompilerOverview.DD</span></a><span class=cF0>.
|
|
<a name="l4"></a>
|
|
<a name="l5"></a>* See </span><a href="https://tomawezome.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="l6"></a>
|
|
<a name="l7"></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="l8"></a>and </span><span class=cF2>F64</span><span class=cF0> for 8 byte floats.
|
|
<a name="l9"></a>
|
|
<a name="l10"></a></span><span class=cF2> U0 void, but ZERO size!
|
|
<a name="l11"></a> I8 char
|
|
<a name="l12"></a> U8 unsigned char
|
|
<a name="l13"></a> I16 short
|
|
<a name="l14"></a> U16 unsigned short
|
|
<a name="l15"></a> I32 int
|
|
<a name="l16"></a> U32 unsigned int
|
|
<a name="l17"></a> I64 long (64-bit)
|
|
<a name="l18"></a> U64 unsigned long (64-bit)
|
|
<a name="l19"></a> F64 double</span><span class=cF0>
|
|
<a name="l20"></a> </span><span class=cF4>no F32 float.</span><span class=cF0>
|
|
<a name="l21"></a>
|
|
<a name="l22"></a>* Function with no args, or just default args can be called without parentheses.
|
|
<a name="l23"></a>
|
|
<a name="l24"></a> ></span><span class=cF2>Dir("*");</span><span class=cF0>
|
|
<a name="l25"></a> ></span><span class=cF2>Dir();</span><span class=cF0>
|
|
<a name="l26"></a> ></span><span class=cF2>Dir;</span><span class=cF0>
|
|
<a name="l27"></a>
|
|
<a name="l28"></a>* Default args don't have to be on the end. This code is valid:
|
|
<a name="l29"></a> </span><span class=cF2>U0 Test(I64 i=4, I64 j, I64 k=5)
|
|
<a name="l30"></a> {
|
|
<a name="l31"></a> Print("%X %X %X\n", i, j, k);
|
|
<a name="l32"></a> }
|
|
<a name="l33"></a>
|
|
<a name="l34"></a> Test(, 3);</span><span class=cF0>
|
|
<a name="l35"></a>
|
|
<a name="l36"></a>* A char const all alone is sent to </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KeyDev.CC.html#l23"><span class=cF4>PutChars</span></a><span class=cF0>(). A string with or without args is sent to </span><a href="https://tomawezome.github.io/ZealOS/Kernel/StrPrint.CC.html#l1110"><span class=cF4>Print</span></a><span class=cF0>(). An empty string literal
|
|
<a name="l37"></a>signals a variable format_str follows.
|
|
<a name="l38"></a>
|
|
<a name="l39"></a> </span><span class=cF2>void DemoC(char drv, char *format, char *name, int age)
|
|
<a name="l40"></a> {
|
|
<a name="l41"></a> printf("Hello World!\n");
|
|
<a name="l42"></a> printf("%s age %d\n", name, age);
|
|
<a name="l43"></a> printf(format, name, age);
|
|
<a name="l44"></a> putchar(drv);
|
|
<a name="l45"></a> putchar('*');
|
|
<a name="l46"></a> }
|
|
<a name="l47"></a>
|
|
<a name="l48"></a> U0 DemoCosmiC(U8 drive, U8 *format, U8 *name, I64 age)
|
|
<a name="l49"></a> {
|
|
<a name="l50"></a> "Hello World!\n";
|
|
<a name="l51"></a> "%s age %d\n", name, age;
|
|
<a name="l52"></a> "" format, name, age;
|
|
<a name="l53"></a> '' drive;
|
|
<a name="l54"></a> '*';
|
|
<a name="l55"></a> }
|
|
<a name="l56"></a></span><span class=cF0>
|
|
<a name="l57"></a>* When dealing with function addresses such as for callbacks, precede the name with "</span><span class=cF2>&</span><span class=cF0>".
|
|
<a name="l58"></a>
|
|
<a name="l59"></a>* Type casting is postfix. To typecast int or F64, use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelB.HH.html#l92"><span class=cF4>ToI64</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelB.HH.html#l90"><span class=cF4>ToBool</span></a><span class=cF0>() or </span><a href="https://tomawezome.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="l60"></a>conversion, but sometimes you want to override. These functions are better than multiplying by "1.0" to convert to float.)
|
|
<a name="l61"></a>
|
|
<a name="l62"></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="l63"></a>
|
|
<a name="l64"></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="l65"></a></span><a href="https://tomawezome.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="l66"></a>
|
|
<a name="l67"></a> </span><span class=cF2>public I64i union I64 //"I64i" is intrinsic. We are defining "I64".
|
|
<a name="l68"></a> {
|
|
<a name="l69"></a> I8i i8[8];
|
|
<a name="l70"></a> U8i u8[8];
|
|
<a name="l71"></a> I16 i16[4];
|
|
<a name="l72"></a> U16 u16[4];
|
|
<a name="l73"></a> I32 i32[2];
|
|
<a name="l74"></a> U32 u32[2];
|
|
<a name="l75"></a> };
|
|
<a name="l76"></a>
|
|
<a name="l77"></a> I64 i = 0x123456780000DEF0;
|
|
<a name="l78"></a> i.u16[1] = 0x9ABC;
|
|
<a name="l79"></a></span><span class=cF0>
|
|
<a name="l80"></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="l81"></a>argc</span><span class=cF0>' and '</span><span class=cF2>I64 argv[]</span><span class=cF0>'.
|
|
<a name="l82"></a>
|
|
<a name="l83"></a> </span><span class=cF2>I64 AddNums(...)
|
|
<a name="l84"></a> {
|
|
<a name="l85"></a> I64 i, res = 0;
|
|
<a name="l86"></a>
|
|
<a name="l87"></a> for (i = 0; i < argc; i++)
|
|
<a name="l88"></a> res += argv[i];
|
|
<a name="l89"></a>
|
|
<a name="l90"></a> return res;
|
|
<a name="l91"></a> }
|
|
<a name="l92"></a>
|
|
<a name="l93"></a> </span><span class=cF0>></span><span class=cF2>AddNums(1, 2, 3);</span><span class=cF0>
|
|
<a name="l94"></a> ans = 6
|
|
<a name="l95"></a> </span><span class=cF2>
|
|
<a name="l96"></a>
|
|
<a name="l97"></a> public U0 GrPrint(CDC *dc, I64 x, I64 y, U8 *format, ...)
|
|
<a name="l98"></a> {
|
|
<a name="l99"></a> U8 *buf = </span><a href="https://tomawezome.github.io/ZealOS/Kernel/StrPrint.CC.html#l249"><span class=cF4>StrPrintJoin</span></a><span class=cF2>(NULL, format, argc, argv); //SPrintF() with </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF2>()ed string.
|
|
<a name="l100"></a>
|
|
<a name="l101"></a> </span><a href="https://tomawezome.github.io/ZealOS/System/Gr/GrBitMap.CC.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="l102"></a> Free(buf);
|
|
<a name="l103"></a> }
|
|
<a name="l104"></a>
|
|
<a name="l105"></a> ...
|
|
<a name="l106"></a>
|
|
<a name="l107"></a> GrPrint(gr.dc, (GR_WIDTH - 10 * FONT_WIDTH) >> 1, (GR_HEIGHT - FONT_HEIGHT) >> 1, "Score:%4d", score);
|
|
<a name="l108"></a> //Print score in the center of the screen.
|
|
<a name="l109"></a> ...
|
|
<a name="l110"></a>
|
|
<a name="l111"></a></span><span class=cF0>
|
|
<a name="l112"></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="l113"></a>
|
|
<a name="l114"></a> </span><span class=cF2>if (13 <= age < 20)
|
|
<a name="l115"></a> "Teen-ager";
|
|
<a name="l116"></a></span><span class=cF0>
|
|
<a name="l117"></a>* if you know a switch stmt 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="l118"></a>doesn't check.
|
|
<a name="l119"></a>
|
|
<a name="l120"></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="l121"></a>
|
|
<a name="l122"></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="l123"></a>
|
|
<a name="l124"></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://tomawezome.github.io/ZealOS/Demo/NullCase.CC.html#l1"><span class=cF4>::/Demo/NullCase.CC</span></a><span class=cF0>.
|
|
<a name="l125"></a>
|
|
<a name="l126"></a> </span><span class=cF2>I64 i;
|
|
<a name="l127"></a>
|
|
<a name="l128"></a> for (i = 0; i < 20; i++)
|
|
<a name="l129"></a> switch (i)
|
|
<a name="l130"></a> {
|
|
<a name="l131"></a> case: "Zero\n"; break; //Starts at zero
|
|
<a name="l132"></a> case: "One\n"; break; //One plus prev case.
|
|
<a name="l133"></a> case: "Two\n"; break;
|
|
<a name="l134"></a> case: "Three\n"; break;
|
|
<a name="l135"></a> case 10: "Ten\n"; break;
|
|
<a name="l136"></a> case: "Eleven\n"; break; //One plus prev case.
|
|
<a name="l137"></a> }</span><span class=cF0>
|
|
<a name="l138"></a>
|
|
<a name="l139"></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="l140"></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="l141"></a></span><a href="https://tomawezome.github.io/ZealOS/Demo/SubSwitch.CC.html#l1"><span class=cF4>::/Demo/SubSwitch.CC</span></a><span class=cF0>.
|
|
<a name="l142"></a>
|
|
<a name="l143"></a> </span><span class=cF2>I64 i;
|
|
<a name="l144"></a>
|
|
<a name="l145"></a> for (i = 0; i < 10; i++)
|
|
<a name="l146"></a> switch (i)
|
|
<a name="l147"></a> {
|
|
<a name="l148"></a> case 0: "Zero "; break;
|
|
<a name="l149"></a> case 2: "Two "; break;
|
|
<a name="l150"></a> case 4: "Four "; break;
|
|
<a name="l151"></a> start:
|
|
<a name="l152"></a> "[";
|
|
<a name="l153"></a> case 1: "One"; break;
|
|
<a name="l154"></a> case 3: "Three"; break;
|
|
<a name="l155"></a> case 5: "Five"; break;
|
|
<a name="l156"></a> end:
|
|
<a name="l157"></a> "] ";
|
|
<a name="l158"></a> break;
|
|
<a name="l159"></a> }</span><span class=cF0>
|
|
<a name="l160"></a> OutPut:
|
|
<a name="l161"></a> ></span><span class=cF2>Zero [One] Two [Three] Four [Five]</span><span class=cF0>
|
|
<a name="l162"></a>
|
|
<a name="l163"></a>* A </span><span class=cF2>no_warn</span><span class=cF0> stmt will suppress an unused var warning.
|
|
<a name="l164"></a>
|
|
<a name="l165"></a>* You can have multiple member vars 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="l166"></a>
|
|
<a name="l167"></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 var name. You can, optionally, specify a reg after the </span><span class=cF2>reg</span><span class=cF0> keyword.
|
|
<a name="l168"></a>
|
|
<a name="l169"></a> </span><span class=cF2>U0 Main()
|
|
<a name="l170"></a> {
|
|
<a name="l171"></a> //Only use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l1939"><span class=cF4>REGG_LOCAL_VARS</span></a><span class=cF2> or </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l1940"><span class=cF4>REGG_LOCAL_NON_PTR_VARS</span></a><span class=cF2> for reg vars or else clobbered.
|
|
<a name="l172"></a> I64 reg R15 i = 5, noreg j = 4;
|
|
<a name="l173"></a> no_warn i;
|
|
<a name="l174"></a> asm {
|
|
<a name="l175"></a> MOV RAX, R15
|
|
<a name="l176"></a> CALL &PUT_HEX_U64
|
|
<a name="l177"></a> MOV RAX, '\n'
|
|
<a name="l178"></a> CALL &PUT_CHARS
|
|
<a name="l179"></a> MOV RAX, U64 &j[RBP]
|
|
<a name="l180"></a> CALL &PUT_HEX_U64
|
|
<a name="l181"></a> MOV RAX, '\n'
|
|
<a name="l182"></a> CALL &PUT_CHARS
|
|
<a name="l183"></a> }
|
|
<a name="l184"></a> }
|
|
<a name="l185"></a></span><span class=cF0>
|
|
<a name="l186"></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://tomawezome.github.io/ZealOS/Kernel/SerialDev/Keyboard.CC.html#l477"><span class=cF4>IRQKbd</span></a><span class=cF0>().
|
|
<a name="l187"></a>
|
|
<a name="l188"></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://tomawezome.github.io/ZealOS/Kernel/KeyDev.CC.html#l23"><span class=cF4>PutChars</span></a><span class=cF0>() takes multiple characters.
|
|
<a name="l189"></a>
|
|
<a name="l190"></a> </span><span class=cF2>asm {
|
|
<a name="l191"></a> HELLO_WORLD::
|
|
<a name="l192"></a> PUSH RBP
|
|
<a name="l193"></a> MOV RBP, RSP
|
|
<a name="l194"></a> MOV RAX, 'Hello '
|
|
<a name="l195"></a> CALL &PUT_CHARS
|
|
<a name="l196"></a> MOV RAX, 'World\n'
|
|
<a name="l197"></a> CALL &PUT_CHARS
|
|
<a name="l198"></a> LEAVE
|
|
<a name="l199"></a> RET
|
|
<a name="l200"></a> }
|
|
<a name="l201"></a> Call(HELLO_WORLD);
|
|
<a name="l202"></a> PutChars('Hello ');
|
|
<a name="l203"></a> PutChars('World\n');
|
|
<a name="l204"></a></span><span class=cF0>
|
|
<a name="l205"></a>* The "</span><span class=cF2>`</span><span class=cF0>" operator raises a base to a power.
|
|
<a name="l206"></a>
|
|
<a name="l207"></a>* There is no question-colon operator.
|
|
<a name="l208"></a>
|
|
<a name="l209"></a>* ZealOS </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CInit.CC.html#l508"><span class=cF4>operator precedence</span></a><span class=cF0>
|
|
<a name="l210"></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="l211"></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="l212"></a> </span><span class=cF2>&</span><span class=cF0>
|
|
<a name="l213"></a> </span><span class=cF2>^</span><span class=cF0>
|
|
<a name="l214"></a> </span><span class=cF2>|</span><span class=cF0>
|
|
<a name="l215"></a> </span><span class=cF2>+</span><span class=cF0>, </span><span class=cF2>-</span><span class=cF0>
|
|
<a name="l216"></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="l217"></a> </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>
|
|
<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>, </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="l222"></a>
|
|
<a name="l223"></a>* You can use </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMisc.CC.html#l1"><span class=cF4>Option</span></a><span class=cF0>(</span><a href="https://tomawezome.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="l224"></a>
|
|
<a name="l225"></a>* You can use </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMisc.CC.html#l1"><span class=cF4>Option</span></a><span class=cF0>(</span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l1680"><span class=cF4>OPTf_WARN_DUP_TYPES</span></a><span class=cF0>, ON) to find dup local var type statements.
|
|
<a name="l226"></a>
|
|
<a name="l227"></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="l228"></a>See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMain.CC.html#l252"><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="l229"></a></span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMisc.CC.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> blk.
|
|
<a name="l230"></a>
|
|
<a name="l231"></a>* No </span><span class=cF2>#define</span><span class=cF0> functions exist (Terry was not a fan)
|
|
<a name="l232"></a>
|
|
<a name="l233"></a>* No </span><span class=cF2>typedef</span><span class=cF0>, use </span><span class=cF2>class</span><span class=cF0>.
|
|
<a name="l234"></a>
|
|
<a name="l235"></a>* No type-checking
|
|
<a name="l236"></a>
|
|
<a name="l237"></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="l238"></a>
|
|
<a name="l239"></a>* "</span><span class=cF2>$</span><span class=cF0>" is an escape character. Two dollar signs signify an ordinary $. See </span><a href="https://tomawezome.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://tomawezome.github.io/ZealOS/Doc/CosmiC.DD.html#l1"><span class=cF4>CosmiC</span></a><span class=cF0> code, it also refers to
|
|
<a name="l240"></a>the instruction's address or the offset in a </span><span class=cF2>class</span><span class=cF0> definition.
|
|
<a name="l241"></a>
|
|
<a name="l242"></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="l243"></a>declared in </span><a href="https://tomawezome.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="l244"></a>when used by itself. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/SubIntAccess.CC.html#l1"><span class=cF4>::/Demo/SubIntAccess.CC</span></a><span class=cF0>.
|
|
<a name="l245"></a>
|
|
<a name="l246"></a>* </span><span class=cF2>class</span><span class=cF0> member vars 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 saved
|
|
<a name="l247"></a>and you can access the compiler's info about classes and vars. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/ClassMeta.CC.html#l1"><span class=cF4>::/Demo/ClassMeta.CC</span></a><span class=cF0> and </span><a href="https://tomawezome.github.io/ZealOS/System/DolDoc/DocForm.CC.html#l263"><span class=cF4>DocForm</span></a><span class=cF0>().
|
|
<a name="l248"></a>
|
|
<a name="l249"></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="l250"></a></span><a href="https://tomawezome.github.io/ZealOS/Demo/LastClass.CC.html#l1"><span class=cF4>::/Demo/LastClass.CC</span></a><span class=cF0>, </span><a href="https://tomawezome.github.io/ZealOS/System/Debug.CC.html#l216"><span class=cF4>ClassRep</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/System/DolDoc/DocForm.CC.html#l263"><span class=cF4>DocForm</span></a><span class=cF0>() and </span><a href="https://tomawezome.github.io/ZealOS/Demo/Disk/BlkDevRep.CC.html#l1"><span class=cF4>::/Demo/Disk/BlkDevRep.CC</span></a><span class=cF0>.
|
|
<a name="l251"></a>
|
|
<a name="l252"></a>* See </span><a href="https://tomawezome.github.io/ZealOS/Demo/Exceptions.CC.html#l1"><span class=cF4>::/Demo/Exceptions.CC</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="l253"></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> blk,
|
|
<a name="l254"></a>set the var </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://tomawezome.github.io/ZealOS/Kernel/KExcept.CC.html#l46"><span class=cF4>PutExcept</span></a><span class=cF0>() as a handler, if you
|
|
<a name="l255"></a>like.
|
|
<a name="l256"></a>
|
|
<a name="l257"></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="l258"></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="l259"></a>and </span><span class=cF2>offset</span><span class=cF0> only accept one level of member vars. That is, you can't do </span><span class=cF2>sizeof(classname.membername.submembername)</span><span class=cF0>.
|
|
<a name="l260"></a>
|
|
<a name="l261"></a>* There is no </span><span class=cF2>continue</span><span class=cF0> stmt. Use </span><span class=cF2>goto</span><span class=cF0>.
|
|
<a name="l262"></a>
|
|
<a name="l263"></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="l264"></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://tomawezome.github.io/ZealOS/Demo/MultiCore/Lock.CC.html#l1"><span class=cF4>::/Demo/MultiCore/Lock.CC</span></a><span class=cF0>.
|
|
<a name="l265"></a>
|
|
<a name="l266"></a>* There is a function called </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.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="l267"></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="l268"></a>
|
|
<a name="l269"></a>* You CAN </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l387"><span class=cF4>Free</span></a><span class=cF0>() a </span><span class=cF2>NULL</span><span class=cF0> ptr. Useful variants of </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>() can be found </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.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>Free</span><span class=cF0>
|
|
<a name="l270"></a>off-of other task's heaps, or make an independent heap with </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/HeapCtrl.CC.html#l1"><span class=cF4>HeapCtrlInit</span></a><span class=cF0>(). See </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/HeapLog.CC.html#l83"><span class=cF4>HeapLog</span></a><span class=cF0>() for an example.
|
|
<a name="l271"></a>
|
|
<a name="l272"></a>* The stack does not grow because virtual mem is not used. It's recommended to allocate large local vars from the heap. Yo
|
|
<a name="l273"></a>u can change </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3508"><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://tomawezome.github.io/ZealOS/Kernel/KTask.CC.html#l264"><span class=cF4>Spawn</span></a><span class=cF0>(). You can use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KTask.CC.html#l129"><span class=cF4>CallStackGrow</span></a><span class=cF0>(), but
|
|
<a name="l274"></a>it's odd. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/StackGrow.CC.html#l1"><span class=cF4>::/Demo/StackGrow.CC</span></a><span class=cF0>.
|
|
<a name="l275"></a>
|
|
<a name="l276"></a>* Only one base class is allowed.
|
|
<a name="l277"></a>
|
|
<a name="l278"></a>* </span><span class=cF2>printf()</span><span class=cF0> has new codes. See </span><a href="https://tomawezome.github.io/ZealOS/Doc/Print.DD.html#l1"><span class=cF4>Print("") Format Strings</span></a><span class=cF0>.
|
|
<a name="l279"></a>
|
|
<a name="l280"></a>* All values are extended to 64-bit when accessed. Intermediate calculations are done with 64-bit values.
|
|
<a name="l281"></a>
|
|
<a name="l282"></a> </span><span class=cF2>U0 Main()
|
|
<a name="l283"></a> {
|
|
<a name="l284"></a> I16 i1;
|
|
<a name="l285"></a> I32 j1;
|
|
<a name="l286"></a>
|
|
<a name="l287"></a> j1 = i1 = 0x12345678; //Resulting i1 is 0x5678 but j1 is 0x12345678
|
|
<a name="l288"></a>
|
|
<a name="l289"></a> I64 i2 = 0x8000000000000000;
|
|
<a name="l290"></a> Print("%X\n", i2 >> 1); //Res is 0xC000000000000000 as expected
|
|
<a name="l291"></a>
|
|
<a name="l292"></a> U64 u3 = 0x8000000000000000;
|
|
<a name="l293"></a> Print("%X\n", u3 >> 1); //Res is 0x4000000000000000 as expected
|
|
<a name="l294"></a>
|
|
<a name="l295"></a> I32 i4 = 0x80000000; //const is loaded into a 64-bit reg var.
|
|
<a name="l296"></a> Print("%X\n", i4 >> 1); //Res is 0x40000000
|
|
<a name="l297"></a>
|
|
<a name="l298"></a> I32 i5 = -0x80000000;
|
|
<a name="l299"></a> Print("%X\n", i5 >> 1); //Res is 0xFFFFFFFFC0000000
|
|
<a name="l300"></a> }
|
|
<a name="l301"></a></span><span class=cF0>
|
|
</span></pre></body>
|
|
</html>
|