Hi my fellow Assembly coders!! :D
I have quite a bit of problem here. (Wanna talk about problems? That PASS32 compiler has some serious bugs in it, it compiles JZ as a JMP ins and messes up all my DOS progs :( ).
Anywho I have some code from a IT music module player I am programming. Here it is:

LoadModule proc DWORD : szSongFile uses eax ebx ecx edx esi edi PUBLIC
mov eax,sndmemlck
.if eax!=0
mov ebx,sndmemhd
invoke HeapUnlock, ebx
.endif
mov eax,sndmemsz
mov ebx,sndmemcur
sub eax,ebx
.if eax==0
mov eax,FALSE
ret
.endif
mov ebx,szSongFile
invoke filesize, ebx
.if eax==-1
mov eax,FALSE
ret
.else
mov ebx,sndmemcur
mov ecx,sndmemsz
sub ecx,ebx
.if ecx>eax
mov eax,FALSE
ret
.endif
mov ebx,szSongFile
mov secatrrib.nxmLength, sizeof SECURITY_ATTRIBUTES
mov secattrib.lpSecurityDescriptor, NULL
mov secattrib.bInheritHandle,TRUE
invoke CreateFile, ebx, GENERIC_READ, FILE_SHARE_READ, ADDR secattrib, OPEN_EXISTING or FILE_FLAG_RANDOM_ACCESS, FILE_ATTRIBUTE_NORMAL, NULL
.if eax==INVALID_HANDLE_VALUE
mov eax,FALSE
ret
.else
mov ecx,OFFSET shnd
mov ebx,shndcur
add ecx,ebx
mov ,eax
mov ebx,OFFSET tempdd
mov ,eax
.endif
mov eax,sndmemlck
.if eax=1
mov eax,0
mov sndmemlck,eax
mov ebx,sndmemhd
invoke HeapUnlock, ebx
mov eax,szSongFile
invoke filesize, eax
mov ebx,sndmemcur
mov ecx,sndmemptr
add ebx,ecx
mov edx,OFFSET shnd
mov ecx,shndcur
add edx,ecx ;Now EBX has the availabe OFFSET and EDX has the Address of the File Handle
mov ebx,MODULE.Pointer
mov ecx,
invoke ReadFile, ecx, ebx, eax, ADDR tempdd, NULL
.if eax==0
mov eax,FALSE
ret
.endif
Anywho look at the top where I defined a Process. As you can see I have my process name and the word "PROC" but MASM when I ask to compile it keeps bit....er....complaining about "Unmatched Nested Block" or sumtin' like that. I was wondering what is the PROPER way to define a Function/Process?
Thank you all for your time, I greatly appreciate it! Finally some Assembly programmers I can look up to :), whenever I go outside to the C/C++ world I always get shunned =(
Posted on 2002-06-19 21:56:25 by x86asm
For every: LoadModule proc

There must be a: LoadModule endp

And this is the correct syntax:

LoadModule proc PUBLIC USES eax ebx ecx edx esi edi,szSongFile:DWORD

Posted on 2002-06-19 22:01:16 by bitRAKE

For every: LoadModule proc

There must be a: LoadModule endp

Posted on 2002-06-19 22:02:22 by x86asm
Here is an example:
D3DXVec2BaryCentric PROC PUBLIC USES ecx edx, pOut:PTR D3DXVECTOR2, \

pV1:PTR D3DXVECTOR2, pV2:PTR D3DXVECTOR2, pV3:PTR D3DXVECTOR2, f:REAL4, g:REAL4

mov eax, pV3
mov ecx, pV2
mov edx, pV1
movd mm6, DWORD PTR f
movq mm1, QWORD PTR [eax]
movq mm2, QWORD PTR [ecx]
movq mm0, QWORD PTR [edx]
punpckldq mm6, mm6 ; f:f
movd mm7, DWORD PTR g
pfsub mm1, mm0 ; V3-V1
punpckldq mm7, mm7 ; g:g
pfmul mm1, mm6 ; f(V3-V1)
pfsub mm2, mm0 ; V2-V1
pfadd mm0, mm1 ; V1 + f(V3-V1)
pfmul mm2, mm7 ; g(V2-V1)
mov eax, pOut
pfadd mm0, mm2 ; V1 + g(V2-V1) + f(V3-V1)
movq QWORD PTR [eax], mm0
femms
ret
D3DXVec2BaryCentric ENDP ; eax = pOut
Posted on 2002-06-19 22:08:11 by bitRAKE
Yep,

Standard stuff in MASM is a PROTOTYPE and a PROCEDURE.


FuncName PROTO :DWORD,:DWORD etc ...

In the code,

FuncName proc var1:DWORD,var2:DWORD etc ...

; your code

ret

FuncName endp


In the prototype you can specify both the calling convention, STDCALL or C, and in the PROCEDURE you can specify the registers that must be preserved.

Regards,

hutch@movsd.com
Posted on 2002-06-19 22:29:04 by hutch--
You can also define calling convention in the proc statement, but
imo the best place is in the proto... but if you're not using protos for
some of your procs, it's nice being able to put the calling convention
specifier in the proc statement.
Posted on 2002-06-20 09:20:03 by f0dder