flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > new method init value.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1892
Roman 22 Jul 2020, 11:55
Code:
Sz_Adr = 4      ;for 32 bit and 8 for 64 bits
TypeDB = 0
TypeDW = 1
TypeDD = 2
TypeDQ = 3
TypeV2 = 4   ;vector2 as float2
TypeV3 = 5   ;vector3 as float3
TypeV4 = 6   ;vector4 as float4
TypeFlt = 7
TypeMatrix4 = 10   ;mat4x4 as float4x4
TypeMatrix3 = 11   ;mat3x3
TypeMatrix2 = 12   ;mat2x2
    


Last edited by Roman on 22 Jul 2020, 14:01; edited 1 time in total
Post 22 Jul 2020, 11:55
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1892
Roman 22 Jul 2020, 11:56
Code:
macro Var chN,chSz,chTp {
       chN EQU Vars_offs
       chN#_tp EQU chTp
       Vars_offs EQU Vars_offs+chSz
       }
macro CopyVar chF,chT {
       if chF#_tp = TypeFlt & chT#_tp = TypeFlt
       movss xmm0,dword [chF]
       movss dword [chT],xmm0
       end if
       if chF#_tp = TypeFlt & chT#_tp = TypeDD
       cvtss2si eax,dword [chF]
       mov dword [chT],eax
       end if
       if chF#_tp = TypeDD & chT#_tp = TypeFlt
       cvtsi2ss xmm0,dword [chF]
       movss dword [chT],xmm0
       end if
       if chF#_tp = TypeDB
       mov al,[chF]
       mov [chT],al
       end if
       if chF#_tp = TypeDW
       mov ax,word [chF]
       mov word [chT],ax
       end if
       if chF#_tp = TypeDD
       mov eax,dword [chF]
       mov dword [chT],eax
       end if
       if chF#_tp = TypeDQ
       movsd xmm0,qword [chF]
       movsd qword [chT],xmm0
       end if
       if chF#_tp = TypeMatrix4
       LDDQU xmm0,dqword [chF]
       LDDQU xmm1,dqword [chF+16]
       movups dqword [chT],xmm0
       movups dqword [chT+16],xmm1
       LDDQU xmm0,dqword [chF+32]
       LDDQU xmm1,dqword [chF+48]
       movups dqword [chT+32],xmm0
       movups dqword [chT+48],xmm1
       end if
       }
 macro SetVar chV,chOf,chNum {
       if chV#_tp = TypeDB
       mov byte [chV+chOf],chNum
       end if
       if chV#_tp = TypeDW
       mov word [chV+chOf],chNum
       end if
       if chV#_tp = TypeDD
       mov dword [chV+chOf],chNum
       end if
       if chV#_tp = TypeDQ
       mov qword [chV+chOf],chNum
       end if
       if chV#_tp = TypeMatrix4
       mov dword [chV+chOf],chNum
       end if
       }
    


Last edited by Roman on 22 Jul 2020, 14:01; edited 1 time in total
Post 22 Jul 2020, 11:56
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1892
Roman 22 Jul 2020, 11:58
In code write:
Code:
Vars_offs EQU Vars_Tabl

      Var hndl,Sz_Adr*1,TypeDD
      Var hndl2,Sz_Adr*4,TypeDD

    rept 3 n:1 {
      Var mat#n,64,TypeMatrix4
      }
 
      SetVar mat3,0,10.0
      SetVar hndl,0,8    
      CopyVar mat1,mat3
      CopyVar hndl,hndl2

      Var a1,4,TypeFlt
      Var a2,4,TypeFlt

      CopyVar a1,hndl
      CopyVar a1,a2
      CopyVar hndl,a1
    


section '.bss' readable writeable
Vars_Tabl rb 1000


Last edited by Roman on 22 Jul 2020, 14:03; edited 1 time in total
Post 22 Jul 2020, 11:58
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1892
Roman 22 Jul 2020, 11:59
No need write in data section many names.
Only cuple:

Vars_Tabl rb 1000
VarsInterfaces_Tabl rb 1000


Last edited by Roman on 22 Jul 2020, 12:20; edited 1 time in total
Post 22 Jul 2020, 11:59
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1892
Roman 22 Jul 2020, 12:20
You can include file.
And in include file we can write:
Code:
Var a1,Sz_Adr*1,TypeDD
      Var a2,Sz_Adr*4,TypeDD
    

And no need comment in data section a1 and a2
Post 22 Jul 2020, 12:20
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.