alright I'm beginning to learn assembly-language and I have created a sample program that does some adding and I'm getting a problem while linking. Heres the program---
when I compile with nasm it compiles fine, but when I try to link it with ld i get this:
running it under root does not help and I've tried using both USE64 and BITS64 in the file to no avail-ive heard the cannot find entry symbol _start is just a symptom of the i386 architecture error...can anyone help me with this?
thank you!
Code:
USE64
global _start
section .stack
section .text
_start:
sub RCX,RCX ;set sum to zero
mov RAX,47h ;starting number for adds
par_loop:
push RAX ;pass parameter
dec RAX ;decrement amount of parms left
inc RCX ;update number of parameters
cmp RAX,40h ;if not done
jne par_loop ;repeat
push RCX ;final parameter
call total_add ;find the ands of the parms
total_add:
push RBP ;save EBP
mov RBP,RSP ;start of parameters
add RBP,16 ;
push RCX; ;save ECX
push RDX ;save EDX
mov RCX,[EBP+4] ;counter
add RCX,8; ;beginning of parms
add RCX,RCX ;multiply ECX by size of parameters
add RCX,RCX ;
add RCX,RCX ;
add RCX,RCX ;
add RBP,RCX ;beginning
sub RAX,RAX ;zero out sum
add RSP,32 ;set ESP to top
add_loop:
sub RBP,8 ;update EBP
mov RDX,[RBP] ;second parameter
add RDX,[RBP+8] ;add them together
add RAX,RDX ;add to sum
cmp RBP,RSP ;if end of parameters
jne and_loop ;then end
sub RSP,32 ;
pop RDX ;restore EDX
add RSP,24 ;clearing parameters
add RSP,RCX ;clear all parameters
ret ;clear stack again for processing
Code:
$ ld -s -o practice practice.o
ld: warning: i386 architecture of input file `practice.o' is incompatible with i386:x86-64 output
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
thank you!