MASM proc in NASM

This is a discussion on MASM proc in NASM within the ASM x86 ASM 370 forums in Programming Languages category; I understand that their aren't really procedures, and in NASM "procs" are just labels, but how does one translate this example from MASM to NASM? I know it does nothing. This is sample code MyProc PROC wParam WORD, wParam WORD LOCAL lpTimeBuf[12] :BYTE LOCAL lpLocalTime :SYSTEMTIME ;---------------------------- mov eax, wParam lea esi, [hTimeFormat] lea esi, [lpLocalTime] ret KeyBoardProc ENDP For scope I am trying to give the procedure to a windows function....

Go Back   Application Development Forum > Programming Languages > ASM x86 ASM 370

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-05-2008, 11:31 AM
coyote
Guest
 
Default MASM proc in NASM

I understand that their aren't really procedures, and in NASM "procs"
are just labels, but how does one translate this example from MASM to
NASM?

I know it does nothing. This is sample code

MyProc PROC wParamWORD, wParamWORD
LOCAL lpTimeBuf[12] :BYTE
LOCAL lpLocalTime :SYSTEMTIME
;----------------------------
mov eax, wParam
lea esi, [hTimeFormat]
lea esi, [lpLocalTime]
ret
KeyBoardProc ENDP

For scope I am trying to give the procedure to a windows function.

Reply With Quote
  #2  
Old 09-07-2008, 08:32 PM
Rod Pemberton
Guest
 
Default Re: MASM proc in NASM


"coyote" <spamtrap@crayne.org> wrote in message
news:af0cf968-708b-4bea-a2a0-bfb9366220ac@y21g2000hsf.googlegroups.com...
> I understand that their aren't really procedures, and in NASM "procs"
> are just labels, but how does one translate this example from MASM to
> NASM?
>
> I know it does nothing. This is sample code
>
> MyProc PROC wParamWORD, wParamWORD
> LOCAL lpTimeBuf[12] :BYTE
> LOCAL lpLocalTime :SYSTEMTIME
> ;----------------------------
> mov eax, wParam
> lea esi, [hTimeFormat]
> lea esi, [lpLocalTime]
> ret
> KeyBoardProc ENDP
>
> For scope I am trying to give the procedure to a windows function.
>


Not real sure, but I'll give it a try. I chose to use some macro's by
Mammon for the PROC and ENDP. They seemed to use a feature no longer
available in NASM. I posted a fix below. The changes mean that the local
variables have to be added to 'ebp' instead of being done automatically.

; for PROC and ENDP
%include "mammon.inc"

; define a NASM template for SYSTEMTIME to get it's size
struc SYSTEMTIME
wYear: resw 1
wMonth: resw 1
wDayOfWeek: resw 1
wDay: resw 1
wHour: resw 1
wMinute: resw 1
wSecond: resw 1
wMilliseconds: resw 1
endstruc

PROC MyProc, nCode, wParam

; __ll is used by Mammon's macros to allocate space
%assign __ll __ll+12 ; 12 is size of lpTimeBuf
LOCALVAR lpTimeBuf ; declare variable

%assign __ll __ll+SYSTEMTIME_size ; is size of struct
LOCALVAR lpLocalTime

;----------------------------
mov eax, [ebp+nCode]
mov eax, [ebp+wParam]
lea esi, [hTimeFormat]
lea esi, [ebp+lpTimeBuf]
lea esi, [ebp+lpLocalTime]
ret
ENDP

hTimeFormat: db "hh:mm:ss tt", 0


You'll need Mammon's macros for the PROC and ENDP which are here:
http://groups.google.com/group/alt.l...e573ddfd882156


Although his macro's were for NASM, I had a problem with two
equates which needed changing:

--- mammon.old 2008-09-07 20:16:42.000000000 +0000
+++ mammon.inc 2008-09-07 20:16:18.000000000 +0000
@@ -267,7 +267,7 @@
%1:
%assign _i 4
%rep %0-1
- %2 equ [ebp-_i]
+ %2 equ -_i
%assign _i _i+4
%rotate 1
%endrep
@@ -293,7 +293,7 @@

%macro LOCALVAR 1
sub esp, 4
- %1 equ [ebp + __ll]
+ %1 equ __ll
%endmacro

Disclaimer: I'm not completely sure if any of that will do what you want...
;-)

HTH,


Rod Pemberton

Reply With Quote
  #3  
Old 09-10-2008, 04:01 PM
coyote
Guest
 
Default Re: MASM proc in NASM



I will try this, thank you very much.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:45 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.