Chapter 4. Introducing the Script Language

In this chapter the basics of the script language is introduced. We will focus on how Kick Assembler evaluates expressions, the standard values and libraries. Later chapters will deal with more advanced areas.

4.1. Expressions

Kick assembler has a built in mechanism for evaluating expressions. An example of an expression is 25+2*3/x. Expressions can be used in many different contexts, for example to calculate the value of a variable or to define a byte:

        lda #25+2*3/x
        .byte 25+2*3/x

Standard assemblers can only calculate expressions based on numbers, while Kick Assembler can evaluate expressions based on many different types like: Numbers, Booleans, Strings, Lists, Vectors, and Matrixes. So, if you want to calculate an argument based on the second value in a list you write:

        lda #35+myList.get(1) // 1 because first element is number 0 

Or perhaps you want to generate your argument based on the x-coordinate of a vector:

        lda #35+myVector.getX()

Or perhaps on the basis of the x-coordinate on the third vector in a list:

        lda #35+myVectorList.get(2).getX()

I think you get the idea by now. Kick Assembler's evaluation mechanism is much like those in modern programming languages. It has a kind of object oriented approach, so calling a function on a value(/object) executes a function specially connected to the value. Operators like +, -,*, /, ==, !=, etc., are seen as functions and are also specially defined for each type of value.

In the following chapters, a detailed description of how to use the value types and functions in Kick Assembler will be presented.