This document provides an overview of the features and commands available in Game Core. The language is designed to be simple and supports basic arithmetic operations, conditional jumps, and register manipulation. Game Core is a simple programming language that is built for the Game Machine Console but can also be used in other operating systems such as Windows and Linux. The Game Machine is a high-performance console that let you hops in games and interact with them like it was the real world also known as VR (virtual reality). The Game Machine usually supports Game Cubes to make the performance better and for addons as well and you can install some Game Cubes and Packs and Machines at the gameMachineWeb
Game Packs is like the Game Machines but less powerful but it is also compact, portable version and also supports the ability to install multiple Game Cubes on it.
- In order to use Game Core, you need to install the Game Machine Shell from the gameMachineWeb or gameCoreRepo
- Put it in your project folder or somewhere you can easily access
- Create a Game Core file in the project folder with the
.gc
extension, Right now we recommend you using VS Code and installing the Assembly Language Support or any asm language support - Run this command
GameCoreShell.exe {filename}
or you cna just runGameCoreShell.exe
then select the file.
- In order to use Game Core, you need to install the Game Machine Shell from the gameMachineWeb or gameCoreRepo
- Put it in your project folder or somewhere you can easily access like the
/bin
folder - Create a Game Core file in the project folder with the
.gc
extension, Right now we recommend you using VS Code and installing the Assembly Language Support or any asm language support - Run this command
GameCoreShell {filename}
or you cna just runGameCoreShell
then select the file.
Game Core uses a simplified syntax for writing commands. Each command consists of a keyword followed by its arguments. Arguments are separated by spaces.
Comments can be added to the code using the ;
symbol. Anything after the ;
on the same line will be treated as a comment and ignored during execution.
Macros can be used by first defining a macro by using the #
symbol then the name of the macro then the value like this #name 30
.
Note: Macros can be named and have a value of anything.
Macros can be accessed by using the %
symbol and then the name of the macro like this %name%
then it will be replaced with the value of the macro
#PI Pie-314
writeln "Pie is %PI%"
You can import files using the #import
directive, which will replace the import statement with the file text. It can be used in the following syntax:
#import filename
where filename
is the path to the file containing the code.
For example, consider a file named functions.gc
with the following content:
jmp functions_end
sayHello:
writeln "hello, world!"
ret
functions_end:
The reason why we need to jump to the end of the file is because it will run everything in the file so it will say hello, world!
write away if we don't
To import the function into your code, you can use #import
directive:
#import functions.gc
call sayHello
The language has a set of registers that can be used to store and manipulate data. Each register is identified by a unique name,
and it can store AV
(actual value typeof int), LV
(long value typeof long), FV
(flags), and also a SrcValue
which can be anything.
The following registers are available:
eax
: General-purpose register for arithmetic operations.ebx
: General-purpose register for arithmetic operations.ecx
: General-purpose register for arithmetic/loop operations (loop counter).edx
: General-purpose register for arithmetic operations.esi
: General-purpose register for storing data.edi
: General-purpose register for storing data that is mostly use for functions returns.esp
: Stack pointer register.eip
: Instruction pointer register (used for control flow).
cs
: unusedds
: unusedes
: unusedfs
: unusedgs
: unusedss
: unused
cr0
: default register forreadline
cr1
: default register forgetkey
cr2
: unusedcr3
: unusedcr4
: unusedcr5
: unusedcr6
: unusedcr7
: unused
dr0
: used for os infoSRC
: This will store the versionAV
: 2 for Windows NT or later, 4 for Unix, 7 for Other
dr1
: unuseddr2
: unuseddr3
: unuseddr4
: unuseddr5
: unuseddr6
: unuseddr7
: used as a exit code
.flags
: the global flags register.mem
: output memory usage
The memory have by default 65775, 10000 minimal. each bit is represented by a int
or 32 bit int value.
The last 5000 ints in memory are reserved therefor should not be overwritten. It is common practice to use the first couple of bits in memory reserved for strings.
The language supports various commands that perform arithmetic operations, control flow, and register manipulation. Here are the available commands:
add dest value
: Adds thevalue
to the value stored in thedest
register.sub dest value
: Subtracts thevalue
from the value stored in thedest
register.mul dest value
: Multiplies the value in thedest
register by thevalue
.div dest value
: Divides the value in thedest
register by thevalue
.mod dest value
: Computes the modulus of the value in thedest
register by thevalue
.and dest value
: Performs bitwise AND between the value in thedest
register and thevalue
.or dest value
: Performs bitwise OR between the value in thedest
register and thevalue
.xor dest value
: Performs bitwise XOR between the value in thedest
register and thevalue
.inc dest
: Adds 1 to thedest
register.dec dest
: Subtracts 1 from thedest
register.shl reg value
: Shiftsreg
to the left byvalue
(value
can also be a register)shr reg value
: Shiftsreg
to the right byvalue
(value
can also be a register)not reg
: inverts all the bits including the two's complement bitcmp (value | regA) (value | regB)
: ComparesregA's
AV
withregB's
AV
, ifregA
==regB
thenZero
flag is set, ifregA
>regB
thenPositive
flag is set, ifregA
<regB
thenNegative
flag is setcmpSrc regA regB
: ComparesregA's
SrcValue
withregB's
SrcValue
, ifregA
==regB
thenZero
flag is set, ifregA
andregB
are not null thenPositive
flag is set, ifregA
andregB
are both equal to true thenNegative
flag is set
set reg value
: Sets thereg
SrcValue
register to the specifiedvalue
.mov dest src
: Copies everything from thesrc
register to thedest
register and set theCopied
flag ondest
.movSrc dest src
: Copies thesrc
registerSrcValue
to thedest
register but do not set theCopied
flag.setAV reg (reg | value)
: Sets thereg
register'sAV
to the specifiedvalue
.setLV reg (reg | value)
: Sets thereg
register'sLV
to the specifiedvalue
.sf reg value
: Set thereg
registerFV
to the specifiedvalue
.convertAV reg
: converts theSrcValue
register intoreg's
AV
slot, when fails it will set theFailure
flag.
jmp label
: Unconditionally jumps to the specifiedlabel
.jz label
: Jumps to the specifiedlabel
if theZero
flag is setjnz label
: Jumps to the specifiedlabel
if theZero
flag is not setjg label
: Jumps to the specifiedlabel
if thePositive
flag is setjl label
: Jumps to the specifiedlabel
if theNegative
flag is setjf label
: Jumps to the specifiedlabel
if theFailure
flag is setjnf label
: Jumps to the specifiedlabel
if theFailure
flag is not setjo
: Jumps to the specifiedlabel
if theOverflow
flag is setloop label
: Subtracts 1 fromecx
(loop counter) and then jumps to location along asecx
is not zero or less then zero.
push reg
: Pushes the specified registers's AV onto the stack.pop reg
: Pops the top value from the stack and stores it in thereg
register.
readMem destAddress
: Reads memory fromdestAddress
and stores it in theAV
of.mem
, also stores the char representation of the memory in theSrcValue
writeRawMem destAdress value
: Writes thevalue
to the memory at the specifieddest
addresswriteMem destAddress values
: Writes avalues
which is seperated by spaces and can be any type between string and ints, to the memory at the specifieddest
addressfillMem startAdress endAdress value
: Fills the memory within the range ofstart
toend
addresscopyMem src dest length
: Copies a block of memory fromsrc
todest
with the specifiedlength
.cmpMem memoryAddressA memoryAddressB size
: Compares the memory frommemoryAddressA
tomemoryAddressB
, withsize
being the block size.Zero
flag will be set ifA
andB
are equal to each other,Overflow
flag will also be set ifmemoryAddress
is out of boundscmpStr memoryAddressA (memoryAddressB | string)
: Similar tocmpMem
but if will compare until null termination.
writeSrc reg
: Displays theSrcValue
of the specified register.writeAV reg
: Displays theAV
of the specified register.writeLV reg
: Displays theLV
of the specified register.writeln text
: Displays the specified text on a new line.write text
: Displays the specified text.newline
: Add a new linereadline (optional: reg)
: Reads a line from the console and puts it into theSrcValue
ofreg
orcr0
by default.getkey (optional: reg)
: Reads a key press from the console and puts the keychar intoSrcValue
and keyCode intoAV
and the Modifiers into theFV
ofreg
orcr1
by defaultbeep (optinal: frequency, duration)
: windows only makes a beep sound in the consoleprintRawMem start length
: prints the memory contents within the specified range fromstart
toend
.printMem start
: prints the character representation of the memory contents within the specified range fromstart
to the next null character.readfile path
: reads the file contents from the specifiedpath
into memory and returns the memoryAddress intoedi
.createfile file
: createsfile
.writefile path (contents | memoryAddress)
: writescontents
or the string atmemoryAddress
to the specified file atpath
.
call label
: Calls the specifiedlabel
(function) and saves the return address on the stack.ret
: Returns from a function by popping the return address from the stack.exit
: Exits the program with the value stored in thedr7
register.wait ms
: Waits for a certain amount of millisecondsrand min max
: Generate a random number betweenmin
andmax
, and put the number inedi
registergetOS
: this function gets the os info and stores it into thedr0
register, by default this calls at the start of the programclear
: this function clears the console screen
Labels are used to mark specific locations in the code, allowing for easy control flow using jump commands. A label is any valid identifier followed by a colon :
. Labels must start in the first column of the line.
- Bit 0 represents the
Zero
flag - Bit 1 represents the
Positive
flag - Bit 2 represents the
Negative
flag Bit 3 represents theCarry
flag- Bit 4 represents the
Overflow
flag - Bit 5 represents the
Copied
flag - Bit 6 represents the
Failure
flag
- Bit 0 represents the
Alt
flag - Bit 1 represents the
Shift
flag - Bit 2 represents the
Control
flag
Here are some examples of code written in the assembly-like language:
- Calculating the factorial of 5 and displaying the result:
setAV eax 5
setAV ebx 1
.loop:
mul eax ebx
dec eax
cmp eax ecx
jz .done
jmp .loop
.done:
mov ebx eax
writeAV eax
- Simple function call example:
call .myFunction
writeln "Returned from function call"
.myFunction:
writeln "Inside function"
ret
- Simple memory usage:
#newline 10 ; the assci representation of the newline
#helloString 40 ; memory address
#byeString 70
writeMem %helloString% "Hello, world!" %newline% 0
writeMem %byeString% "Bye, world!" %newline% 0
printMem %helloString% ; output: Hello, world!
cmpStr %helloString% %byeString%
jz .equals
jmp .notequals
.equals:
writeln "They are equal"
exit
.notequals:
writeln "They are not equal"
exit
; output: They are not equal
Game Core provides a basic set of commands for arithmetic operations, control flow, and register manipulation. It is designed to be simple and easy to understand, making it suitable for educational purposes or small projects. However, it lacks more advanced features and optimizations commonly found in real-world assembly languages.