flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Combined stdcall and invoke macros to one

Author
Thread Post new topic Reply to topic
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 19 Aug 2005, 10:47
Dear All:
I've come back, now. Wink Last year, I can't access fasm network address because China CNIC blocked this address. I have to use proxy server to access it.

On the Flat assember 1.64 and previous versions, we have to use stdcall and invoke for invoking other sub-routines. Why don't we combine it to alone one? The simplest is the best method. I write some of macros and it worked normally.

Code:
 IMAGE_ORDINAL_FLAG32   =       80000000h
 macro import name,[label,string]
 { common
    name#.lookup:
   forward
    if used label
     if string eqtype ''
      local _label
      dd RVA _label
     else
      dd IMAGE_ORDINAL_FLAG32 + string
     end if
     API.#label = 1
    end if
   common
    if $ > name#.lookup
     name#.redundant = 0
     dd 0
    else
     name#.redundant = 1
    end if
    name#.address:
   forward
    if used label
     if string eqtype ''
      label dd RVA _label
     else
      label dd 80000000h + string
     end if
    end if
   common
    if ~ name#.redundant
     dd 0
    end if
   forward
    if used label & string eqtype ''
    _label dw 0
           db string,0
    end if }

;============================================================================
; It's used for call "stdcall" type procedure.
; If arg is a char, it should be complied the instruction" pushw arg or pushd arg"
; else if arg is a string, it should be complied the instruction "call @f ; db arg,0 ; @@: " 
macro   call    proc,[arg]
{
  common
    get_seg_attr
  reverse
    local .str_param
    if    arg eq
    else  if arg eqtype ""
          call  .str_param
          db    arg,0
         .str_param:
    else
         if attr@seg=..use16
            pushw arg
         else
            pushd arg
         end if     
    end if      
  common
    call proc   
}
           

; It's used for call "standcall" type procedure and API.
macro   stdcall proc,[arg]
{
  common
    if defined API.#proc
        call    [proc],arg
    else
        call    proc,arg
    end if
}    


Do you think it?

Kevin Zheng
August 19th,2005


Description:
Download
Filename: template.asm
Filesize: 6.9 KB
Downloaded: 535 Time(s)

Post 19 Aug 2005, 10:47
View user's profile Send private message MSN Messenger Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 19 Aug 2005, 12:37
Welcome back Kevin_Zheng Very Happy
Post 19 Aug 2005, 12:37
View user's profile Send private message Yahoo Messenger Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 19 Aug 2005, 12:53
Hi and welcome back!

Very nice example of macro usage, but... I wouldn't like to use it because they would hide real nature of the functions. It is matter of preference (of course) but I just prefer to know what kind of routine I'm calling Wink
Post 19 Aug 2005, 12:53
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 19 Aug 2005, 22:36
Glad you could make it back! Lots of exciting things happening in Fasm land. This is an interesting macro, there was more than a few times I wished the two were one. I'll give this a try. thanks for the Macro.
MadMatt
Post 19 Aug 2005, 22:36
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 19 Aug 2005, 22:48
Here's a welcome back for you, this macro gives me an error in the call macro: get_seg_attr - "illegal instruction error"
Post 19 Aug 2005, 22:48
View user's profile Send private message Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 22 Aug 2005, 01:21
Hi, Madmatt:
Please see the attached file proc.inc on package private.zip, you can find the macro "get_seg_attr".

And others, I extended the call,ccall, proc and enp macro defines, it can use on win32, 32 bit linux and dos platform. Please see the demo source code (template.zip and dos_seg.zip). In the future, I think that it should use on win64 and linux64 platforms.

Other friends:
Thank you very much.

Kevin Zheng
August 22th,2005


Description: win32 demo program
Download
Filename: template.zip
Filesize: 6.29 KB
Downloaded: 538 Time(s)

Description: dos demo program with used extended proc and endp macros
Download
Filename: dos_seg.zip
Filesize: 9.77 KB
Downloaded: 524 Time(s)

Description: some of personal define macros. It can use on win32 ,linux and dos platform.
Download
Filename: private.zip
Filesize: 19.29 KB
Downloaded: 517 Time(s)

Post 22 Aug 2005, 01:21
View user's profile Send private message MSN Messenger Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias 22 Aug 2005, 18:18
Hi Kevin, glad to read of your return.
Gosh, WHY is FASM blocked in ZG? I tried so hard, FOR MONTHS, last year, to discover WHY FASM was blocked, and I just met with one denial after another. The most frustrating part was that for my first few days in ZG, I had access to an UNRESTRICTED, UNFILTERED line, so that I COULD receive FASM, even in a backwoods province in the hinterlands, but then, after I criticised Stalin as a mass murderer, the filters were applied, and FASM disappeared. I kept asking various government representatives, wherever I went, including BeiJing, but I never found anyone who could explain why FASM was blocked. The concept of blocking a site is so ALIEN to the philosophy of the internet, I can't imagine what rationale the CCP has for denying Chinese people the opportunity to learn about FASM.
My difficult experience in ZG left me filled with admiration for you and your several colleagues who have NEVERTHELESS succeeded, despite living in such a hostile environment, which still considers Stalin a hero. Europeans, and others on this forum HAVE NO IDEA how difficult it is for Chinese programmers. The problem is not SIMPLY government suppression of FASM, it is also the entire culture, which is DEVOTED to the concept of both restricting personal freedom, and insisting on mediocrity, in every domain, in every component of society. I visited one university's computer science department: All the university students there were busy watching CARTOONS, not programming. These cartoons were appropriate for children, perhaps age 7, or 8. In Russia, such kids are studying assembly language programming. In USA and China, kids, AND adults, are busy watching such mind numbing nonsense--the cartoons were childish and stupid 50 years ago, when first created, in Hollywood. Today they are just silly, and completely inappropriate for university students anywhere.
I asked them (maybe 100 or so undergraduate students, i.e. a SMALL group, by Chinese standards) whether or not any of them ever used assembly language. Answer: no idea. What's that? They really had no interest in my questions, (I had interrupted their close attention to the cartoons), so it wasn't just a problem of FASM being unavailable, and the students being uninformed, it is also a CULTURAL attitude. Of the 30 faculty members I met, in that department, only ONE guy had the slightest notion of programming in Assembly language. Blocking FASM, for those students and faculty at that university, was irrelevant. I guess I would feel the same way if someone asked me incredulously how it was possible to live one's life absent Chinese television. Since I have no interest in Chinese television, if some government blocks my reception of it, then, how is it harming anyone? That explanation, seemed to be the generally accepted opinion, whenever I raised the question of FASM. I mentioned Menuet, again, zero interest. I hope, Kevin, you will be promoted within the CCP soon, so that there will be someone in ZG who understands FASM's potential contribution.
Regards, tom Smile
Post 22 Aug 2005, 18:18
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 22 Aug 2005, 19:06
STALIN IS GREAT
Post 22 Aug 2005, 19:06
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 23 Aug 2005, 01:50
Hi, Tom:
I think that I have to tell you this rule: This is a technology forum. Please don't talk any topics without related technologies in this forum.

There are serval cultures on this world, I think that all of people in this earth is equal, they have right to select their belief.

Thank you.

Kevin Zheng
August,23th,2005
Post 23 Aug 2005, 01:50
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.