diff options
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -291,7 +291,7 @@ mvprintw_time :: (y: s32, x: s32, time: s64, space: s32) -> int { } } -add_int64 :: (x :s64, y: s64) -> s64 { +add_int64 :: (x :s64, y: s64) -> s64 #dump { // TODO Comparing implementations. return ifx (y > 0 && x > S64_MAX - y) then S64_MAX else ifx (y < 0 && x < S64_MIN - y) then S64_MIN else @@ -1164,6 +1164,32 @@ read_enter_confirmation :: inline (row: int, style: int, message: string) -> boo main :: () { + + add :: (value_a: s64, value_b: s64) -> s64, bool #dump { // TODO Comparing implementaitons using dump + result: s64 = ---; + flag: bool = ---; + #asm { + mov d: gpr === d, 9223372036854775807; + mov a: gpr === a, value_a; + mov b: gpr === b, value_b; + add a, b; + seto flag; // Signal overflow. + mov result, a; + mov a, value_a; + shr a, 63; + add a, d; + mov c: gpr, value_a; + xor c, b; + xor b, result; + not b; + or c, b; + test c, c; + cmovns result, a; + } + return result, flag; + } + + // value_a: s64 = 2; // value_b: s64 = S64_MAX-1; value_a: s64 = -2; |
