This project is a small assembly-language program that:
- Opens a text file passed as the first CLI argument.
- Reads up to a configurable buffer size from the file.
- Prints the file content to stdout.
- Reads additional input from stdin.
- Appends the input to the original buffer and writes the result back to the same file.
Source file:
Text Editor
- Linux (tested with GNU/Linux tooling)
nasmld(frombinutils)
Install dependencies on Debian/Ubuntu:
sudo apt update
sudo apt install -y nasm binutilsnasm -f elf64 -o text_editor.o "Text Editor"
ld -o text_editor text_editor.o- Create a test file:
echo "Initial content;" > sample.txt- Run the program with the file path as first argument:
./text_editor sample.txt- Type text in stdin and press
Ctrl+Dto finish input.
The program prints what it reads and updates sample.txt with appended content.
- The program currently uses Linux syscalls directly (
sys_open,sys_read,sys_write,sys_close,sys_exit). - The read and working buffers are controlled by
BUFFER_SIZEin the source file. - The file path comes from
argv[1]; if omitted, behavior is undefined.
git clone <repo-url>
cd Text_editor_assembly
nasm -f elf64 -o text_editor.o "Text Editor"
ld -o text_editor text_editor.o
echo "Initial content;" > sample.txt
./text_editor sample.txt