Added some crypto 100% implemented in Fun. (0.11.0)
This commit is contained in:
parent
5d3cfd9f65
commit
12a5646d56
25 changed files with 1926 additions and 12 deletions
27
src/vm/bitwise/band.c
Normal file
27
src/vm/bitwise/band.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* This file is part of the Fun programming language.
|
||||
* https://hanez.org/project/fun/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the ISC license.
|
||||
* https://opensource.org/license/isc-license-txt
|
||||
*
|
||||
* Added: 2025-09-29
|
||||
*/
|
||||
|
||||
/**
|
||||
* OP_BAND: bitwise AND (uint32 32-bit)
|
||||
* pops: b, a
|
||||
* pushes: (uint32_t)(a & b)
|
||||
*/
|
||||
case OP_BAND: {
|
||||
Value vb = pop_value(vm);
|
||||
Value va = pop_value(vm);
|
||||
uint32_t a = (va.type == VAL_INT) ? (uint32_t)va.i : 0u;
|
||||
uint32_t b = (vb.type == VAL_INT) ? (uint32_t)vb.i : 0u;
|
||||
uint32_t r = a & b;
|
||||
free_value(vb);
|
||||
free_value(va);
|
||||
push_value(vm, make_int((int64_t)(uint64_t)r));
|
||||
break;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue