· Начало · Отвђтить · Статистика · Поиск · FAQ · Правила · Установки · Язык · Выход · WASM.RU · Noir.Ru ·

 WASM Phorum —› WASM.ASSEMBLER —› standart C procs

Посл.отвђт Сообщенiе


Дата: Янв 14, 2004 12:30:45

Hi, podskajite kak mne vyzwat' iz asma, standartnye c funkzii. takie kak: printf, rand itd...

MASM 7


Дата: Янв 14, 2004 13:02:05

ydab
Статически или динамически?


Дата: Янв 14, 2004 13:34:28

@q_q:

esli mojesh podskaji oba sposoba


Дата: Янв 14, 2004 18:37:03

Какого ляда... ydab, ты MSDN читать пробовал???


An __asm block can call C functions, including C library routines. The following example calls the printf library routine:

// InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
#include <stdio.h>

char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
void main( void )
{
   __asm
   {
      mov  eax, offset world
      push eax
      mov  eax, offset hello
      push eax
      mov  eax, offset format
      push eax
      call printf
      //clean up the stack so that main can exit cleanly
      //use the unused register ebx to do the cleanup
      pop  ebx
      pop  ebx
      pop  ebx
   }
}

Because function arguments are passed on the stack, you simply push the needed arguments — string pointers, in the previous example — before calling the function. The arguments are pushed in reverse order, so they come off the stack in the desired order. To emulate the C statement

printf( format, hello, world );
the example pushes pointers to world, hello, and format, in that order, and then calls printf.



Дата: Янв 14, 2004 19:08:38

ydab
1. Подключаешь msvcrt.lib (эту либу можно найти в сети или в недрах вижуал студио).
2. Создаёшь определения прототипов нужных функций (типа random PROTO C :DWORD)
3. Вызываешь их через invoke.


Дата: Янв 15, 2004 08:02:03

ydab
esli mojesh podskaji oba sposoba
Если найду статическую библиотеку, то напишу.
Динамический вариан см. в аттаче.


_634378606__use_msvcrt.rar


Дата: Янв 16, 2004 09:53:59

@all
thx...


Powered by miniBB 1.6 © 2001-2002
Время загрузки страницы (сек.): 0.053