flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > object like code

Thread Post new topic Reply to topic

Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 21 Nov 2007, 23:45
By seeking a manner to call function, i've conclude that manner to pass parameters via registers as pointers is really good!!!

;ds:esi is the current item. all items are in the same segment
;ds:edi is the parent item. it's not a problem
.call = 0
.x = 4
.y = 8
.xl = 12
.yl = 16
.datasize = 20
.datas = 24
.bmp = 28
.txt = 32
.colors = 36
dd f.caller,x,y,xl,yl,@f-$-4
dd objet1,objet2,objet3
dd f.frame,0,0,0,0,@f-$-4,0,0 
;these zeros are the work space for the called function
db c1,c2,c3,c4

All parameters and work space are defined at [DS:ESI] & [DS:EDI]
all object begins with this type of header
[ESI+item.call] is the routine ptr used by the object, defined by the system, or the application coder, in the function list.
The capacity to make trees with this structure is good to make a datacode section that brings a modular evolutive interface.

All functions are not always graphical oriented, so <X,Y,XL,YL> fields can be replaced by what is needed by the function. for exemple: memory zones, messages ptr, buffers, stacks, ...

Size field is not always needed too, it's used for parent items, and to signal who many parameters are available for the function.

Size can be modified to mask some possible features. Txt, bmp, colors, wav, etc...

If no more parameters are defined, size is still there and set to 0.
Then, if size is modified in function, as a counter for exemple, it shall be cleared before return.

The question is , is it possible to integrate this programing style into the C or other high level languages based on stack parameters.

Here the stack is used to save differents states, not more.

To pass parameters, the calling code must provide the item header
minimal header space is 4 bytes, for the function number.

Functions are sorted in a function list and are accessible from any application, because it's a global table.
Api can have also it's own function list built at loading, and during execution, if new functions are imported for exemple.

Function list consist of an array of 2dwords.
One 2dwords is a linear ptr to the desired function or if needed, it can be a far pointer [0000SEGM:OFFSETOFF]. depend on your opinion.

DS point to the datacode segment, CS then point to current item function code.

Each item can be modified by writing new values in the corresponding header.

Items are all in application_data segment, can be easily accessed from an other segment.

Ressources of the item, txt, bmp etc etc... are in the item datacode segment. can be loaded from a list of ressource, as the function list

Items are located in protected Ring0 data segment.
only kernel can modify it.
Post 21 Nov 2007, 23:45
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.