ALE Assembly Language Engine 1.1

Hi Everyone,

I’ve just completed the updates to 1.1 which includes the following:

Changes:

  1. Improved and simplified engine
  2. String and numeric variable datatypes
  3. Improved and additional XOJO wrappers
  4. Memory reduction by reducing duplicate constants to a single stack location
  5. Constants and variables data table
  6. Improved bounds update to include constant and variable data
  7. Clean up of bit codes
  8. Many documentation changes

My other thought is if I leave the engine unlocked, so people can view it as this seemed to be an issue for some, can I call it open source but still license it as donation ware? I’d still like to be the maintainer of the engine code and would like any suggestions for changes to be directed to myself. Is this possibly or do I still need to keep it locked?

Anyway the only changes in Version 1.1 that would stop version 1.0 code from running is reset_ALE no longer requires a parameter, and performing a bounds update in your asm code is now a mov 0,eax rather than a 4. From now on I don’t plan on making any further language changes which would stop previous version code from running.

Here is a sample of version 1.1 code I’ve been using for testing:

lbl "_start:"

var_ "inString", S, "Hello World"
var_ "outString", S, ""
var_ "memPointer", N, 0

call_ "writeString"
call_ "upperCaseString"
call_ "readString"
call_ "deallocateExtraStack"

mov 1,eax  //Exit the program
int


lbl "writeString"
mov "inString", ebx
mov 4, eax
int
ret

lbl "readString"
mov "outString", ebx  //Move the string location to ebx
mov esi, edx  //move the total stack to edx
inc edx  //increment the starting point by one
mov 3, eax  //call for a stack read
int
ret

lbl "deallocateExtraStack"
cmp esi, esp  //get the total number of extra stack items to remove, after the variables
mov eax, ecx //place the total in ECX the loop counter
lbl "deallocateLoopStart"
pop //remove the last item off the stack
loop_ "deallocateLoopStart"

mov 0,eax  //do a bounds update as we've made major changes to the stack
int

ret

lbl "upperCaseString"
cmp esi, esp  //get the total number of extra items on the stack to Uppercase
mov eax, ecx //place the total in ECX the loop counter

mov esp, "memPointer" //Move the upper stack location into our memory pointer

lbl "upperCaseLoopStart"

cmp 97, "[memPointer]"  //check to see if the value in the pointer is in the correct range
jl "notLowerCase"
cmp 122, "[memPointer]"
jg "notlowercase" 

//decrease the value in pointer R1 by 32
sub_ 32, "[memPointer]"

lbl "notLowerCase"

dec "memPointer"

loop_ "upperCaseLoopStart"

ret

writeStringVariable_ALE("inString", tfLowerCaseString.Text)

//Run the engine after all code sent
run_ALE("_start:")

tfUpperCaseString.Text = readStringVariable_ALE("outString")

I hope you’ve all had a great day…

Kind Regards

Trig

4 Likes

You can do what you want with your code. That sounds flippant but it’s the truth.

2 Likes

Thanks Beatrix,

Regards

Trig

I second Beatrix, you control your code and how it can be legally used. Open-source does not make a difference if you make this plain.

If you decide to go this route, consider posting the project on GitHub. In addition to encouraging others to submit changes and improvements, they offer a variety of boilerplate licenses to include in your project, and I’m sure one of them will fit your needs.

2 Likes

Hi Everyone,

To assist with engine development I’ve just added an execution profiler to my development environment. This allows me to get an instant overview of how often core instructions are being called within the engine over the course of running multiple ALE programs. I then use this information to reorder the instructions in the engine code so that the most often called instructions are checked first, greatly improving performance.

You may also notice that there are now only 22 core instructions in the engine, I’ve removed heaps, another speed increase. More complex commands have been replaced with assembly code utilising the core instructions. You still enter the commands in your program the same way, its the compiler which replaces them with assembly code.

Kind Regards

Trig

2 Likes

Hi Everyone,

I’ve been asked if it’s possible for users to add their own assembly instructions into ALE, because maybe they cut their assembly teeth on Z80, 6502, or yet another assembly implementation which had a slightly different instruction set to the original 1985 x86 specification I’m using. The answer is, sure it is, and you don’t need access to the ALE engine to do it. The only stipulation is that the command you wish to implement must be possible in the ALE core instructions. Core instructions are those listed in the documentation with a code reference beside their name.

So lets say you wanted to add a SWAP instruction which switches the values in two stack addresses. All you need to do is create a method in your XOJO application called SWAP which accepts two locations as stings, so that they’ll be evaluated by the ALE compiler to point to numeric addresses, registers or even variables.

In your swap method you would then need to add the ALE assembly commands to achieve your task: Simple.

mov mLoc1, ebx
mov mLoc2, mLoc1
mov ebx, mLoc2

From then on in your ALE code you can use your SWAP instruction just like any other instruction, and the best thing is adding your own instructions will have no impact on the engine performance because we haven’t added any new core instructions.

lbl "_start:"

mov 100, r0
mov 200, r1
swap r0, r1

mov 1, eax
int

Regards

Trig