NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: nobody on March 24, 2008, 12:58:26 AM

Title: Type checking
Post by: nobody on March 24, 2008, 12:58:26 AM
I'm trying to write some generic functions, that can handle different data types and act on them appropriatly. This introduces type and parameter checking, which NASM does not do natively.

Proc myproc, p2String
code
endproc

how can myproc be written so that it would know that the passed parameter is of the correct type and size eg: dword value, pointer to byte, pointer to struc or array
if p2String would erroneously point to memory containing 41,42,43,0 this would be interpreted as a pointer to the zero terminated string "ABC",0 and would be valid for input but would be the incorrect string.
Furthermore, if I declare a string char db"{~}",0 this would be an invalid string, falls outside of character range.

What options and solutions are there for type checking?

Second question:

how can I differentiate between defined local and defined extern?
I'm using Nasm 2.0 and golink with no definition files, since go link finds imported functions on its own.

my proc macro defines procs as Global %1,  %1:

macro call 1
ifidn %1 _extern
   stdcall %1   ;stdcall macro defines API functions as extern
elifidn %1 _local
   call %1
endif

Parameters ar pushed with macro


call MessageBoxA

call myproc

this results in myproc being called as stdcall

Your help is allways appreciated as allways
Klod