Thread: assembly help

  1. #16
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Quote Originally Posted by MacNilly View Post
    Yes, but those are C functions, I don't see any return statements. (in the OP post)
    Correct. The assembly part is handling the return. It's not really legal C in that sense, but if you're writing inline assembly, you've lost your portability factor anyway, so the point of writing 100% valid standard C is kind of lost then.

  2. #17
    Registered User
    Join Date
    Mar 2007
    i only want was the logic !!
    and i think, its sufficient to try with.

  3. #18
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Where is the return value being returned in any of these functions?
    You don't return values in assembler. This is a feature of the C language. You can basically return values in any explicit return register in assembler. For instance I could set up the ECX register to hold a value and then call another function.

    Integral return values are returned in EAX and float values are returned in ST(0) in C.

  4. #19
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Cambridge, UK
    Usually, return values in assembler is carried out through stack manipulation. By putting the return value in top of the stack. But this was interesting since the return value is stored in a different register, where that would be refereed to get the value.


  5. #20
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    x86 convention is to pass parameters to a function via the stack, but receive return values in EAX. If you're receiving a 64-bit number on a 32-bit system, I believe the convention is to store the most significant DWORD in EDX and the least significant DWORD in EAX.

    As Bubba said, floating point numbers have their own convention within the x86 convention.

    Technically, you could write your assembly code anyway you want. You don't necessarily have to even call a function, but you could technically just jump all over the place. You could even decide from inside a function that you don't like the return location, and decide on the fly where to return to. Needless to say, that's dangerous.

    Although it's kind of obvious, it's good to stick to conventions so you can be sure your code will play nice with other code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learning Assembly
    By mrafcho001 in forum Tech Board
    Replies: 5
    Last Post: 03-12-2006, 05:00 PM
  2. C to assembly interface
    By Roaring_Tiger in forum C Programming
    Replies: 4
    Last Post: 02-04-2005, 03:51 PM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  5. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 03:35 AM