1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 03:01:22 +00:00

Merge pull request #104 from QB64Cobalt/development

Added 4 New Bit Functions
This commit is contained in:
Fellippe Heitor 2019-11-16 22:08:22 -03:00 committed by GitHub
commit 5ff044b027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 1 deletions

View file

@ -643,6 +643,10 @@ extern long double string2f(qbs*str);
//Cobalt(aka Dave) added the next 2 lines
int64 func__shr(int64 a1, int b1);
int64 func__shl(int64 a1, int b1);
int64 func__readbit(int64 a1, int b1);
int64 func__setbit(int64 a1, int b1);
int64 func__resetbit(int64 a1, int b1);
int64 func__togglebit(int64 a1, int b1);
#ifndef QB64_WINDOWS
extern void Sleep(uint32 milliseconds);
extern void ZeroMemory(void *ptr,int64 bytes);
@ -977,6 +981,18 @@ inline int64 func__shl(int64 a1,int b1)
inline int64 func__shr(int64 a1,int b1)
{return a1>>b1;}
inline int64 func__readbit(int64 a1, int b1)
{if (a1 & 1<<b1) return -1; else return 0;}
inline int64 func__setbit(int64 a1, int b1)
{return a1 | 1<<b1;}
inline int64 func__resetbit(int64 a1, int b1)
{return a1 & ~(1<<b1);}
inline int64 func__togglebit(int64 a1, int b1)
{return a1 ^ 1<<b1;}
//Working with 32bit colors:
inline uint32 func__rgb32(int32 r,int32 g,int32 b,int32 a){
if (r<0) r=0;
@ -2211,4 +2227,4 @@ void QBMAIN(void *unused)
#include "../temp/main.txt"
#endif
//} (closed by main.txt)
//} (closed by main.txt)

View file

@ -3407,3 +3407,39 @@ id.callname = "func__getconsoleinput"
id.args = 0
id.ret = LONGTYPE - ISPOINTER
regid
clearid
id.n = "_READBIT"
id.subfunc = 1
id.callname = "func__readbit"
id.args = 2
id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.ret = INTEGER64TYPE - ISPOINTER
regid
clearid
id.n = "_SETBIT"
id.subfunc = 1
id.callname = "func__setbit"
id.args = 2
id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.ret = INTEGER64TYPE - ISPOINTER
regid
clearid
id.n = "_RESETBIT"
id.subfunc = 1
id.callname = "func__resetbit"
id.args = 2
id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.ret = INTEGER64TYPE - ISPOINTER
regid
clearid
id.n = "_TOGGLEBIT"
id.subfunc = 1
id.callname = "func__togglebit"
id.args = 2
id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.ret = INTEGER64TYPE - ISPOINTER
regid