64 ビットの lubuntu で nasm にスタックを実装する際に問題が発生しています。他の ubuntu OS では正しく動作し、オンライン コンパイラで実行すると正しく動作します。私のOSがnasmのスタックをサポートしていないのか、それとも適用する必要があるコードがあるのか 考えていました.
section .data
num dw 0
x dw 5
y dw 4
newline db "",10
newlineLen equ $-newline
section .bss
section .text
global _start
_start:
sub esp,2
push word[x]
push word[y]
call sum
pop word[num] ;fetch the sum from the stack
;convert num for printing
add word[num],30h
mov eax,4
mov ebx,1
mov ecx,num
mov edx,1
int 80h
mov eax,4
mov ebx,1
mov ecx,newline
mov edx,newlineLen
int 80h
mov eax,1
mov ebx,0
int 80h
sum:
mov ebp,esp
mov ax,[ebp+6] ;5
add ax,[ebp+4] ;4+5
mov [ebp+8],ax ;store the result in the space allocated for the sum
ret 4 ;esp+4