Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OUT parameters in inline asm

OUT parameters in inline asm

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    csrss
    wrote on last edited by
    #1

    Hey guys. Lets say, i have such function, like:

    void Stuff(int A, int *B);

    So as you can see, B is OUT parameter. The question is, how would you call it from inline assembly code? Something like this:

    void Some(int A){ //do something with a }
    __asm
    {
    push 1
    call dword ptr Some
    }

    // or this

    int Some(int A, int B){ // do something with variables and return some integer }
    __asm
    {
    push 2
    push 5
    call dword ptr Some
    // now the function result is in eax, so we can grab it and store in some variable, and do something with it later
    }

    but how to do it with this: void Stuff(int A, int *B) ? How to get B? Thanks

    011011010110000101100011011010000110100101101110 0110010101110011

    C 1 Reply Last reply
    0
    • C csrss

      Hey guys. Lets say, i have such function, like:

      void Stuff(int A, int *B);

      So as you can see, B is OUT parameter. The question is, how would you call it from inline assembly code? Something like this:

      void Some(int A){ //do something with a }
      __asm
      {
      push 1
      call dword ptr Some
      }

      // or this

      int Some(int A, int B){ // do something with variables and return some integer }
      __asm
      {
      push 2
      push 5
      call dword ptr Some
      // now the function result is in eax, so we can grab it and store in some variable, and do something with it later
      }

      but how to do it with this: void Stuff(int A, int *B) ? How to get B? Thanks

      011011010110000101100011011010000110100101101110 0110010101110011

      C Offline
      C Offline
      csrss
      wrote on last edited by
      #2

      Ok, solved it myself.

      #include <windows.h>
      #include <iostream>

      using namespace std;

      void Func(int A, int *B, int *C)
      {
      *B += ++A;
      *C *= *B + 1;
      }

      int main()
      {
      int B = 3;
      int C = 6;
      __asm
      {
      lea ecx, C
      push ecx
      xor ecx, ecx
      lea ecx, B
      push ecx
      push 3
      call dword ptr Func
      add esp, 12
      }
      cout << B << " : " << C << endl;
      }

      011011010110000101100011011010000110100101101110 0110010101110011

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups