flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > overloaded instructions anyone? |
Author |
|
revolution 16 Apr 2009, 09:21
Your code works for me:
Code: macro push [regs] { if ~ regs eq forward define ..done 0 match =all , regs \{ pushad define ..done 1 \} match =flags , regs \{ pushfd define ..done 1 \} match =0 , ..done \{ push regs ; was pushd regs \} common end if } push ds Quote: flat assembler version 1.67.38 (100000 kilobytes memory) |
|||
16 Apr 2009, 09:21 |
|
Mercury Knight 16 Apr 2009, 12:55
I feel so stupid! DS was indeed redefined, I forgot about it.
Code: struc ds [data] { common db data,0 alignb 4 } ; you use it like... StrMess1 ds "This is the first string" StrMess2 ds "This is the second string" Its a simple macro which stands for "define string". You use this instead of db or du, and it automatically appends a null terminator at the end of the string so you dont have to. Any strings (or other data) defined afterwards is automatically aligned on the next 4 byte alignment. I use this in my windows macros, this particular macro is for the ASCII version of Windows, the Unicode version uses "du data,0". This allows me to define a string one time, and if I needed to change from Unicode to ASCII or vice versa, I simply define WINASCII to use the ASCII version and reassemble the code. Much easier than searching throughout the source code for all of the strings and changing db to du or vice versa. Unless I find a way to keep this, I'm going to have to go through the code I've written so far and change all of the macro ds to something else so that it does not conflict with the segment register ds. I never thought to look at it until you asked, because my code was pushing ds first, then es, fs, and gs. Any ideas what I should rename the macro ds as? Or hopefully you have any tricks up your sleeve that will let me keep ds as a macro and still use it as a segment register as well? Thanks for pointing me in the right direction. MK |
|||
16 Apr 2009, 12:55 |
|
revolution 16 Apr 2009, 13:36
You can make one or both characters capital letters: Ds, dS or DS.
|
|||
16 Apr 2009, 13:36 |
|
revolution 16 Apr 2009, 13:39
Actually since it is for Windows then why do you need to bother with pushing/popping DS? Or any of the segment registers? Windows uses flat addressing so all segments can access the entire 4G memory.
|
|||
16 Apr 2009, 13:39 |
|
Mercury Knight 16 Apr 2009, 14:41
Sorry, I forgot to tell you: This isn't for Windows, although the macro itself was originally written for Windows programming. I, like who knows how many others, am writing an operating system (32 bits even tho I have an Athlon XP 64-X2), and I also write DOS programs as well, although I haven't in the past couple of years (busy with school and a certain large Windows program...). I have an alpha-level kernel written in nasm, and I have been porting it over to fasm since nasm's updates shattered most of my macros to tiny little pieces. It was the IRQ handlers that brought ds to my attention...
I was programming for Windows when I was first learning how fasm's preprocessor works. The macros in the sysmacros.mac file was moved from Windows and is designed to be platform-independent, so that the same set of macros can work whether programming for Windows or another OS. Thus I forgot that my ds macro was also the name of the segment register, because like you said, we use flat addressing in Windows... |
|||
16 Apr 2009, 14:41 |
|
revolution 16 Apr 2009, 14:57
BTW: Windows uses the TCHAR name to define strings. The standard fasm macros also use this name and will morph their behaviour to byte or word depending upon the included file (win32ax or win32wx).
|
|||
16 Apr 2009, 14:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.