Page 8 of 8 FirstFirst ... 678
Results 71 to 79 of 79

Thread: Further Developments in Asmosphere I.

  1. #71

    Re: Further Developments in Asmosphere

    Yes, well spotted Kent. I slipped back into 4 byte integer. In fact the = would not work either since the result is returned in the FPU. This is where overloading operators would be useful. If you dont mind RPN how about this:

    Create_vector p1
    var 8 x y z r
    (
    def to (
    fstp qword %1
    )
    def + (
    faddp st(1),st(0)
    )
    def squared (
    fmul st(0),st(0)
    )
    def sqroot (
    fsqrt
    )


    ; try the methods
    p1_getX to x
    p1_getY to y
    p1_getZ to z

    p1_getX squared p1_getY squared p1_getZ squared + + sqroot to r


    )





  2. #72
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: Further Developments in Asmosphere

    That looks cool. I am confused on the getZ squared + + sqroot to r

    Is the first + summing the squares of x y and z and then adding that sum to the sqroot and storing it all into r?
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #73

    Re: Further Developments in Asmosphere

    Hi Kent,

    You must be up very late or very early - (I have a random body clock ).

    The above expression is Pythagoras: sqr(x^2+y^2+z^2). Only it's Reverse Polish for the FPU which has a stack of 8 registers the topmost being the main accummulator.

    Today I am experimenting with providing a few more overloadable items namely ( ) and =. So that these can be taken over temporarily for customised notation.

  4. #74
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: Further Developments in Asmosphere

    Thanks for explaining the RPN for me in the example. Good luck on the cool project and overloading!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  5. #75
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: Further Developments in Asmosphere

    Charles you might want to check out this page. It explains creating a class in Ruby, there are some neat ideas without confusing syntax that seem similar to what you are doing.

    http://www.ruby-lang.org/en/documentation/quickstart/2/
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  6. #76

    Re: Further Developments in Asmosphere

    Thanks Kent, I'm keeping half an eye on Ruby. It is a long way up the code pyramid, and o2 is way down at the bottom somewhere, where the bugs have sharper teeth.

    O2 syntax is slightly complicated by having both a single line and multiline form and it has to be quite smart to detect the difference - usually by the presence of outer brackets, but we definitely need both forms when dealing with assembler.

    I've now got it overloading = and even brackets, quotes and comments - occasionally useful. It can adopt curly braces {} or begin .. end, amongst other possibilities. - putting together some test examples.

  7. #77
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: Further Developments in Asmosphere

    That is neat how you are putting all of this together so quickly Charles. Good luck on the examples, am here when they are ready to test out!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  8. #78

    Re: Further Developments in Asmosphere


    Shrinking the OOP Monster

    After trying out various OOP models, I think I've got one that comes out top, both in performance, flexibility and simplicity. The virtual table of functions has gone in favour of direct linkage but I dont think this will have any serious disadvantages.

    For test purposes I piggy-backed this model onto test_PF6 in the latest release. It does not do very much but this environment is very sensitive to malformed code so it's a good testing ground.

    Most the the work is done by macros which render the OOP into good old fashioned procedural code. The ecx register is used to carry the this pointer.

    This is a rather abstract example showing all the construction macros which are used to create classes with 2 levels of inheritance and various methods associated with each. The object created has access to the methods of class0 class1 and class2.

    The Generic OOP macros only have to be defined once.


    [code=thinbasic]
    ;==========================
    ; classes
    ;==========================


    ;------------------
    ;GENERIC OOP MACROS
    ;------------------


    def class type


    def context
    (
    indexers `ecx` offset 0 ascending var %1 this
    )

    def params
    (
    def parambytes %1
    indexers `ebp` offset 8 ascending
    )

    def locals
    (
    indexers `ebp` offset 0 descending
    push ebp
    mov ebp,esp
    sub esp,%1
    )

    def release
    (
    mov esp,ebp
    pop ebp
    ret parambytes
    )

    def create
    (
    var %1 %2
    %1_methods %2
    )

    def method
    (
    lea ecx, %1
    proc )


    ;------------------
    ;define classes
    ;------------------

    class class0
    (
    4 u 4 v 4 w
    )

    class class1
    (
    class0, 4 a 4 b 4 c
    )

    class class2
    (
    class1, 4 d 4 e
    )


    ;define methods
    ;---------------

    .init
    (
    context class0
    params 0
    locals 0
    ;...
    release
    )

    .get
    (
    context class1
    params 8
    var 4 a b
    locals 100
    ;...
    release
    )

    .put
    (
    context class1
    params 8
    var 4 aa bb
    locals 100
    var 4 i j
    def =
    (
    fld dword %1
    fstp dword %:
    )
    this.w=aa
    this.a=i
    ;...
    release
    )

    .clear
    (
    context class2
    params 0
    locals 0
    ;...
    release
    )

    ;define method calls
    ;-------------------


    def class0_methods
    (
    def %1_init method %1 init
    )

    def class1_methods
    (
    class0_methods %1
    def %1_get method %1 get
    def %1_put method %1 put
    )

    def class2_methods
    (
    class1_methods %1
    def %1_clear method %1 clear
    )

    '------------
    testclasses:
    '------------
    (
    indexers `esi` offset 100 ascending
    create class2 obj
    obj_init
    obj_get 1,2
    obj_put 3,4
    obj_clear
    ret
    )


    ;=========================
    ;=========================

    [/code]

    This is how it looks in machine code: - there is very little overhead associated with the OOP
    [code=asm]
    ; ;==========================
    ; ; classes
    ; ;==========================
    ; ;------------------
    ; ;GENERIC OOP MACROS
    ; ;------------------
    ; ;------------------
    ; ;define classes
    ; ;------------------
    ; ;define methods
    ; ;---------------
    .init ; .init
    ( ; (
    55 ; push ebp
    8B EC ; mov ebp,esp
    83 EC 00 ; sub esp,0
    8B E5 ; mov esp,ebp
    5D ; pop ebp
    C3 ; ret 0
    ) ; )
    .get ; .get
    ( ; (
    55 ; push ebp
    8B EC ; mov ebp,esp
    83 EC 64 ; sub esp,100
    8B E5 ; mov esp,ebp
    5D ; pop ebp
    C2 08 00 ; ret 8
    ) ; )
    .put ; .put
    ( ; (
    55 ; push ebp
    8B EC ; mov ebp,esp
    83 EC 64 ; sub esp,100
    D9 45 08 ; fld dword [ebp+8]
    D9 59 08 ; fstp dword [ecx+8]
    D9 45 FC ; fld dword [ebp-4]
    D9 59 0C ; fstp dword [ecx+12]
    8B E5 ; mov esp,ebp
    5D ; pop ebp
    C2 08 00 ; ret 8
    ) ; )
    .clear ; .clear
    ( ; (
    55 ; push ebp
    8B EC ; mov ebp,esp
    83 EC 00 ; sub esp,0
    8B E5 ; mov esp,ebp
    5D ; pop ebp
    C3 ; ret 0
    ) ; )
    ; ;define method calls
    ; ;-------------------
    ; '------------
    .testclasses ; .testclasses
    ; '------------
    ( ; (
    8D 4E 64 ; lea ecx, [esi+100]
    E8 gl init ; call init
    8D 4E 64 ; lea ecx, [esi+100]
    6A 02 ; push 2
    6A 01 ; push 1
    E8 gl get ; call get
    8D 4E 64 ; lea ecx, [esi+100]
    6A 04 ; push 4
    6A 03 ; push 3
    E8 gl put ; call put
    8D 4E 64 ; lea ecx, [esi+100]
    E8 gl clear ; call clear
    C3 ; ret
    ) ; )
    ; ;=========================
    ; ;=========================

    [/code]

  9. #79
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: Further Developments in Asmosphere

    Charles I am anxious to play with this. Can you tell me where I put that code and play with it?
    Thanks!

    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Page 8 of 8 FirstFirst ... 678

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
  •