This project is a simplified version of the Unix diff
tool, implemented in x86-64 assembly (AT&T syntax).
It compares two text inputs line by line and highlights the differences, with optional flags for case-insensitivity and blank-line handling.
-
diff.s
Contains the full implementation:main
: Parses command-line arguments and sets flags (-i
,-B
).diff
: Core comparison logic.compareLines
: Compares two lines, optionally ignoring case (-i
).printDifferentLines
: Outputs differences in a readable format.
-
Example input (hardcoded in
diff.s
for now):file1 = "a\nkFds\nfdsan\nabc\n" file2 = "A\nkFds"
Use gcc
to assemble and link the program. For example:
gcc -no-pie diff.s -o diff
This creates an executable called diff
.
For now, diff.s
contains two hardcoded input strings (file1
and file2
).
When you run the program, it compares those and prints the differences.
Example:
./diff
Output format:
1c1
< a
----
> A
The program supports two optional flags:
-i
→ Ignore case differences (e.g., "a" == "A")-B
→ Ignore blank lines when comparing
Example:
./diff -i
./diff -B
./diff -i -B