CSC231 Bash Tutorial 6
--D. Thiebaut (talk) 22:18, 21 March 2017 (EDT)
Script File
Let's create a simple batch file that will allow you to automatically assemble, link, and run an assembly program. Furthermore, we'll link it with the 231Lib library, just to be safe. If it doesn't use it, it should be fine.
The commands you normally use to go through this process are the following:
nasm -f elf progName.asm ld -melf_i386 progName.o 231Lib.o -o progName ./progName
Let's create a script file called nald (for nasm ld) that will run these 3 commands automatically:
- emacs a new file called nald
- Store the following lines in it:
#! /bin/bash nasm -f elf $1.asm nasm -f elf 231Lib.asm ld -melf_i386 $1.o 231Lib.o -o $1 ./$1