News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Proc using VARARG and multidimensionnal arrays

Started by TouEnMasm, August 08, 2021, 04:05:58 PM

Previous topic - Next topic

TouEnMasm

Hello,
Proc using VARARG and Multidimensionnal arrays are two subjects missing in this forum with masm.
Here the soluce in 32 and 64 bits for arrays of 2,3,4 dimensions.
The use of those arrays allow to use index instead of adress and simplify greatly many complex problems.
The more simple is the 32 bits.
The size of the parameters is in the intruction just after the call and it is not too much difficult
to retrieve the number of args.
In 64 bits,it seems that this information is lost.The proc must know how many paramaters he need.
Here,it is a pointer on data who give this information.


I have tested it with uasm,jwasm and asmc64.
Take care that uasm dont find the fifty element at the same place    (64 bits sample debut.asm)
This obliges to modify the code for your own compiler

.If NBdim == 4
mov rdx,0
mov ecx,[rbx+12]
.if ecx == 0
jmp NullDim
.endif
;mov eax,[rbp+50h]                     ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< uasm
mov         eax,dword ptr [rbp+30h]    ;<<<<<<<<<<<<<<<< jwasm ,asmc64
mul ecx
add cumul,eax
.endif


The c optimize this giving only the result for the various calcul needed to solve the adress.


Fa is a musical note to play with CL