filmov
tv
How to compile and execute an Assembly Language Code

Показать описание
This video shows you how to compile and execute and assembly language code. If you want to learn how the code works, please check out my other videos.
Please note this works only on Raspberry Pis. I am using a file named "hw.s" in this video. If you want to use a different file, just update the fine name in the commands with your file name. For example if your file name is addition.s, following will be the commands to assemble, create an object file and execute the code:
as -o addition.o addition.s
ld -s -o addition addition.o
./addition
In the first command:
as: This is the GNU assembler, used to convert assembly code into machine code.
-o: Specifies the output file name (addition.o), which will contain the assembled machine code.
addition.s: This is the assembly source file that we are assembling.
In the second command,
ld: This is the GNU linker, used to link object files into an executable.
-s: Strips debugging symbols to reduce the executable size.
-o addition: Specifies the output executable file (addition).
add.o: This is the object file produced by as in the previous step.
Please note this works only on Raspberry Pis. I am using a file named "hw.s" in this video. If you want to use a different file, just update the fine name in the commands with your file name. For example if your file name is addition.s, following will be the commands to assemble, create an object file and execute the code:
as -o addition.o addition.s
ld -s -o addition addition.o
./addition
In the first command:
as: This is the GNU assembler, used to convert assembly code into machine code.
-o: Specifies the output file name (addition.o), which will contain the assembled machine code.
addition.s: This is the assembly source file that we are assembling.
In the second command,
ld: This is the GNU linker, used to link object files into an executable.
-s: Strips debugging symbols to reduce the executable size.
-o addition: Specifies the output executable file (addition).
add.o: This is the object file produced by as in the previous step.