企业网站优化方案范本,wordpress开发网站,浙江省建设信息,ps怎么做网站0. 说明本学习系列代码几乎完全摘自#xff1a;asmtutor.com#xff0c;如果英文可以的(也可以用谷歌浏览器翻译看)#xff0c;可以直接看asmtutor.com上的教程系统环境搭建#xff1a;(我用的是ubuntu18.04.4 server#xff0c;安装gcc、g)sudo apt install nasmsudo apt…0. 说明本学习系列代码几乎完全摘自asmtutor.com如果英文可以的(也可以用谷歌浏览器翻译看)可以直接看asmtutor.com上的教程系统环境搭建(我用的是ubuntu18.04.4 server安装gcc、g)sudo apt install nasmsudo apt install gcc-multilib1. 完整示例; Hello World Program - asmtutor.com; Compile with: nasm -f elf helloworld.asm; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld.o -o helloworld; Run with: ./helloworldSECTION .datamsg db Hello World!, 0Ah ; assign msg variable with your message stringSECTION .textglobal _start_start:mov edx, 13 ; number of bytes to write - one for each letter plus 0Ah (line feed character)mov ecx, msg ; move the memory address of our message string into ecxmov ebx, 1 ; write to the STDOUT filemov eax, 4 ; invoke SYS_WRITE (kernel opcode 4)int 80hmov ebx, 0 ; return 0 status on exit - No Errorsmov eax, 1 ; invoke SYS_EXIT (kernel opcode 1)int 80h编译、链接和运行方法(其实代码中已经写了)nasm -f elf helloworld.asm -o helloworld # 可以用nasm -h看帮助信息-f elf是输出32位elf-f elf64是64ld -m elf_i386 helloworld.o -o helloworld # ld是链接器可以用ld -h看帮助信息-m elf_i386是格式为i386也有其他的可选# Run with:./helloworld2. 系统函数调用Linux的系统调用通过int 80h实现在此之前需要先要给eax寄存器赋值(opcodeoperation code操作码)例如调用sys_write函数的opcode是4那么就给eax赋值4mov eax, 4类似的sys_exit的opcode为1。3. 参数传递参数分别按照依次传递给ebx, ecx, edx例如sys_write的系统调用#include ssize_t write(int fd, const void *buf, size_t count);ebx第一个参数文件描述符1是标准输出(0是标准输入2是错误)这个就是写入到标准输出即打印到屏幕ecx第二个参数内存地址传递的是msg数据段中的地址(SECTION .data)edx把待打印的字符数传递给edxwindows c编程中好像有stdcall等函数调用约定约定参数传递的顺序是从右至左还是反之windows 32位下参数通过压栈的方式传递的当执行到int 80后因为opcode是4所以调用sys_write然后取ebx、ecx、edx作为参数执行相当于write(1, msg, 13)。类似的sys_exit函数为#include void _exit(int status);把0传递给ebx然后执行exit相当于exit(0)。系统调用的参数列表可以在linux shell命令行中输入man 2 write man 2 exit查看man手册第2部分就是关于系统调用的。