ZealOS/src/Demo/Carry.CC

46 lines
549 B
HolyC
Raw Normal View History

2020-02-15 20:01:48 +00:00
//Shows the $LK,"Carry",A="MN:Carry"$ function. It holds the CPU carry flag.
//$LK,"U",A="MN:U"$() Unassemble to make sure it is right.
2020-02-16 00:20:04 +00:00
U0 BigCount()
2020-02-15 20:01:48 +00:00
{
U64 lo=0,hi=0;
"BigCount\n";
while (hi<0x10) {
lo+=1<<58;
hi+=Carry;
2020-03-01 01:59:50 +00:00
"%016X %016X\n",hi,lo;
}
2020-02-15 20:01:48 +00:00
}
2020-02-16 00:20:04 +00:00
BigCount;
2020-02-15 20:01:48 +00:00
U0 BigShift()
{
U64 lo=1,hi=0;
"Big Shift\n";
while (lo||hi) {
hi<<=1;
lo<<=1;
hi+=Carry;
2020-03-01 01:59:50 +00:00
"%016X %016X\n",hi,lo;
}
2020-02-15 20:01:48 +00:00
}
BigShift;
U0 Branch()
{
U64 i=0xFFCC3311,j;
'Branch\n';
for (j=0;j<64;j++) {
i<<=1;
if (Carry)
'1';
else
'0';
}
'\n';
2020-02-15 20:01:48 +00:00
}
Branch;