This program seems simple. It's only complex because it's made with x86_64 assembly.
C++ equivalent: std::cout << argv[1] << "^2 = " << argv[1] * argv[1];
- An x86_64 compatible processor
- Linux operating system (i think idek)
- An assembler (e.g.,
nasm) - A linker (e.g.,
ld)
-
Clone the repository or download the source file.
-
Assemble the code:
nasm -f elf64 -o main.o src/main.asm
nasm -f elf64 -o syscalls.o src/syscalls.asm
nasm -f elf64 -o len.o src/len.asm
nasm -f elf64 -o numbers.o src/numbers.asm- Link the object files
ld -m elf_x86_64 -o square main.o syscalls.o len.o numbers.o- Run the program
./square 5
5^2 = 25