Installation and basic usage of nasm assembler

Experimental environment
ubuntu 18.04

Reference material (very detailed)
address

nasm installation

sudo apt install nasm

test

nasm -v

sample code

test.s

; 测试unpcklps指令
        global  main
        global msg
        extern  puts
        section .text
data1 db  1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
data2 db  17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32

main:
        lea rax, [rel data1]
        lea rbx, [rel data2]
        movups xmm1,[rax]
        movups xmm2,[rbx]
        unpcklps xmm2,xmm1 
        ret

Nasm compiles into object files

nasm -felf64 test.s

After execution, a test.ofile will be generated

gcc link into executable file

gcc test.o -o test

After compilation, testthe file will be generated

run

./test

No output (because nothing is printed), more routines refer to address

gdb debugging

If you encounter an instruction that you don't understand, you can use gdb to debug.

Guess you like

Origin blog.csdn.net/qq_29809823/article/details/118919802