commit de8b1611f450bdd710910ed225639d4863fd25eb
parent 72a6f120e181b8ee1ec55ee1777d0fd0a180d378
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 2 Jun 2022 16:30:14 -0400
TIL about x86's SETcc
Diffstat:
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/dusk.asm b/dusk.asm
@@ -476,28 +476,30 @@ defword 'xor', 3, word_xor, word_or
ret
defword 'not', 3, word_not, word_xor
- sub dword [ebp],1 ; carry=1 if 0
-set_PS_to_carry: ; set PS top to 0 or one depending on CF
- lahf ; c = bit 0
- mov al, ah
- and eax, 1
- mov [ebp], eax
+ mov eax, [ebp]
+ mov dword [ebp], 0
+ test eax, eax
+ setz byte [ebp]
ret
defword '<', 1, word_lt, word_not
pspop eax
sub [ebp], eax
- jmp set_PS_to_carry
+ mov dword [ebp], 0
+ setc byte [ebp]
+ ret
defword '<<c', 3, word_shlc, word_lt
- sub ebp,4
+ pspush 0
shl dword [ebp+4], 1
- jmp set_PS_to_carry
+ setc byte [ebp]
+ ret
defword '>>c', 3, word_shrc, word_shlc
- sub ebp,4
+ pspush 0
shr dword [ebp+4], 1
- jmp set_PS_to_carry
+ setc byte [ebp]
+ ret
; ( n u -- n )
defword 'lshift', 6, word_lshift, word_shrc