开发者

How do you do binary file I/O with Win32 ASM?

How would I do file io in assembly? And I mean assembly. I hate macros. I'm loo开发者_JAVA技巧king to edit a pre-existing 10 MB file with ASM.

If someone could give me some quick example code on how to do it, that would be appreciated.

Thanks!


All the actual file I/O is going to be handled by the OS, abstracted away by the open()/close()/read()/write()/etc. system calls (or whatever the equivalents are on Windows). So really all your ASM needs to do is call out to these functions (correctly setting up arguments on the stack, etc.), and handling return values.

So if you already know how to use open()/close() etc. in C, and you know how to call a function from ASM, then you're done!


While reading a file certainly should not be your first program if you're learning assembly Here's an example. As long as you're in Windows, you'll need to somehow invoke CreateFile in the win32 API.

The example calls CreateFile using macros, don't let that stop you, you can easily open the nasm include files and look at the assembly behind the macros and copy paste that assembly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