Skip to content

Commit

Permalink
unittests: Test RC{R,L} wraparound behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
bylaws committed Jan 21, 2024
1 parent e323938 commit 576cf61
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 0 deletions.
50 changes: 50 additions & 0 deletions unittests/ASM/PrimaryGroup/2_D3_02_4.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%ifdef CONFIG
{
"RegData": {
"RBX": "0x00000006",
"RDI": "0x00000004",
"RDX": "0x00000002",
"RSI": "0x00000000",
"R8": "0x0",
"R9": "0x0",
"R10": "0x1",
"R11": "0x1"
}
}
%endif

mov rbx, 0x00000001
mov rdi, 0x00000001
mov rdx, 0x40000000
mov rsi, 0x40000000
mov rcx, 34 ; Test wraparound

stc
rcl ebx, cl
lahf
mov r8w, ax
shr r8, 8
and r8, 1 ; We only care about carry flag here

clc
rcl edi, cl
lahf
mov r9w, ax
shr r9, 8
and r9, 1 ; We only care about carry flag here

stc
rcl edx, cl
lahf
mov r10w, ax
shr r10, 8
and r10, 1 ; We only care about carry flag here

clc
rcl esi, cl
lahf
mov r11w, ax
shr r11, 8
and r11, 1 ; We only care about carry flag here

hlt
50 changes: 50 additions & 0 deletions unittests/ASM/PrimaryGroup/2_D3_02_5.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%ifdef CONFIG
{
"RegData": {
"RBX": "0x00000001",
"RDI": "0x00000001",
"RDX": "0x40000000",
"RSI": "0x40000000",
"R8": "0x1",
"R9": "0x0",
"R10": "0x1",
"R11": "0x0"
}
}
%endif

mov rbx, 0x00000001
mov rdi, 0x00000001
mov rdx, 0x40000000
mov rsi, 0x40000000
mov rcx, 32 ; Test wraparound with zero shift

stc
rcl ebx, cl
lahf
mov r8w, ax
shr r8, 8
and r8, 1 ; We only care about carry flag here

clc
rcl edi, cl
lahf
mov r9w, ax
shr r9, 8
and r9, 1 ; We only care about carry flag here

stc
rcl edx, cl
lahf
mov r10w, ax
shr r10, 8
and r10, 1 ; We only care about carry flag here

clc
rcl esi, cl
lahf
mov r11w, ax
shr r11, 8
and r11, 1 ; We only care about carry flag here

hlt
50 changes: 50 additions & 0 deletions unittests/ASM/PrimaryGroup/2_D3_03_7.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%ifdef CONFIG
{
"RegData": {
"RBX": "0x40000000",
"RDI": "0x00000000",
"RDX": "0x60000000",
"RSI": "0x20000000",
"R8": "0x1",
"R9": "0x1",
"R10": "0x0",
"R11": "0x0"
}
}
%endif

mov rbx, 0x00000002
mov rdi, 0x00000002
mov rdx, 0x80000000
mov rsi, 0x80000000
mov rcx, 34 ; Test wraparound

stc
rcr ebx, cl
lahf
mov r8w, ax
shr r8, 8
and r8, 1 ; We only care about carry flag here

clc
rcr edi, cl
lahf
mov r9w, ax
shr r9, 8
and r9, 1 ; We only care about carry flag here

stc
rcr edx, cl
lahf
mov r10w, ax
shr r10, 8
and r10, 1 ; We only care about carry flag here

clc
rcr esi, cl
lahf
mov r11w, ax
shr r11, 8
and r11, 1 ; We only care about carry flag here

hlt
50 changes: 50 additions & 0 deletions unittests/ASM/PrimaryGroup/2_D3_03_8.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%ifdef CONFIG
{
"RegData": {
"RBX": "0x00000002",
"RDI": "0x00000002",
"RDX": "0x80000000",
"RSI": "0x80000000",
"R8": "0x1",
"R9": "0x0",
"R10": "0x1",
"R11": "0x0"
}
}
%endif

mov rbx, 0x00000002
mov rdi, 0x00000002
mov rdx, 0x80000000
mov rsi, 0x80000000
mov rcx, 32 ; Test wraparound with zero shift

stc
rcr ebx, cl
lahf
mov r8w, ax
shr r8, 8
and r8, 1 ; We only care about carry flag here

clc
rcr edi, cl
lahf
mov r9w, ax
shr r9, 8
and r9, 1 ; We only care about carry flag here

stc
rcr edx, cl
lahf
mov r10w, ax
shr r10, 8
and r10, 1 ; We only care about carry flag here

clc
rcr esi, cl
lahf
mov r11w, ax
shr r11, 8
and r11, 1 ; We only care about carry flag here

hlt

0 comments on commit 576cf61

Please sign in to comment.