The progress is in order ...
Posted by 3Nigma on May 11 2008 08:43:52
A month or so ago...I talked about eniAsm v0.7 , why not make it v0.8? Well...it has been done!

Extended News

On 10th of April,this year,I've told you about eniAsm v0.7,you thought that I was done with you?
Think again...today,I'm proud to present to you eniAsm v0_8 .



articles: 103.gif

1.Version details


Is that it? Well...this version comes along with a small friend...eniAsm IDE which comes freely in the archive in it's special folder.
Why have I made eniAsm IDE ? Well...I wouldn't want it to be done till eniAsm was done but by the middle of April,I participated on a Programming contest held in my region[won second place by the sheer fact that my presentation sucked ,being excited about the concept and all,but I was happy in the way that the first prize wasn't given to anybody] and I was told that they despite all that was console[too much Linuxy I guess],so I made a small IDE : eniAsm IDE which I'll describe later in the article.
Besides this,I've also implemented one of my basics concepts: an assembler in which the user is the boss of instruction naming for which I am sort of proud,added many instructions and examples to show their usage and tidied up the code a little.
Let's continue...

articles: 120.gif
2.What does the archive contain?

I've kept the original v0.7 archive file structure in v0.8 so I'll explain it briefly:
The only part that needs explaining is the 'eniAsm IDE'. Upon opening this folder you'll see 4 files[talked about later in the article] but no source code. The reason why this has happened is because there would not be any reason not to put the source in the archive,the reason I've chosen not to do this is the state of the 'eniAsm IDE'. I've considered that it is so rudimentary,that it is not worth posting yet. In the future,when the 'eniAsm IDE' advances,be sure that you'll see a 'eniAsm IDE sources',but that will happen some time in the future,not now!

articles: 141.gif

3.A 'little' more about 'eniAsm IDE' ...

You know about it's history,the location in the archive and why it doesn't contain the sources.Now...let's go on a little further and talk about what it can do and how to use it.
Using `eniAsm IDE` one can assemble eniAsm sources more elegantly,this was the main purpose of it's existence[it's official one]. It comes in the need of the needy user that finds it hard to assemble sources in the command line so I consider that it is a step forward in the development.
Upon executing `eniAsm IDE.exe` ,you will be confronted with an image like this:

It's a simple IDE interface as you can see. It consists of the primary source code window[the place where you write your eniAsm assembler code] and a menu line which hosts some options.
Let's talk about the options a bit,shall we?
I'll lay them out sequentially:
Ok,let's see what are the Options all about?
Upon clicking the menu option "Options" you will see something like this:

As you can see,you can select 2 destinations:
  1. Assembler location - the actual location of the eniAsm.exe [the actual assembler]
  2. eAsm config file - the .easmcl file used for the current source file [talked about later in the article] For now it is better to know that each and every source uses a easm language specification file,so the location of this is mandatory as is the location for the assembler
You must ensure that these options are right prior to the assembly of a file. Usually you can set them once and the next time you enter the IDE , they will be automatically picked up from a IDE config file.
Upon saving a source,in it's source file header it's automatically embedded it's .easmcl file location,but you should check this location prior to any first assembly of a source file just in case.

Now that we have seen the options I must state that the IDE doesn't contain the notion of syntax highlighting,not yet really. In fact...the main difference between the IDE and the notepad is,apart the fact that Notepad is more complex,the fact that it has the "Project" in its menu.
I've posted this IDE just because I had it made on demand[not the way I'd liked it to be]. Many modifications are scheduled to be implemented[in 2 weeks another contest awaits eniAsm and ,by then, I hope to implement at least the syntax highlighting part,and fix a bug or 2 :P] but for now...works on "eniAsm IDE" are halted until further notice!

articles: 104.gif
4.Where has the project gotten to?

...you might ask...
As I said, a lot of progress has been made to eniAsm. Although the class relationship remains the same as in v0.7,many new instruction were added to this version as the following table shows:

Command

Implemented as

Parameters

Example

Aaa

Aaa

--

Aaa,

Aad

Aad

--

Aad,

Aam,

Aam

--

Aam,

Aas

Aas

--

Aas,

Cbw

Convertbw

--

Convertbw,

cdq

convertdq

--

Convertdq

Cmp

Compare

Immediate to register

Compare 5 to ah,

Cupid

Cupid

--

Cupid,

Cwd

Convertwd

--

Convertwd,

Cwde

