Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: Further Developments in Asmosphere II

  1. #21

    Re: Further Developments in Asmosphere II

    New features in Asmosphere

    The earlier Asmosphere (~May 200 had a simple macro language without parameters. It also had a method of calling functions like a high level language (suitable for stdcall or Cdecl). It was also possible to pass string
    literals, which would always leave their pointers in the eax register.

    But linking to DLLs was quite hard work and relied on some of the procaddresses being passed with thinBasic variables.

    To make coding more efficient and escape from the minutiae of assembly coding it was necessary to introduce a few more elements into the preprocessor layer.

    Here is a recap of the recent Asmospsphere developments: (the ones that made it)

    Structures and variables and arrays were introduced to represent data in similar way to higher level languages.

    type

    types can be specified in multiline or single line format.


    type vec3
    (
    8 x
    8 y
    8 z
    )

    type rect 4 left 4 top 4 width 4 bottom


    types can contain other types


    type bounding_box
    (
    4 id
    vec3 A
    vec3 B
    )


    types can inherit other types

    type vec5
    (
    vec3,
    8 u
    8 v
    )



    var
    Variables can be defined with or without TYPE

    the structure or number of bytes is given first. Dimensions are specified in brackets)


    var 4 vv ww
    var 8 xx yy zz

    var rect rec
    var rect recs(100)
    var vec3 vecs(10,10)


    variables use the familiar dot notation when referring to their elements

    mov eax, rec.top

    variables are associared with specified index(es) using statements like this:

    indexers `ebp` offset 0 descending
    indexers `esi` offset 4 ascending
    indexers `ebp+eax*4` offset 0 descending


    To help with variable management the following constants are available for use as literals

    sizeof size of a type, element or variable
    offsetof offset of a variable or element
    spanof size of a dimension in an array variable




    def

    Macros can now support parameters %1..%9

    def greeting messagebox 0,`%1 %2`,`Greeting`,0

    greeting Hello World!


    As you can see, prototypes are not used, Instead, the macro 'consumes'
    adjacent words and incorporates them into its body. There a few restrictions where the %params may be placed.

    Some %params are a little more specialised:

    %0 takes the word to the left of the macro

    %b takes all the words on the line to the left

    %e takes all the words on the line to the right or an entire block if this is delineated by brackets.

    %a Assignment: this takes the words on the line to the left and spits them out in the line following the next proc.


    defs types and vars have much in common. They are all local and can therefore be confined with in scope by using brackets.

    These macro words have priority over almost all other words. It is therefore possible to create instant mini-languages for a particular task in your program. They will be out of scope beyond the closing bracket - and any prior meanings of the words will be restored.


    defs may contain other defs:
    note the double %% to disguise the macro parameters on the primary expansion.

    def floats
    (
    def + fadd %%1
    def - fsub %%1
    )



    Ruining the syntax:

    Breaking the rules macro names may be composed of several symbols, words or whole phrases:

    def `floating point operations`
    (
    def + fadd %%1
    def - fsub %%1
    def A qword [edx+08]
    def B qword [edx+16]
    )


    (
    floating point operations
    + A
    - B
    )



  2. #22

    Re: Further Developments in Asmosphere II

    RunTime support functions

    These rely upon the ebx register, which holds the address of the
    run time function table when your code is called with o2_exec

    LoadLibrary

    user32=loadlibrary `user32.dll`

    FreeLibrary

    freelibrary user32

    GetprocAddress

    msgbox getprocaddress user32,`MessageBoxA`
    proc msgbox 0,`Hello`,`greeting`,0



    data

    create inline data
    esi=data
    (
    nd 1.234
    nd 3.14159
    nl 2345
    )



    dataspace

    create inline data / workspace
    esi=dataspace 512

    GetMemory

    allocate system memory
    esi=getmemory 512

    FreeMemory

    release memory
    freememory esi

    Bind

    bind DLL calls
    bind user32
    (
    MessageBox MessageBoxA
    CreateWindowEx CreateWindowExA
    )
    messagebox 0,`hello`,`greeting`,0



    copy0

    for zstrings
    copy0 dest,source

    copy00

    for wstrings
    copy0o dest,source

    copyn

    for any string
    copyn dest,source,length


  3. #23

    Re: Further Developments in Asmosphere II


    New O2_ functions

    These are intended to improve performance and flexibility. They work with the O2_Buf buffer selector which supports code buffers 0..511

    O2_Exec

    Call assembled code in the current buffer

    O2_Asmo

    Assemble from specified source string but leave the result in the current buffer

    O2_Asmo_File

    Assemble from specified source file but leave the result in the current buffer


    O2_Len

    return length of code in current buffer

    O2_Get

    Get code string from current buffer

    O2_Put

    Insert code string into current buffer

    O2_Proc1 .. O2_Proc8

    Exec code at predefined entry points. These are offset from the beginning of the code string at 8 byte intervals: 8 16 24 32 etc.

    They support multitasking software such as sound and 3d frames which require setup, frame processing and termination calls while maintaining persistant data.

  4. #24

    Re: Further Developments in Asmosphere II

    Conclusion

    This is quite a lot to take in but there are a fair number of scripts included in the distribution to show how these new functions are used in practice. A chm manual is also available including the beginnings of an experimental code snippet generator called Omerlin codespells (possibly a wizard of Irish descent) , which will help to produce reliable standardised blocks of source code.

    It should seldom be necessary to write code from scratch. The easiest way to learn and develop assembly code is to take a working script and gradually modify it. Assembly code is far more picky than higher level languages, so it is vital to know where an error is triggered even if you can't immediately tell why.

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Further Developments in Asmosphere III
    By Charles Pegge in forum Legacy
    Replies: 30
    Last Post: 22-09-2008, 22:55

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •