flat assembler
Message board for the users of flat assembler.

Index > Main > Tomasz please show tutorial add new command to tables.inc

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 02 May 2023, 17:48
Fasmw 1.73
Tomasz interesting see tutorial\video, how add new command to tables.inc
And how to process it later and where is in fasm sources code.
Code:
preprocessor_directives:
 db 6,'define'
 dw define_symbolic_constant-directive_handler
 db 7,'include'
 dw include_file-directive_handler
 db 3,'irp'
 dw irp_directive-directive_handler
 db 4,'irps'
 dw irps_directive-directive_handler
 db 4,'irpv'
 dw irpv_directive-directive_handler
 db 5,'macro'
 dw define_macro-directive_handler
 db 5,'match'
 dw match_directive-directive_handler
 db 8,'postpone'
 dw postpone_directive-directive_handler
 db 5,'purge'
 dw purge_macro-directive_handler
 db 4,'rept'
 dw rept_directive-directive_handler
 db 7,'restore'
 dw restore_equ_constant-directive_handler
 db 7,'restruc'
 dw purge_struc-directive_handler
 db 5,'struc'
 dw define_struc-directive_handler
 db 0    
    


db 6 =size name,'define'
dw define_symbolic_constant-directive_handler ; Why this ?

Did first parsed 'define', last 'struc' ? Like as privilege level.


Last edited by Roman on 02 May 2023, 19:33; edited 6 times in total
Post 02 May 2023, 17:48
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 02 May 2023, 17:55
Very interesting see, how in preprocessing apply usr_dll proc call after load.
Code:
virtual at 0
tt:: txt db '12.0'
end virtual
load a dword from tt:txt
usr_dll 'cos',a       ;this must run user proc, and set a=cos(12)
mov eax,a             ;now eax =0.978147

;or sand address tt:: txt to usr_dll proc
virtual at 0
tt:: txt2 dd 10,20,30,2,4,5
     txt3 dd 0,0,0,0 ;output result cross product
end virtual
usr_dll 'cross_product_Vec3',tt:txt2,tt:txt3
    


We could do fasm preprocessing more powerful.


Last edited by Roman on 03 May 2023, 12:26; edited 1 time in total
Post 02 May 2023, 17:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 02 May 2023, 18:30
I think if you want to make a suggestion then breaking it down to the lowest possible complexity would be best.

For example, there is no need to complicate the above code with unnecessary virtual blocks. You could just show this:
Code:
usr_dll 'cos', result, 1.2345    
That would be the most general form of what you are asking without all the additional virtual baggage obscuring the basic premise.

You could also try writing the code yourself and posting the result for others to use if they wish. Maybe one day it could find its way into fasm if it is popular enough.
Post 02 May 2023, 18:30
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 02 May 2023, 19:07
Quote:

usr_dll 'cos', result, 1.2345

This is simple example.
I want generated terrain vertex mesh data, or calculating on fly, 12 matrices4x4 in preprocessing.
Or changed array positionXYZ objects for 3d level.

Or usr_dll proc split text from file to parts
and put to fasm data textCharTom,textCharNick,textCharChief

This reason I needed out calculated data to fasm data.
Than fasm work as usual with virtual or dd data.

Or usr_dll proc work like as macro(more simple or complicated) and calculating some specific tasks.
Usr_dll proc could changed equ\define\data. And change the macro name for some situation.
Code:
usr_dll 'cos', result, 1.2345 
some fasm code
macro a1 { mov eax,result }
macroset equ 0
usr_dll 'if_equal', result, 1.2345 ,macroset,a1 ;to macroset return 0 or macro a1
if macroset >0
 macroset   ;in hear usr_dll 'if_equal' put fasm macro a1
end if
    
Post 02 May 2023, 19:07
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 795
Location: Russian Federation, Sochi
ProMiNick 02 May 2023, 20:27
for any task thou should chose best instrument.
purpose of preprocessor is to make translation of one texts to another and making simple calculations.
if thou expect floating point calculations as some kind of preprocessor wrapping over external to compiler OS interfaces (API or syscalls), so why not use completely external tool for such calculation and to leave for preprocessor tasks it was designed for?
Post 02 May 2023, 20:27
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 02 May 2023, 20:42
Because fasm preprocessor not universal, and exist many direction whear is need some special and not ordinary solution.
For simple example fasm not have vector cross,dot product, sqrt, matrices multiplication, and many etc.

ProMiNick
If fasm preprocessor so good, why Tomasz writing calm and fasmg ?!

Some times Tomasz writes new supper-fasmg version, because fasmg not ready for new modern tasks. For example quantum or neural networks.

This more flexible's and simple way add new feature in fasm.
User_dll 'calm', param1,...,param12

Another moment, Tomasz not physically can write many solutions.
Usr_dll gives parallel development for many people for many directions,on different programming languages.


Last edited by Roman on 02 May 2023, 21:44; edited 4 times in total
Post 02 May 2023, 20:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 02 May 2023, 20:50
I looks to me like you want to transform the preprocessor into a fully fledged HLL compiler.

At what point does one realise that they stopped writing assembly and transitioned into writing HLL?
Post 02 May 2023, 20:50
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 02 May 2023, 20:55
Quote:

I looks to me like you want to transform the preprocessor into a fully fledged HLL compiler.

Some task yes, some not.
If you want, you write as usual fasm code, or using many user_dlls and thousands procs and ready solution, for different tasks.
For example parse complex math expression (as science math for molecules) to fasm data or code algorithm.
Parse php to own format.
Or video\audio decoding,encoding for neural algorithms.

Good example. Writing hands thousands data values and enums(as usual do in fasm), or using
usr_dll 'get_Tabdata_sin',0,360,0.2 ;and get to fasm auto generated sin tab for all 360 degrees , with step 0.2 !
Second profit we not see this big data ! Only fasm preprocessing see and work with this big data !
Something like as do in fasm rept:
Code:
rept 360*10 n:0 { sin(n) }  ;small code, but generated big data
;but rept not powerful as could be usr_dll 'many_procs' !
;and do more cool and complex datas generations tricks.
rept 360*500 n:0 { sqrt(dot(sin(n)+cos(n/2),n))*0.85*vec3(n*0.1,n/6,n*0.05) }
;Or hands writing couples weeks very big data as usual.
    
Post 02 May 2023, 20:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 03 May 2023, 11:28
Your proposal is very Windows centric. fasm has many other targets that it can be used on. How would you suggest to make it more universal for other use cases? For example, how could a Linux user, or someone using the libc version, make use of user_dll?
Post 03 May 2023, 11:28
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 03 May 2023, 12:05
For arm or Linux use different user_dll libs.
We not using windows dll on Linux or on ARM.

Now we using fasm for arm and fasm for windows.
And no problems.

Fasm task only load usr_dll and call name proc. That's all.

On arm library load one way and call procs.
On window another way load library and call procs.
This path is determined by the version fasm(arm or windows or linux)
Post 03 May 2023, 12:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 03 May 2023, 12:34
Roman wrote:
For ... Linux use different user_dll libs.
So you propose to have different source code for people using different OS hosts?
Code:
;*** only use this source for Windows host ***
;...
user_dll 'super_matrix_converter', my_matrix, cols, rows, ...
;...    
Code:
;*** only use this source for Linux host ***
;...
user_so 'super_matrix_converter', my_matrix, cols, rows, ...
;...    
Code:
;*** only use this source for libc host ***
;...
user_??? 'super_matrix_converter', my_matrix, cols, rows, ...
;...    
Now you need lots of different sources for user_dll, user_so, whatever works for libc, etc. Sounds awful to maintain. Sad

Note that this doesn't involve ARM, it affects fasm and the OS host, not the CPU you are programming for.
Post 03 May 2023, 12:34
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 03 May 2023, 15:04
How fasm arm load dll for arm ?

