mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +00:00
Add comments to some compiler methods.
Revert 440Hz 'A' tuning.
This commit is contained in:
parent
1b2144c451
commit
2836d36ca6
14 changed files with 99 additions and 65 deletions
|
@ -22,8 +22,6 @@ Features in development include:
|
|||
- Added comments and documentation
|
||||
- HolyC -> CosmiC
|
||||
- System-wide renaming for clarity
|
||||
- Removed shift-space mechanism
|
||||
- 440Hz 'A' tuning changed to 432Hz
|
||||
|
||||
## Getting started
|
||||
|
||||
|
@ -44,7 +42,7 @@ Afterwards, you can make a pull request on the `master` branch.
|
|||
|
||||
## Background
|
||||
|
||||
In around November of 2019, [VoidNV](https://web.archive.org/web/20210414181948/https://github.com/VoidNV) forked [ZenithOS](https://web.archive.org/web/20200811190005/https://github.com/VoidNV/ZenithOS) from TempleOS to continue Terry's work in a direction that would make it a viable operating system while still keeping the innovative and divine-intellect ideas and design strategies intact. At first, development occurred exclusively inside a VM and ISOs were occasionally generated as official releases, but this was scrapped and restarted from scratch. [Releases of the "old" ZenithOS are currently archived on the mega.nz website.](https://mega.nz/#F!ZIEGmSRQ!qvL6Wk6THzE-dazkfT6N3Q) The repository was removed in August of 2020, and reuploaded to [ZenithOS](https://web.archive.org/web/20210630230454/https://github.com/ZenithOS/ZenithOS). The latest archived [front page](https://web.archive.org/web/20200811190005/https://github.com/VoidNV/ZenithOS/), [master.zip](https://web.archive.org/web/20200811190054/https://codeload.github.com/VoidNV/ZenithOS/zip/master), and [related links](https://web.archive.org/web/*/https://github.com/VoidNV/ZenithOS/*) can be found on archive.org.
|
||||
In around November of 2019, [VoidNV](https://web.archive.org/web/20210414181948/https://github.com/VoidNV) forked [ZenithOS](https://web.archive.org/web/20200811190005/https://github.com/VoidNV/ZenithOS) from TempleOS. [Releases of pre-git ZenithOS are currently archived on the mega.nz website.](https://mega.nz/#F!ZIEGmSRQ!qvL6Wk6THzE-dazkfT6N3Q) The repository was removed in August of 2020, and reuploaded to [ZenithOS](https://web.archive.org/web/20210630230454/https://github.com/ZenithOS/ZenithOS). The latest archived [front page](https://web.archive.org/web/20200811190005/https://github.com/VoidNV/ZenithOS/), [master.zip](https://web.archive.org/web/20200811190054/https://codeload.github.com/VoidNV/ZenithOS/zip/master), and [related links](https://web.archive.org/web/*/https://github.com/VoidNV/ZenithOS/*) can be found on archive.org.
|
||||
|
||||
In July of 2021, ZealOS was forked from ZenithOS.
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ U0 ICSub(CIntermediateCode *tmpi,
|
|||
if (!swap)
|
||||
{
|
||||
op = 0x03;
|
||||
ICU24(tmpi, 0xD8F748);
|
||||
ICU24(tmpi, 0xD8F748); // NEG RAX
|
||||
}
|
||||
i = ICModr1(REG_RAX, t2, r2, d2);
|
||||
if (tmpi->ic_flags & ICF_LOCK)
|
||||
|
@ -257,7 +257,7 @@ U0 ICSub(CIntermediateCode *tmpi,
|
|||
if (swap)
|
||||
{
|
||||
op = 0x03;
|
||||
ICU24(tmpi, 0xD9F748);
|
||||
ICU24(tmpi, 0xD9F748); // NEG U64 RCX
|
||||
}
|
||||
if (r3 > 7)
|
||||
i++;
|
||||
|
@ -379,11 +379,11 @@ U0 ICMulEqu(CIntermediateCode *tmpi, I64 rip)
|
|||
MDF_DISP + tmpi->arg1_type_pointed_to, REG_RCX, 0, rip);
|
||||
r = REG_RBX;
|
||||
if (I8_MIN <= i <= I8_MAX)
|
||||
ICU32(tmpi, i << 24 + 0xDB6B48);
|
||||
ICU32(tmpi, i << 24 + 0xDB6B48); // IMUL2 U64 RBX, I8 i
|
||||
else
|
||||
{
|
||||
ICU24(tmpi, 0xDB6948);
|
||||
ICU32(tmpi, i);
|
||||
ICU24(tmpi, 0xDB6948); //
|
||||
ICU32(tmpi, i); // IMUL2 U64 RBX, U32 i
|
||||
}
|
||||
ICMov(tmpi, MDF_DISP + tmpi->arg1_type_pointed_to, REG_RCX, 0, MDF_REG + RT_I64, REG_RBX, 0, rip);
|
||||
}
|
||||
|
@ -424,12 +424,12 @@ U0 ICDiv(CIntermediateCode *tmpi, I64 rip)
|
|||
if (tmpi->ic_class->raw_type & RTF_UNSIGNED)
|
||||
{
|
||||
ICZero(tmpi, REG_RDX);
|
||||
ICU24(tmpi, 0xF1F748);
|
||||
ICU24(tmpi, 0xF1F748); // DIV U64 RCX
|
||||
}
|
||||
else
|
||||
{
|
||||
ICU16(tmpi, 0x9948);
|
||||
ICU24(tmpi, 0xF9F748);
|
||||
ICU16(tmpi, 0x9948); // CQO
|
||||
ICU24(tmpi, 0xF9F748); // IDIV U64 RAX
|
||||
}
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RAX, 0, rip);
|
||||
}
|
||||
|
@ -445,12 +445,12 @@ U0 ICDivEqu(CIntermediateCode *tmpi, Bool is_mod, I64 rip)
|
|||
if (tmpi->ic_class->raw_type & RTF_UNSIGNED)
|
||||
{
|
||||
ICZero(tmpi, REG_RDX);
|
||||
ICU24(tmpi, 0xF1F748);
|
||||
ICU24(tmpi, 0xF1F748); // DIV U64 RCX
|
||||
}
|
||||
else
|
||||
{
|
||||
ICU16(tmpi, 0x9948);
|
||||
ICU24(tmpi, 0xF9F748);
|
||||
ICU16(tmpi, 0x9948); // CQO
|
||||
ICU24(tmpi, 0xF9F748); // IDIV U64 RAX
|
||||
}
|
||||
if (is_mod)
|
||||
ICMov(tmpi, tmpi->arg1.type & MDG_MASK + tmpi->arg1_type_pointed_to,
|
||||
|
@ -468,12 +468,12 @@ U0 ICDivEqu(CIntermediateCode *tmpi, Bool is_mod, I64 rip)
|
|||
if (tmpi->ic_class->raw_type & RTF_UNSIGNED)
|
||||
{
|
||||
ICZero(tmpi, REG_RDX);
|
||||
ICU24(tmpi, 0xF1F748);
|
||||
ICU24(tmpi, 0xF1F748); // DIV U64 RCX
|
||||
}
|
||||
else
|
||||
{
|
||||
ICU16(tmpi, 0x9948);
|
||||
ICU24(tmpi, 0xF9F748);
|
||||
ICU16(tmpi, 0x9948); // CQO
|
||||
ICU24(tmpi, 0xF9F748); // IDIV U64 RAX
|
||||
}
|
||||
if (is_mod)
|
||||
ICMov(tmpi, MDF_DISP + tmpi->arg1_type_pointed_to, REG_RBX, 0, MDF_REG + RT_I64, REG_RDX, 0, rip);
|
||||
|
@ -496,12 +496,12 @@ U0 ICMod(CIntermediateCode *tmpi, I64 rip)
|
|||
if (tmpi->ic_class->raw_type & RTF_UNSIGNED)
|
||||
{
|
||||
ICZero(tmpi, REG_RDX);
|
||||
ICU24(tmpi, 0xF1F748);
|
||||
ICU24(tmpi, 0xF1F748); // DIV U64 RCX
|
||||
}
|
||||
else
|
||||
{
|
||||
ICU16(tmpi, 0x9948);
|
||||
ICU24(tmpi, 0xF9F748);
|
||||
ICU16(tmpi, 0x9948); // CQO
|
||||
ICU24(tmpi, 0xF9F748); // IDIV U64 RAX
|
||||
}
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RDX, 0, rip);
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ U0 ICAddSubEctEqu(CIntermediateCode *tmpi, U8 type_pointed_to,
|
|||
done = TRUE;
|
||||
}
|
||||
else if (op.u8[2] == 0x24)
|
||||
{//AND
|
||||
{ // AND
|
||||
ICMov(tmpi, MDF_REG + RT_I64, REG_RCX, 0, t2, r2, d2, rip);
|
||||
ICMov(tmpi, MDF_REG + RT_I64, REG_RAX, 0, MDF_DISP + type_pointed_to, REG_RCX, 0, rip);
|
||||
res_reg = REG_RAX;
|
||||
|
@ -613,7 +613,7 @@ U0 ICAddSubEctEqu(CIntermediateCode *tmpi, U8 type_pointed_to,
|
|||
done = TRUE;
|
||||
}
|
||||
else if (type_pointed_to < RT_I64)
|
||||
{//OR/XOR
|
||||
{ // OR/XOR
|
||||
ICMov(tmpi, MDF_REG + RT_I64, REG_RCX, 0, t2, r2, d2, rip);
|
||||
ICMov(tmpi, MDF_REG + RT_I64, REG_RAX, 0, MDF_DISP + type_pointed_to, REG_RCX, 0, rip);
|
||||
res_reg = REG_RAX;
|
||||
|
|
|
@ -13,7 +13,7 @@ U0 ICNot(CIntermediateCode *tmpi, I64 rip)
|
|||
{
|
||||
i = ICModr1(tmpi, tmpi->arg1.type, tmpi->arg1.reg, tmpi->arg1.disp);
|
||||
ICRex(tmpi, i.u8[1]);
|
||||
ICU16(tmpi, i.u8[2] << 8 + 0xF6); //TEST ?,0xFF
|
||||
ICU16(tmpi, i.u8[2] << 8 + 0xF6); // TEST ?, 0xFF
|
||||
ICModr2(tmpi, i,, tmpi->arg1.disp, rip + 1);
|
||||
ICU8(tmpi, 0xFF);
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ U0 ICNot(CIntermediateCode *tmpi, I64 rip)
|
|||
ICMov(tmpi, MDF_REG + RT_I64, REG_RAX, 0, tmpi->arg1.type, tmpi->arg1.reg, tmpi->arg1.disp, rip);
|
||||
ICTest(tmpi, REG_RAX);
|
||||
}
|
||||
ICU24(tmpi, 0xC0940F); //SETZ AL
|
||||
ICU32(tmpi, 0xC0B60F48);//MOVZX RAX,AL
|
||||
ICU24(tmpi, 0xC0940F); // SETE AL
|
||||
ICU32(tmpi, 0xC0B60F48);// MOVZX RAX, AL
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_U64, REG_RAX, 0, rip);
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,10 @@ U0 ICAndAnd(CIntermediateCode *tmpi, I64 rip)
|
|||
r2 = tmpi->arg1.reg;
|
||||
ICZero(tmpi, REG_RAX);
|
||||
ICTest(tmpi, r2);
|
||||
ICU16(tmpi, 0x0874);
|
||||
ICU16(tmpi, 0x0874); // JE I8 0xA
|
||||
ICTest(tmpi, REG_RCX);
|
||||
ICU16(tmpi, 0x0374);
|
||||
ICU24(tmpi, 0xC0FF48);
|
||||
ICU16(tmpi, 0x0374); // JE I8 0x5
|
||||
ICU24(tmpi, 0xC0FF48); // INC U64 RAX
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RAX, 0, rip);
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ U0 ICOrOr(CIntermediateCode *tmpi, I64 rip)
|
|||
}
|
||||
ICZero(tmpi, REG_RAX);
|
||||
ICU24(tmpi, 0xC80B00 + i + r2 << 16);
|
||||
ICU16(tmpi, 0x0374);
|
||||
ICU24(tmpi, 0xC0FF48);
|
||||
ICU16(tmpi, 0x0374); // JE I8 0x5
|
||||
ICU24(tmpi, 0xC0FF48); // INC U64 RAX
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RAX, 0, rip);
|
||||
}
|
||||
|
||||
|
@ -87,15 +87,15 @@ U0 ICXorXor(CIntermediateCode *tmpi, I64 rip)
|
|||
r2 = tmpi->arg1.reg;
|
||||
ICZero(tmpi, REG_RBX);
|
||||
ICTest(tmpi, r2);
|
||||
ICU16(tmpi, 0x0374);
|
||||
ICU24(tmpi, 0xC3FF48);
|
||||
ICU16(tmpi, 0x0374); // JE I8 0x5
|
||||
ICU24(tmpi, 0xC3FF48); // INC U64 RBX
|
||||
|
||||
ICZero(tmpi, REG_RAX);
|
||||
ICTest(tmpi, REG_RCX);
|
||||
ICU16(tmpi, 0x0374);
|
||||
ICU24(tmpi, 0xC0FF48);
|
||||
ICU16(tmpi, 0x0374); // JE I8 0x5
|
||||
ICU24(tmpi, 0xC0FF48); // INC U64 RAX
|
||||
|
||||
ICU24(tmpi, 0xC33348);
|
||||
ICU24(tmpi, 0xC33348); // XOR U64 RAX, U64 RBX
|
||||
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RAX, 0, rip);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ U0 ICComp(CIntermediateCode *tmpi, I64 us, I64 is, I64 rip)
|
|||
if (tmpi->ic_class->raw_type & RTF_UNSIGNED || tmpi->ic_flags & ICF_USE_UNSIGNED)
|
||||
is = us;
|
||||
ICU16(tmpi, 0x300 + is);
|
||||
ICU24(tmpi, 0xC0FF48);
|
||||
ICU24(tmpi, 0xC0FF48); // INC U64 RAX
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RAX, 0, rip);
|
||||
}
|
||||
else
|
||||
|
@ -211,7 +211,7 @@ U0 ICComp(CIntermediateCode *tmpi, I64 us, I64 is, I64 rip)
|
|||
if (tmpi->ic_class->raw_type & RTF_UNSIGNED || tmpi->ic_flags & ICF_USE_UNSIGNED)
|
||||
is = us;
|
||||
ICU16(tmpi, 0x300 + is);
|
||||
ICU24(tmpi, 0xC0FF48);
|
||||
ICU24(tmpi, 0xC0FF48); // INC U64 RAX
|
||||
ICMov(tmpi, tmpi->res.type, tmpi->res.reg, tmpi->res.disp, MDF_REG + RT_I64, REG_RAX, 0, rip);
|
||||
}
|
||||
}
|
||||
|
@ -298,11 +298,11 @@ U0 ICBitOps(CIntermediateCode *tmpi, CICArg *arg1, CICArg *arg2, CIntermediateCo
|
|||
U0 ICToUpper(CIntermediateCode *tmpi, I64 rip)
|
||||
{
|
||||
ICMov(tmpi, MDF_REG + RT_I64, REG_RAX, 0, tmpi->arg1.type, tmpi->arg1.reg, tmpi->arg1.disp, rip);
|
||||
ICU32(tmpi, 0x61F88348);
|
||||
ICU16(tmpi, 0x0A7C);
|
||||
ICU32(tmpi, 0x7AF88348);
|
||||
ICU16(tmpi, 0x047F);
|
||||
ICU32(tmpi, 0xE0C08348);
|
||||
ICU32(tmpi, 0x61F88348); // CMP U64 RAX, I8 0x61
|
||||
ICU16(tmpi, 0x0A7C); // JL I8 0xC
|
||||
ICU32(tmpi, 0x7AF88348); // CMP U64 RAX, I8 0x7A
|
||||
ICU16(tmpi, 0x047F); // JG I8 0x6
|
||||
ICU32(tmpi, 0xE0C08348); // ADD U64 RAX, I8 0xE0
|
||||
}
|
||||
|
||||
U0 ICToI64(CCompCtrl *cc, CIntermediateCode *tmpi, I64 rip)
|
||||
|
@ -327,8 +327,8 @@ U0 ICToBool(CCompCtrl *, CIntermediateCode *tmpi, I64 rip)
|
|||
r = REG_RAX;
|
||||
}
|
||||
ICTest(tmpi, r);
|
||||
ICU24(tmpi, 0xC0950F); //SETNZ AL
|
||||
ICU32(tmpi, 0xC0B60F48); //MOVZX RAX,AL
|
||||
ICU24(tmpi, 0xC0950F); // SETNE AL
|
||||
ICU32(tmpi, 0xC0B60F48); // MOVZX RAX, AL
|
||||
}
|
||||
|
||||
U0 ICPreIncDec(CIntermediateCode *tmpi, I64 op, I64 rip)
|
||||
|
|
|
@ -863,7 +863,7 @@ U0 ICSwitch(CIntermediateCode *tmpi, I64 rip, Bool nobound, CCompCtrl *cc, U8 *b
|
|||
|
||||
if (lb->flags & (CMF_I8_JMP_TABLE | CMF_U8_JMP_TABLE | CMF_I16_JMP_TABLE | CMF_U16_JMP_TABLE))
|
||||
{
|
||||
ICU16(tmpi, 0xC381); //ADD EBX,0x12345678
|
||||
ICU16(tmpi, 0xC381); // ADD EBX, 0x########
|
||||
if (buf && cc->flags & CCF_AOT_COMPILE)
|
||||
{
|
||||
tmpa = CAlloc(sizeof(CAOTAbsAddr));
|
||||
|
@ -886,12 +886,12 @@ U0 ICSwitch(CIntermediateCode *tmpi, I64 rip, Bool nobound, CCompCtrl *cc, U8 *b
|
|||
|
||||
U0 ICLocalVarInit(CIntermediateCode *tmpi)
|
||||
{
|
||||
ICU24(tmpi, 0xC48B48);
|
||||
ICU16(tmpi, 0x5748);
|
||||
ICU24(tmpi, 0xF88B48);
|
||||
ICU24(tmpi, 0xC1C748);
|
||||
ICU24(tmpi, 0xC48B48); // MOV U64 RAX, U64 RSP
|
||||
ICU16(tmpi, 0x5748); // PUSH U64 RDI
|
||||
ICU24(tmpi, 0xF88B48); // MOV U64 RDI, U64 RAX
|
||||
ICU24(tmpi, 0xC1C748); // MOV U64 RCX, I32 0x########
|
||||
ICU32(tmpi, tmpi->ic_data);
|
||||
ICU16(tmpi, sys_var_init_val << 8 + 0xB0);
|
||||
ICU24(tmpi, 0xAA48F3);
|
||||
ICU16(tmpi, 0x5F48);
|
||||
ICU16(tmpi, sys_var_init_val << 8 + 0xB0); // MOV AL, sys_var_init_val
|
||||
ICU24(tmpi, 0xAA48F3); // REP_STOSB
|
||||
ICU16(tmpi, 0x5F48); // POP U64 RDI
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ extern I64 LexExpression(CCompCtrl *cc);
|
|||
extern I64 LexCharGet(CCompCtrl *cc);
|
||||
extern CCodeMisc *OptLabelFwd(CCodeMisc *lb);
|
||||
extern CIntermediateCode *OptPass012(CCompCtrl *cc);
|
||||
extern U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets);
|
||||
extern U0 OptPass4(CCompCtrl *cc,COptReg *reg_offsets,I64 *_type);
|
||||
extern U0 OptPass3(CCompCtrl *cc, COptReg *reg_offsets);
|
||||
extern U0 OptPass4(CCompCtrl *cc, COptReg *reg_offsets, I64 *_type);
|
||||
extern U0 OptPass5(CCompCtrl *cc);
|
||||
extern U0 OptPass6(CCompCtrl *cc);
|
||||
extern I64 OptPass789A(CCompCtrl *cc, COptReg *reg_offsets, U8 *buf, CDebugInfo **_debug);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class CInternalType
|
||||
{
|
||||
U8 type,size, name[8];
|
||||
U8 type, size, name[8];
|
||||
} internal_types_table[INTERNAL_TYPES_NUM] = {
|
||||
{RT_I0, 0, "I0i"},
|
||||
{RT_I0, 0, "I0"},
|
||||
|
|
|
@ -26,7 +26,7 @@ CMP_TEMPLATES::
|
|||
MOV RBX, RSP
|
||||
FLD U64 [RBX]
|
||||
FLD U64 8[RBX]
|
||||
@@20: FPREM
|
||||
@@20: FPREM
|
||||
FSTSW
|
||||
TEST AX, 0x400
|
||||
JNZ @@20
|
||||
|
|
|
@ -463,3 +463,26 @@ $TX,"Peter Gadwa",HTML="http://www.wired.com/magazine/2010/11/mf_ticketmaster/al
|
|||
$TX,"Ticketmaster",HTML="http://www.nytimes.com/1994/11/06/business/ticketmaster-s-mr-tough-guy.html?pagewanted=a"$
|
||||
$TX,"Tom Foley",HTML="http://web.gccaz.edu/~tfoley/perspage.html"$
|
||||
$TX,"Graphic Technologies",HTML="https://web.archive.org/web/20020811060541/http://www.graphic-technologies.com/"$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<1>",BI=1$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|