stdf - Standard Functions library
The built-in standrad functions library.
stdf library
The stdf library is a collection of standard functions within CrateAssembly that provides basic operations for manipulating floating-point values in variables. It includes functions for assigning values, arithmetic addition, subtraction, incrementing, decrementing, and printing values to the console.
mov Function
The mov
function is a fundamental operation in the stdf library for variable management. It is designed to set a specified value
to a variable named varname
. The function operates as follows:
If
varname
does not already exist,mov
will define a new variable with that name.If
varname
does exist,mov
will modify the existing variable's value to the newvalue
.Example Usage:
add Function
The add function is another essential operation in the stdf library for variable arithmetic. It allows for the addition of a specified amount to a variable named varname
. If varname
does not exist, the add function will return an error, indicating that the variable must be defined before performing arithmetic operations. The function behaves in the following manner:
The function requires that
varname
already exists.It will add the numerical value of
amount
to the current value ofvarname
.If
varname
does not exist, a DefinitionError is returned.
; Usage of the add function in CrateAssembly add varname amount ; Adds the value of 'amount' to the variable 'varname'
Example Usage:
If 'eax' was not previously defined, the add function would return an error:
sub Function
The sub function is a crucial arithmetic operation available in the stdf library for variable arithmetic. It subtracts a specified amount from a variable named varname. Here's how the sub function works:
The function requires the existence of the variable named varname.
It will subtract the numerical value of amount from the current value of varname.
If the variable varname does not exist, a DefinitionError is returned with a specific message.
Example Usage:
If 'ebx' was not previously defined, the sub function would return an error:
inc Function
The inc function is a convenient operation from the stdf library that allows for incrementing the value of an existing variable by 1. This function is particularly useful for operations where regular increments are needed. Here's how to use the inc function in CrateAssembly:
The inc function requires that the variable
varname
has already been declared.It increments the value of
varname
by 1.If
varname
does not exist, an error messageDefinitionError: varname is not defined
is shown.Example Usage:
If 'ecx' was not previously defined, the inc function would result in an error as shown below:
dec Function
The dec function is a simple yet essential operation in the stdf library meant for decreasing the value of an existing variable by 1. Below is a comprehensive guide to using the dec function in CrateAssembly:
The dec function decrements the value of a predefined variable by 1.
This function requires the variable varname to be already initialized.
If the variable varname does not exist, a DefinitionError is triggered, signaling that the variable needs definition.
Example Usage:
If 'edx' was not previously defined, the dec function would return an error:
prt Function
The prt function is part of the stdf library in CrateAssembly and it allows you to print the value of a variable or a direct numerical value, be it a floating-point number or an integer. The usage of the prt function is straightforward; it takes a single argument that can be either a variable name or a number.
Example Usage:
mul Function
The mul function is a key arithmetic operator provided by the stdf library in CrateAssembly, used for multiplying the value of an existing variable by a given amount. To understand and use the mul function effectively, consider the following points:
The function requires the existence of the variable referred to as varname.
The mul function multiplies the current value of varname by the numerical value provided in amount.
If the variable varname is not already defined in the code, executing the mul function will result in a DefinitionError with the message indicating that varname is not defined.
Example Usage:
In the event that 'eax' was not previously defined, the mul function would generate an error message:
div Function
The div
function is an arithmetic operation included in the CrateAssembly language for dividing the value of an existing variable by a specified amount. The following guidelines will help you understand and use the div
function:
Before using the
div
function, the variable referred to as varname must be previously declared and initialized.The div function divides the current value of varname by the numerical value given in amount.
In case varname is not defined in the code, a DefinitionError is triggered with the message "varname is not defined".
Example Usage:
If 'esi' was not previously defined, the div function would produce an error:
elev Function
The elev
function is an advanced mathematical operation available in the CrateAssembly language, allowing users to raise a previously defined variable to the power of a given amount. Below are the details on how to use the elev
function effectively:
Ensure that the
varname
has already been declared and initialized before using theelev
function.The
elev
function takes two arguments:varname
andamount
.It raises the value of
varname
to the power specified byamount
.If
varname
is not defined, the function triggers aDefinitionError
, indicating the variable needs to be declared.
Example Usage:
If 'ebx' was not previously defined, attempting to use the elev
function would result in an error:
root Function
The root
function is a mathematical operation present in the CrateAssembly language that calculates the specified root of a given variable. It's included as part of the standard function library (stdf). To use the root
function properly, follow these guidelines:
Before using the
root
function, ensure that the variable (varname
) has been previously declared and assigned a value.The
root
function takes two arguments:varname
andamount
, whereamount
represents the degree of the root (e.g., 2 for square root, 3 for cubic root, etc.).The function computes the specified root of the variable
varname
.If
varname
is not defined, executing theroot
function will result in aDefinitionError
with a message thatvarname
is not defined.Example Usage:
In the case where 'ecx' is not defined, you would encounter an error like so:
Last updated