Friday 15 August 2014

SublimeText Build System for nasm (assembly)

Just been playing looking at the SecurityTube Linux Assembly course (again) and decided to use SublimeText as the editor for writing the code.

Got frustrated with having to type the compile and link each time at the command line and was pretty sure you could configure SublimeText to do this for you rather than use a bash script.

After a quick read of the sublime docs I found the following would work:

 {
"cmd": ["nasm -f elf32 ${file} -o ${file_path}/${file_base_name}.o && ld -o ${file_path}/${file_base_name} ${file_path}/${file_base_name}.o"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "shell": true
}

To add to sublime go to Tools > Build System > New Build System, copy and paste all the text above over the top of what already exists, then save as nasm. Set the Build System to nasm and then use ctrl+b or F7 to build.