argv[1]
x86 アセンブリ言語で格納されているものの最初の要素を取得しようとしています。の数を数えられるようにeax
したいので、スタックを最初に 2 回ポップしました。次に、にポップしました。に入れることを考えています。ここから私は迷子になります。私は組み立ての経験がほとんどないか、まったくありません。理解したいと思っているだけです。argc
argc
argv
ebx
[ebx]
bl
main:
;
mov ecx, 0 ;count output characters
pop eax ;reject this 32 bits
pop eax ;get argc
;
pop ebx ; get argv
;mov bl, [ebx]
;
add al, 30H ;convert integer to ascii
mov edi, cline ;put char in output buffer
mov byte [edi],al
;inc edi
;mov [edi], bl
inc ecx ;increment output char count
inc edi ;increment pointer to o/p buffer
mov al, 0aH ;LF to end line
mov byte[edi],al ;put it at end of output line
inc ecx ;increment output char count
push ecx ;save char count on stack
mov edx,len ;length of string to write
mov ecx,msg ;addr of string
mov ebx,1 ;file descriptor 1 = stdout
mov eax,4 ;"write" system call
int 0x80 ;call the kernel
;
pop edx ;restore char count into edx for system call
mov ecx,cline ;address of string
mov ebx,1 ;file descriptor 1 = stdout