Convertwde

--

Convertwde,

Daa

Daa

--

Daa,

Das

Das

--

Das,

Hlt

Halt

--

Hlt,

In

Inport

Immediate value[port]

Inport 9,

Into

Into

--

Into,

Invd

Invd

--

Invd,

Iret

Irets

--

Irets,

Ja

Jifa

<label> [beta]

Jifa label_to_jump,

Jae

Jifae

<label> [beta]

Jifae label_to_jump,

Je

Jife

<label> [beta]

Jife label_to_jump,

Jmp

Jump

<label> [beta]

jump label_to_jump,

jz

Jifz

<label> [beta]

Jifz label_to_jump,

Lahf

Lahf

--

Lahf,

Leave

Leave

--

Leave,

Neg

Negate

Register

Negate ax,

Or

Or

Immediate to register

Or 7 to bx,

Out

Outport

Immediate value[port]

Outport 9,

Pop

Pop

register

Pop ax,

Push

Push

register

Push ax,

Rdmsr

Rdmsr,

--

Rdmsr,

Rdpmc

Rdpmc,

--

Rdpmc,

Rdtsc

Rdtsc

--

Rdtsc,

Rsm

Rsm,

--

Rsm

Sahf

Storefah

--

Storefah,

Shl

shiftl

Register

Shiftl bx,

Shr

Shiftr,

Register

Shiftr bx,

sub

Substract

Register 1 to register 2

Substract ax to bx,

Sub

Substract

Immediate to register

Substract 2 to bx,

test

Test

Immediate to register

Test 10 to ah,

Wbinvd

Wbinvd

--

Wbinvd

Wrmsr

Wrmsr

--

Wrmsr,

Xlat

Tbllooktrans

--

Tbllooktrans,

xor

Xor

Register1 to register 2

Xor ax to bx,

letting us to make some rather interesting examples,as you will see.
Other things that I have done include tweaking the appearance of the code a bit[so it may look prettier :)].
The most interesting thing that I have come to implement to this version is the notion of "every user is the boss of their commands" system.What this does is,well...what it says it does. Every user has the right and possibility to choose how to call any instruction in the eniAsm environment.
How are these options stored? Now the .easmcl file come to answer this. All of the user defined instructions are stored in an .easmcl file. Now...it is in order to specify that,although custom naming is allowed from this version forward,eniAsm has a standard language specification which it can be found in the "eniAsm IDE" folder under the name of "default.easmcl" .
Let's take a look at the content of this file:
[default easm language]
add=add
clc=clearcf
cld=cleardf
cli=clearif
cmc=compcf
dec=decr
inc=incr
int=inter
loop=loop
mov=move
mul=multip
nop=noop
not=not
popa=popallr
popf=popallf
pusha=pushallr

...

As you can see...the way a .easmcl file is encoded is plain simple...
comments which are descarded are typed on new lines in [ ]
custom instructions are typed in the form of :
<intel_standard_instruction_name>=<user_defined_instruction>
where
What can the user define?
Any instruction that is supported by the current version...and more[but instructions that are not implemented are discarded so it's a waste of time to try to write them in the .easmcl file and hope that eniAsm will recognize them :))] .An interesting fact is that ... eniAsm v0.8 lets the user define even his command tier using the special macro "special_to" for assignment.
Example...if "special_to= to " in program A and "special_to= with " in program B then "add ax to bx," in program A is equivalent to "add ax with bx," in program B which I would say its pretty nifty stuff.
The reason why I've made this step in letting the programmer decide how to use a instruction is increased familiarity results in increased productivity ... and also it's more inter-portable.What this means is that...if a guy from US writes some code in eniAsm in his custom command list and sends the code along with his .easmcl file to a guy in russia...what then?
In the future..."eniAsm IDE" will take care of this...basically it will convert US's code,using US's custom list,into what ever will the russian guy want. But that's in a future state...even though the first steps are made...a lot is waited but there are good steps to start with.

P.S : All my examples will use,by default, default.easmcl if not other specified
[to see the actual usage of the .easmcl power...reffer to the "eniex_for_skullbox_default.eas" and the "eniex_for_skullbox_romana.eas" examples below]

articles: 144.gif
5.The examples

...Lets face it,if the exams weren't here,how many of you would have read my article,let alone find it useful[taking in consider that I'm addressing the newbies of course]
First of all I'm going to start by proving the .easmcl file philosophy.

