flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar
Do you need that macro to be some interface for the "printf" function from CRT, or do you mean the whole procedure written in assembly, that will perform the task of "printf" function?
|
|||
![]() |
|
HarryTuttle
the basic printf syntax which can simpy print a string %s or a digit %d and can be ended by \n makes me satisfied.
if I'll have to use another printf's option the simplest way will be to load it as module written i C. Am I wrong? but today I'll learn such exampe as "for" to understand how can I do anything ,because I know nothing about macros. _________________ Microsoft: brings power of yesterday to computers of today. |
|||
![]() |
|
Eoin
To be honest I've only ever used sprintf, never the console version but I imagine the functionality is the same.
The printf functions are available in the crtdll.dll which comes with the versions of windows I'm aware of. So the simple solution is to write a macro which will call those functions. Basically all you need is a ccall or cinvoke macro. There are plenty of examples around but you say you wish to do this yourself. I'd recommend studying the stdcall and invoke macros you'll find in the Fasm examples and then try and convert them to cdecl. For extra info on calling conventions see http://www.codeproject.com/cpp/calling_conventions_demystified.asp Including strings among the parameters is possible thanks to the eqtype operator, again there are plenty of examples knocking around. |
|||
![]() |
|
HarryTuttle
THX all of You ,I had no idea that crtdll.dll includes all I need.
API&DLL are powerful tools ,just I know the truth that without those tools I can't do any step forward. _________________ Microsoft: brings power of yesterday to computers of today. |
|||
![]() |
|
Vortex
An example:
Code: format PE CONSOLE entry start include '%include%\win32a.inc' section '.data' data readable writeable msg db 'This is a printf example',0 format1 db '%s',0 section '.code' code readable executable start: cinvoke printf,format1,msg invoke ExitProcess,0 section '.idata' import data readable writeable library kernel32,'kernel32.dll',\ crtdll,'crtdll.dll' import kernel32,\ ExitProcess,'ExitProcess' import crtdll,\ printf,'printf' _________________ Code it... That's all... |
|||
![]() |
|
vid
What about using simple wsprintf from user32 (maybe kernel32)?
At has basic functionality |
|||
![]() |
|
Eoin
The advantage with sprintf is that it handles floating points unlike wsprintf.
|
|||
![]() |
|
HarryTuttle
but this is better and faster for W_9x only.
W_NT use UNICODE so there is w font in sprintf,it means wild-16bit characters intead of ASCII codes. W_NT always translate ASCII to UNICODE ! _________________ Microsoft: brings power of yesterday to computers of today. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.