Code:
;off user_dll and all user_dll fasm preprocessor ignored !
user_modeOff 
;windows
user_dll 'super_matrix_converter', my_matrix, cols, rows, ...

;Linux
user_dll 'super_matrix_converter', my_matrix, cols, rows, ...

;arm
user_dll 'super_matrix_converter', my_matrix, cols, rows, ...
    

How work user_dll is determined by the version fasm !
User_dll must be as part fasm, like as macro,match,irp etc.

If you don't like user_dll, named user_preprocessor_function.
Post 03 May 2023, 15:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 03 May 2023, 15:14
It isn't the name that matters. It is the implementation. You need to maintain many different versions of "user_dll" for each OS and each CPU mode. If someone is trying to compile your code on a 32-bit Linux system but only have a 64-bit Windows version of user_dll then how?

BTW, ARM is not an OS. ARM can run both Windows and Linux, same as x86.
Post 03 May 2023, 15:14
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 03 May 2023, 15:17
This work in fasm without problems, with user_dll i not see difference.
Code:
;code
user_dll Matrix, my_matrix, cols, rows, ...

SECTION '.idata' IMPORT DATA READABLE WRITEABLE ;executable

     library  kernel32, 'KERNEL32.DLL'

;roughly something like this
SECTION '.usrdll' IMPORT DATA 
     library  usrmath,'usermath.dll'

import usrmath,\
        Matrix,'super_matrix_converter'
    
Post 03 May 2023, 15:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 04 May 2023, 02:11
I may have misunderstood what you want. I thought you wanted Tomasz to write your stuff for you. But if all you want is to make your own custom version of fasm then you don't need to modify the preprocessor, you could introduce your own operators.
Code:
mov eax, cos 1.618
load x dword from y
store cos x + sqrt 3.141 at z
dd 1.234 * tanh 0.5    
Post 04 May 2023, 02:11
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 04 May 2023, 05:16
Wath is mean?
Quote:
mov eax, cos 1.618
load x dword from y
store cos x + sqrt 3.141 at z
dd 1.234 * tanh 0.5


Did this worked in Fasmw 1.73?
Or thi is new feature, for New version fasm?

I try in fasmw 1.73 compile error
Code:
 mov eax, cos 1.618     
Post 04 May 2023, 05:16
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 04 May 2023, 06:06
Quote:

you could introduce your own operators.

How do this ? I don't know how do this.
Post 04 May 2023, 06:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 04 May 2023, 15:12
You can add operators to tables.inc and update the expression parser/evaluator:
Code:
single_operand_operators:
 db 1,'+',82h
 db 1,'-',83h
 db 3,'bsf',0E0h
 db 3,'bsr',0E1h
 ; add COS here
 db 3,'not',0D0h
 db 3,'plt',0F1h
 db 3,'rva',0F0h
 ; add SIN/SQRT here
 db 0    
Post 04 May 2023, 15:12
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 04 May 2023, 16:14
Code:
single_operand_operators:
 db 1,'+',82h
 db 1,'-',83h
 db 3,'bsf',0E0h
 db 3,'bsr',0E1h
 ; add COS here
 db 3,'not',0D0h
 db 3,'plt',0F1h
 db 3,'rva',0F0h
 ; add SIN/SQRT here
 db 0       


Its just names. But how fasm do calculation cos or sqrt ? In PREPROCE.INC i must writing my code ?
And db 3,'bsr',0E1h
Wath number i must writing for cos or sqrt ? Like as 0E1h number for bsr


Last edited by Roman on 04 May 2023, 16:35; edited 1 time in total
Post 04 May 2023, 16:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20214
Location: In your JS exploiting you and your system
revolution 04 May 2023, 16:31
First number is the name length, second is the name, third is the priority. Example:
Code:
db 3,'cos',0xd1
db 4,'sqrt',0xd2    
As mentioned above update the expression parser/evaluator. This isn't the preprocessor, it is the assembler.
Post 04 May 2023, 16:31
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:  
Goto page 1, 2  Next

< 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.