5.1 "eniex_for_skullbox_default.eas" and "eniex_for_skullbox_romana.eas"
I'll start,as I said earlier,by showing you the philosophy behind the ".easmcl" file. Consider the following 2 sources:
eniex_for_skullbox_default.eas
eniex_for_skullbox_romana.eas
*program that highlights the usage of 'add' along with the loop instruction[testing stage]*prints the even digits
*assembled with eniasm v0_7
move 25 to cx,
move 0 to dh, *row
move 0 to dl, *column

ciclu:
*set cursor position
move 2 to ah,
move 0 to bh,
inter 16,

*print "hello eniasm!"
move 0 to bh,
move 14 to ah,

move 'h' to al, *prints 'h'
inter 16,
move 'e' to al, *prints 'e'
inter 16,
move 'l' to al, *prints 'l'
inter 16,
move 'l' to al, *prints 'l'
inter 16,
move 'o' to al, *prints 'o'
inter 16,
move ' ' to al, *prints ' '
inter 16,
move 'e' to al, *prints 'e'
inter 16,
move 'n' to al, *prints 'n'
inter 16,
move 'i' to al, *prints 'i'
inter 16,
move 'a' to al, *prints 'a'
inter 16,
move 's' to al, *prints 's'
inter 16,
move 'm' to al, *prints 'm'
inter 16,
move '!' to al, *prints '!'
inter 16,

incr dh,
incr dl,
loop ciclu,

move 0 to ah,
inter 22,
rets,
*program that highlights the usage of 'add' along with the loop instruction[testing stage]*prints the even digits
*assembled with eniasm v0_7
muta 25 la cx,
muta 0 la dh, *row
muta 0 la dl, *column

eticheta:
*set cursor position
muta 2 la ah,
muta 0 la bh,
interrupt 16,

*print "hello eniasm!"
muta 0 la bh,
muta 14 la ah,

muta 'h' la al, *prints 'h'
interrupt 16,
muta 'e' la al, *prints 'e'
interrupt 16,
muta 'l' la al, *prints 'l'
interrupt 16,
muta 'l' la al, *prints 'l'
interrupt 16,
muta 'o' la al, *prints 'o'
interrupt 16,
muta ' ' la al, *prints ' '
interrupt 16,
muta 'e' la al, *prints 'e'
interrupt 16,
muta 'n' la al, *prints 'n'
interrupt 16,
muta 'i' la al, *prints 'i'
interrupt 16,
muta 'a' la al, *prints 'a'
interrupt 16,
muta 's' la al, *prints 's'
interrupt 16,
muta 'm' la al, *prints 'm'
interrupt 16,
muta '!' la al, *prints '!'
interrupt 16,

incrementeaza dh,
incrementeaza dl,
ciclu eticheta,

muta 0 la ah,
interrupt 22,
iesi,
The first one is assembled using the file default.easmcl as its reference language and the second one,using romana.easmcl file[located in the eniAsm IDE directory in the archive].
Upon assembling the 2 sources,you will get the same output which is :

You don't believe me? Try it yourself...

5.2 "2_sample.eas"
The next example is sort of basic,it basically prints out the 15[which it is calculated by adding 5 to 10] in binary.
*prints '00001110b' which is 15 [adding 5[al] to 10[bl]]
*assembled with eniasm v0_8
move 5 to al,
move 10 to bl,
add al to bl,
substract 1 to bl,

move 8 to cx,
print:
move 2 to ah,
move '0' to dl,
test 128 to bl,
jifz zero,
move '1' to dl,
zero:
inter 33,
shiftl bl,
loop print,

move 'b' to dl,
inter 33,

move 0 to ah,
inter 22,
rets,
Upon assembling,the output will be:


5.3 "eniex_test_aaa.eas" and "eniex_test_aas.eas"
The following 2 sources are also basic and show the usage of 'aaa' and 'aas' commands in eniAsm[commands that are implemented since this version]
eniex_test_aaa.eas
eniex_test_aas.eas
*displays '14' on the screan which is calculated by adding 4 to 9*assembled with eniasm v0_8

*we store a 9
move 9 to ah,
*then we store a 5
move 5 to al,
*we add the 5 to 9=14
add ah to al,
*clear tens byte of bcd
xor ah to ah,

*adjust result to bcd form
*ah = 1, al = 4 -> '14'
aaa,

*store content of the ax register
move ax to dx,

*output the result
move 14 to ah,

