flat assembler
Message board for the users of flat assembler.
Index
> Main > invoke |
| Author |
|
|
JohnFound 11 May 2011, 10:05
It is because you are using string constant as an argument. Invoke macro defines the string at the current address and then calls x in order to determine what this address is and to pass it to the function invoked.
IMHO - using string constants as an arguments is very bad programming habit. HLLs implements this kind of features in totally different way. |
|||
|
|
ouadji 11 May 2011, 10:17
Quote:
thank you JohnFound for your repy I don't see anything about this inside invoke macro. just ... "reverse pusd arg" Where the code of this "call" comes from ? Quote:
what is the good way to do that ? |
|||
|
|
JohnFound 11 May 2011, 10:42
There should be redefined "pushd" instruction somewhere. Tomasz likes this kind of tricks.
For me, the good way to make it is to define explicitly the constant somewhere and then to use it's address in the call. Code: ; in the code section: invoke SomeFunction, MyString ; in the data section: MyString db 'Something', 0 The only drawback of this approach is that string definition and string use are placed far from each other. That is why I created "globals.inc" library to define the data at proper place. In this case the code will looks like this: Code: ; in the code section: MyString text 'Something' invoke SomeFunction, MyString |
|||
|
|
ouadji 11 May 2011, 11:00
Quote:
thank you for your help PS: it was about "ExAllocatePoolWithTag" this works fine too : Code: invoke ExAllocatePoolWithTag, NonPagedPool, eax, dword "ABCD" ;not "x" but dword "x" |
|||
|
|
ouadji 11 May 2011, 13:10
Code: invoke Z, [Y], 'AAAA' Fasm does compile, result : call x db 41h db 41 h db 41 h db 41 h db 0 ;why this "db 0" x: push dword [Y] call [Z] I'm stupid |
|||
|
|
Mike Gonta 11 May 2011, 21:50
ouadji wrote:
It's part of the pushd macro in the WIN inc files. Code: macro pushd value ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;{ match first=,more, value \{ \local ..continue ;;;; ;;;; call ..continue ;;;; { match first=,more, value \{ \local ..address, ..continue ;;;; push ..address ;;;; jmp ..continue ;;;; ..address: ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; db value,0 ..continue: pushd equ \} match pushd =addr var,pushd value \{ \local ..opcode,..address virtual at 0 label ..address at var mov eax,dword [..address] load ..opcode from 0 end virtual if ..opcode = 0A1h push var else ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; lea edx,[..address] ;;;; ;;;; push edx ;;;; push eax ;;;; lea eax, [..address] ;;;; xchg eax, [esp] ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; end if pushd equ \} match pushd =double [var],pushd value \{ push dword [var+4] push dword [var] pushd equ \} match pushd =double =ptr var,pushd value \{ push dword [var+4] push dword [var] pushd equ \} match pushd =double num,pushd value \{ \local ..high,..low virtual at 0 dq num load ..low dword from 0 load ..high dword from 4 end virtual push ..high push ..low pushd equ \} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; match pushd,pushd \{ \local ..continue ;;;; match pushd,pushd \{ \local ..address, ..continue ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if value eqtype '' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; call ..continue ;;;; push ..address ;;;; jmp ..continue ;;;; ..address: ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; db value,0 ..continue: else push value end if pushd equ \} restore pushd } I've shown two small improvements.
The microarchitecture of Intel, AMD and VIA CPUs By Agner Fog 3.12 Returns (all processors except P1), page 31. 2. I prefer to preserve the register used to push an effective address. Last edited by Mike Gonta on 11 May 2011, 22:39; edited 1 time in total |
|||
|
|
ouadji 11 May 2011, 22:23
thank you Mike Gonta for the clarification! Quote:
Very interesting comment. |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.