NO

Author Topic: Simple printf emulator  (Read 4208 times)

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Simple printf emulator
« on: November 09, 2011, 09:21:37 AM »
Here is a simple printf simulator. It can process only NULL terminated strings identified by the % symbol :


Code: [Select]
.386
.model flat,stdcall
option casemap:none

includelib \PellesC\lib\win\kernel32.lib
includelib \PellesC\lib\win\user32.lib

ExitProcess PROTO :DWORD

printfX PROTO C format:DWORD,args:VARARG

.data

format1 db 'This is a % % to % %',0
str1    db 'printfX',0
str2    db 'demo',0
str3    db 'display',0
str4    db 'strings.',0

.code

start:

    invoke   printfX,ADDR format1,\
             ADDR str1,ADDR str2,ADDR str3,ADDR str4
    invoke   ExitProcess,0

END start
Code it... That's all...