*output first digit
or 48 to dh,
move dh to al,
inter 16,

*output second digit
or 48 to dl,
move dl to al,
inter 16,

*wait for keypress,then exit
move 0 to ah,
inter 22,
*displays '7' on the screan which is calculated by substracting 8 from 15*assembled with eniasm v0_8

*calculate 5-8
move 5 to al,
move 8 to bl,
substract bl to al,

*convert to binary coded decimal, al = 7 and 1 is borrowed from ah
*like calculating 15-8
aas,

*convert to a printable char
or 48 to al,

*print the result
move 14 to ah,
inter 16,

*wait the keypress then exit
move 0 to ah,
inter 22,

Upon assembling and executing,it will print out:

5.4 "eniex_graf_ex_default.eas" and "0_sample_vga_graphics.eas"
Now we are getting to the interesting part.These are pretty cool examples if I may add so. I will not post a screen on what the 2 sources do but instead,I'll let you assemble them or run them directly from the "eniAsm tests" directory.
eniex_graf_ex_default.eas
0_sample_vga_graphics.eas
*displays a graphical dot
*assembled with eniasm v0_8

*set graphics mode
move 0 to ah,
move 19 to al,
inter 16,

*call put pixel with parameters
move 12 to ah,
move 15 to al,
move 0 to bh,
move 10 to cx,
move 10 to dx,
inter 16,

*wait for key then exit
move 0 to ah,
inter 22,
rets,
*displays a graphical rectangle on the screen
*assembled with eniasm v0_8

*set graphics mode
move 0 to ah,
move 19 to al,
inter 16,

*draw upper line
move 150 to cx,
move 20 to dx,
move 10 to al, *color
u1:
move 12 to ah,
inter 16,

decr cx,
compare 100 to cx,
jifae u1,

*draw bottom line
move 150 to cx,
move 30 to dx,
move 10 to al, *color
u2:
move 12 to ah,
inter 16,

decr cx,
compare 100 to cx,
jifa u2,

*draw left line
move 100 to cx,
move 30 to dx,
move 14 to al, *color
u3:
move 12 to ah,
inter 16,

decr dx,
compare 20 to dx,
jifa u3,

*draw right line
move 150 to cx,
move 30 to dx,
move 14 to al, *color
u4:
move 12 to ah,
inter 16,

decr dx,
compare 20 to dx,
jifa u4,

*wait for keypress
move 0 to ah,
inter 22,

*exit
rets,
Although the header of the sources present a little about what you might aspect from them,I challenge you to find out how.

5.5 "eniex_colors.eas"
An interesting example about showing all the possibilities of outputting a character on different backgrounds.It's basically a color map,nice to see indeed.
*displays a color map on the screen with all the possible colors in assembly*assembled with eniasm v0_8

*set video mode
move 3 to ax,
inter 16,

*disable blinking
move 4099 to ax,
move 0 to bx,
inter 16,

*start from top left corner
move 0 to dl,
move 0 to dh,
move 0 to bl,
jump next_char,

*advanse one row
next_row:
incr dh,
compare 16 to dh,
jife stop_print,
move 0 to dl,

*set new cursor position at dl , dh
next_char:
move 2 to ah,
inter 16,

move 'a' to al,
move 0 to bh,
move 1 to cx,
move 9 to ah,
inter 16,

*advanse it for char attribute
incr bl,

incr dl,
compare 16 to dl,
jife next_row,
jump next_char,

*stops the print and sets the cursor position at dl , dh
stop_print:
move 10 to dl,
move 5 to dh,
move 2 to ah,
inter 16,

*teletype output
move 'x' to al,
move 14 to ah,
inter 16,

*wait for key pressed then exit
move 0 to ah,
inter 22,
rets,
Assembling it,then running it you will get:

I personally like it...
articles: 113.gif
6.The end

...of this version description at least."eniAsm" is not dead nor it will be dead ... I got attached to the project and it has become one of my main priorities.I truly believe in it's potential.

What do future releases hold for this project?
As I said..."eniAsm IDE" has stalled a bit but ... "eniAsm" is on the roll...one of my main priorities besides optimizing "eniAsm" for new instructions and so on,is to implement a variable system.Hopefully ... this will be done,at least started as a concept in v0.9[hopefully released this month or at the beginning of the next one]

ill next time,take care...and stay tunned ;)
Any questions/suggestions/whatever at all…post them here.
(c)3Nigma 13May 2008