Skip to Main Content
Professional Assembly Language
book

Professional Assembly Language

by Richard Blum
February 2005
Intermediate to advanced content levelIntermediate to advanced
574 pages
13h 18m
English
Wrox
Content preview from Professional Assembly Language

Chapter 16. Using Files

There are many occasions when an application must store data for later use, or read configuration information from a configuration file. To handle these functions, the assembly language program must be able to interact with files on the UNIX system.

This chapter describes how to handle files within assembly language programs, both writing data out to them and reading data in from them. Two basic methods are used to access files from assembly language programs. One method is to use the standard C functions. If you already program in C or C++, you should be familiar with these—fopen(), read(), and write(). The C file I/O functions in turn use the Linux system calls (described in Chapter 12, "Using Linux System Calls") to access files. In assembly language programming, you can bypass the C function calls and directly access the Linux file I/O system calls provided by the kernel. This is the method described in this chapter.

The chapter starts out with a brief explanation of how the UNIX system handles files. Next it shows how to write data to files, specifying the proper permissions and access types. After that, how to read data from files is shown, along with how to process the data and write to another file. Finally, the topic of using memory-mapped files is presented. This feature enables you to read a complete file into memory, process and modify the data within the memory-mapped file, and write the data back to the original file.

The File-Handling Sequence ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Introduction to 80x86 Assembly Language and Computer Architecture, 2nd Edition

Introduction to 80x86 Assembly Language and Computer Architecture, 2nd Edition

Richard C. Detmer

Publisher Resources

ISBN: 9780764579011Purchase book