flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > The forever problem with procedures |
Author |
|
Gambino 30 Aug 2004, 07:34
Code: ;this doesn't works proc test,word,dword begin endp i can't pass a word and a dword as parameters... anyone has macros that solve this problem ??? |
|||
30 Aug 2004, 07:34 |
|
Gambino 30 Aug 2004, 15:46
I knew that i can pass the word as a dword and only use the 16 bit value from it but i wanted to pass 16bit and 32bit values...
Quote: better pass it as dword and you can use only a part of it later in the procedure That is not a solution... I need that the macro really does what i say |
|||
30 Aug 2004, 15:46 |
|
vid 30 Aug 2004, 18:51
and do you realize what can it result in if you would be using such macro?
|
|||
30 Aug 2004, 18:51 |
|
Gambino 31 Aug 2004, 04:33
Quote: and do you realize what can it result in if you would be using such macro? No i don't ! Will i break the proccessor in half if i run such a macro or what ? I see that nobody has a solution for this... |
|||
31 Aug 2004, 04:33 |
|
pelaillo 31 Aug 2004, 12:57
Gambino, no solution is needed for this.
The idea behind dword aligned is the performance: If you have to work with a single word, your processor is not going to break in half, but the performance do in more than half A 32 bit processor spend the same clocks for an operation in full register than in a part of it in the best case. Code: mov eax,[.arg] mov ax,[.arg] mov al,[.arg] The problems start when cache goes flushed when otherwise not needed, branch prediction cannot be performed because instructions need to be aligned for execution, usually you need to do tricky code to pack/unpack info and so on. On the other hand, what would be the advantage? Designed performance requires to work in multiple of 32 bits when processor is 32 bits. |
|||
31 Aug 2004, 12:57 |
|
vid 31 Aug 2004, 18:26
that's what i meant. Code will be slowed down greatly, even bugs may happen because of this under windoze, and no reason.
But it is possible to make macros that will in reality allocate 32bits, but set size of label to another size so only parto of 32bits will be used. would this be a solution? |
|||
31 Aug 2004, 18:26 |
|
Gambino 31 Aug 2004, 21:43
This is going really off-topic....
I just wanted to know if someone has or can make some proc macros that pass word and dword... Nothing more. I understand every risc implied... and i don't program for windoze... I am programing an OS and i really need those macros... Because Fasm dont has procedures built-in...like TASM I cant write procedures like i'm used to. |
|||
31 Aug 2004, 21:43 |
|
Foamplast 31 Aug 2004, 22:03
Gambino:
Please tell me, what is the purpose of passing a word value to the proc? It's very interesting. |
|||
31 Aug 2004, 22:03 |
|
Foamplast 31 Aug 2004, 22:06
Gambino:
Suppose you are writing an OS for AMD64. Do you need the macro that passes a word using stack? |
|||
31 Aug 2004, 22:06 |
|
JohnFound 31 Aug 2004, 23:35
Gambino wrote: I just wanted to know if someone has or can make some proc macros that pass word and dword... OK, how you think will look the declaration syntax of such procedures and calls? Btw, I had some plans to implement very universal macroses in Fresh library, but I decided not to make this, because every atempt to create universal StdCall library leads to unwanted decreasing of readability and compilation speed. My suggestion is, if you need mixed code 16+32bit (note that in every reasonable application I can imagine - most probably OS loader) this code will be very very short, so you simply can write procedure in pure assembler without using "proc" macro. (you can replace "pushd" in "stdcall" macro with "push" in order to pass word arguments on calling) Here: http://board.flatassembler.net/topic.php?t=1995 you can read more wide discussion about different syntaxes of StdCall macroses. Regards. |
|||
31 Aug 2004, 23:35 |
|
Gambino 01 Sep 2004, 04:56
Procedure definition structure:
proc ProcedureName .arg1 db ? .arg2 dw ? .arg3 dd ? locals .cloc1 dd ? .cloc2 dw ? endl begin locals .loc1 dd ? .loc2 dw ? endl locals .loc3 db ? .loc4 db ? endl endp This should be everything i ever wanted from the procedure macro.... |
|||
01 Sep 2004, 04:56 |
|
JohnFound 01 Sep 2004, 06:31
Gambino wrote: This should be everything i ever wanted from the procedure macro.... Imagine the tons of "dd ?" you have to type for every windows program. Also, the readability will be worse. Also, how you will call such procedures if someone type ".rect RECT" as an argument? Anyway, if you are stubborn enough, refusing suggestions, you can use Fresh StdCallEx.inc as a base to write this variant. The arguments will use the approach now used for main local block (of course with different base (not "ebp-something", but "ebp+something") Regards. |
|||
01 Sep 2004, 06:31 |
|
vid 01 Sep 2004, 20:25
gambino: yes, such macro can be writen, for example in this way
Code: proc some_proc,<arg1,dword>,<arg2,word> but i think nobody will ever write them because they are really useless. If you learn FASM's macrolanguage well enough maybe you 'll write such macros. |
|||
01 Sep 2004, 20:25 |
|
Gambino 02 Sep 2004, 00:19
JohnFound
Please understand that i will not use this macros to write windows programs.... It will be used for OS programming. And i am not stubborn, i am open to sugestions. The only objection that i had is that i dont want to pass words like dwords and use only a word from that dword ( i think that creates confusion ). |
|||
02 Sep 2004, 00:19 |
|
Dragontamer 02 Sep 2004, 01:43
By pretending words are dwords you gain advantages of speed and easiness. What more do you want?
Anyway, i guess it is possible if we play around with virtual so that you indead pass a dword, when you want a word, but it gets treated as a normal word |
|||
02 Sep 2004, 01:43 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.