WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Using standard C streams with MASM, __iob_func is redirected to __p__iob / an example on extending MASM functionality

Vortex
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 140
Member No.: 8
Joined: 13-May 04


Here is a quick example to use standard C streams with Masm :

CODE
.386
.model flat, stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\msvcrt.inc
includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\msvcrt.lib

include     Streams.inc

.data

msg     db 'stdout = %X',0

.data?

stdout  dd ?
stdin   dd ?
stderr  dd ?

.code

start:

   call    crt___p__iob
   mov     stdin,eax       ; #define stdin  (&__iob_func()[0])
   add     eax,SIZEOF(FILE)
   mov     stdout,eax      ; #define stdout (&__iob_func()[1])
   add     eax,SIZEOF(FILE)
   mov     stderr,eax      ; #define stderr (&__iob_func()[2])
   invoke  crt_fprintf,stdout,ADDR msg,stdout        
   invoke  ExitProcess,0

END start


__iob_func is redirected to __p__iob

Attached File ( Number of downloads: 71 )
 Login or Register to download

PMEmail PosterUsers Website
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google