CFuck

From Esolang
Jump to navigation Jump to search

CFuck is, like its name, a C extension to brainfuck. It is invented by User:None1.

Data structure

It also has a byte queue.

Commands

All the original commands are the same, but there are extra commands:

Extra commands
Command Description
* Push a byte (current cell) onto the queue
% Pop a byte and store it in current cell
@"DllName"FunctionName(arguments)ReturnType This command is very complicated, it first loads DllName and gets the function FunctionName, then it passes the arguments to the function, then it treats the return value as ReturnType and breaks it into bytes and pushes it onto the queue.
Argument/Return type Description
b Pop a byte and current argument is the byte
i/I Pop 4 bytes, and compose a little/big endian 4-byte integer from it
l/L Pop 8 bytes, and compose a little/big endian 8-byte integer from it
s Pop bytes until front of queue is a zero, compose a C-Style string from it
v void, doesn't push anything when used as a return type, and it is invalid to use it as an argument type

For instance, if queue contains 10 0 0 0 1 3 0 0 0 65 66 67 0 from front to back and the command @"a.dll"f(bIis)l is the same as calling the function f in a.dll like f('\n',1,3,"ABC") and treat the return value as an 8 bit integer.

Examples

Wait for a key

@"msvcrt.dll"getch()v

Wait for a key and print it

@"msvcrt.dll"getch()b%.

Message box

********++++++++[>++++++++<-]>+***>*<***>*****@"user32.dll"MessageBoxA(Lssi)v

It creates a message box with its title and content both AAA.