1. 无法获得锁
E: 无法获得锁 /var/cache/apt/archives/lock - open (11: 资源暂时不可用)
E: 无法对目录 /var/cache/apt/archives/ 加锁
E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用)
E: 无法对目录 /var/lib/apt/lists/ 加锁
参考 https://www.linuxidc.com/Linux/2014-06/103437.htm
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
1.1 重命名文件 hello.c -> hello.s
mv hello.c hello.s //可以移动文件或者实现重命名
2. 安装NASM
sudo apt-get clean
sudo apt-get remove nasm-rdoff
sudo apt-get install nasm
3. 安装GAS
sudo apt-get install build-essential //于GCC编译器一同完成安装
as --version //检查GAS
4. Hello World
# ---------------------------------------------------------------------------------------- # Writes "Hello, World" to the console using only system calls.
Runs on 64-bit Linux only.
# To assemble and run:
# # gcc -c hello.s && ld hello.o && ./a.out # # or # # gcc -nostdlib hello.s && ./a.out
# ----------------------------------------------------------------------------------------
.global _start
.text _start:
# write(1, message, 13)
mov $1, %rax # system call 1 is write
mov $1, %rdi # file handle 1 is stdout
mov $message, %rsi # address of string to output
mov $13, %rdx # number of bytes
syscall # invoke operating system to do the write # exit(0) mov $60, %rax # system call 60 is exit
xor %rdi, %rdi # we want return code 0
syscall # invoke operating system to exit message:
.ascii "Hello, world\n"