Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
88
Task/Bitwise-operations/Phix/bitwise-operations.phix
Normal file
88
Task/Bitwise-operations/Phix/bitwise-operations.phix
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
enum SHL, SAR, SHR, ROL, ROR
|
||||
function bitop(atom a, integer b, integer op)
|
||||
atom res
|
||||
#ilASM{
|
||||
[32]
|
||||
mov eax,[a]
|
||||
call :%pLoadMint
|
||||
mov ecx,[b]
|
||||
mov edx,[op]
|
||||
cmp dl,SHL
|
||||
jne @f
|
||||
shl eax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,SAR
|
||||
jne @f
|
||||
sar eax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,SHR
|
||||
jne @f
|
||||
shr eax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,ROL
|
||||
jne @f
|
||||
rol eax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,ROR
|
||||
jne @f
|
||||
ror eax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
int3
|
||||
::storeres
|
||||
lea edi,[res]
|
||||
call :%pStoreMint
|
||||
[64]
|
||||
mov rax,[a]
|
||||
mov rcx,[b]
|
||||
mov edx,[op]
|
||||
cmp dl,SHL
|
||||
jne @f
|
||||
shl rax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,SAR
|
||||
jne @f
|
||||
sar rax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,SHR
|
||||
jne @f
|
||||
shr rax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,ROL
|
||||
jne @f
|
||||
rol rax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
cmp dl,ROR
|
||||
jne @f
|
||||
ror eax,cl
|
||||
jmp :storeres
|
||||
@@:
|
||||
int3
|
||||
::storeres
|
||||
lea rdi,[res]
|
||||
call :%pStoreMint
|
||||
}
|
||||
return res
|
||||
end function
|
||||
|
||||
procedure bitwise(atom a, atom b)
|
||||
printf(1,"and_bits(%b,%b) = %032b\n",{a,b,and_bits(a,b)})
|
||||
printf(1," or_bits(%b,%b) = %032b\n",{a,b, or_bits(a,b)})
|
||||
printf(1,"xor_bits(%b,%b) = %032b\n",{a,b,xor_bits(a,b)})
|
||||
printf(1,"not_bits(%b) = %032b\n",{a,not_bits(a)})
|
||||
printf(1," shl(%b,%b) = %032b\n",{a,b,bitop(a,b,SHL)})
|
||||
printf(1," sar(%b,%b) = %032b\n",{a,b,bitop(a,b,SAR)})
|
||||
printf(1," shr(%b,%b) = %032b\n",{a,b,bitop(a,b,SHR)})
|
||||
printf(1," rol(%b,%b) = %032b\n",{a,b,bitop(a,b,ROL)})
|
||||
printf(1," ror(%b,%b) = %032b\n",{a,b,bitop(a,b,ROR)})
|
||||
end procedure
|
||||
|
||||
bitwise(0x800000FE,7)
|
||||
Loading…
Add table
Add a link
Reference in a new issue