标签:class pre 搭建 smt his 说明 argc sem fun
sudo apt install nasm
sudo apt install gcc-multilib
main(int argc, char** argv)
:
以下代码摘自:https://asmtutor.com/#lesson8
functions.asm
是之前的。
%include ‘functions.asm‘ ; 这个就是之前的
SECTION .text
global _start
_start:
pop ecx ; 弹出第一个参数到ecx,即参数个数
nextArg:
cmp ecx, 0h ; check to see if we have any arguments left
jz noMoreArgs ; if zero flag is set jump to noMoreArgs label (jumping over the end of the loop)
pop eax ; 弹出下一个参数到eax,然后打印
call sprintLF ; call our print with linefeed function
dec ecx ; 递减ecx,看看剩下的参数个数
jmp nextArg ; jump to nextArg label
noMoreArgs:
call quit
下面摘自https://asmtutor.com/#lesson8的测试结果:
~$ ./helloworld-args "This is one argument" "This is another" 101
./helloworld-args
This is one argument
This is another
101
标签:class pre 搭建 smt his 说明 argc sem fun
原文地址:https://www.cnblogs.com/whuwzp/p/nasm_cmdline.html