Hi there;
I am writing a sample nasm program via terminal.It's a basic one ,it only demonstrates the usage of the zero and sign flags and print relevant message to the output. Here are the code:
Code:
SECTION .data ; data section
errMsg: db "Error !",10
errLen: equ $-errMsg
zeroMsg: db "Zero flag",10
zeroLen: equ $-zeroMsg
signMsg: db "Sign flag",10
signLen: equ $-signMsg
SECTION .text ; code section
global main ; make label available to linker
main: ; standard gcc entry point
;Zero Check Module
;---------------------------------
; mov cx,1
; sub cx,1
; jz zero
;If flow reached here, an error has been done.
; jmp error
;---------------------------------
;Signed Check Module
;---------------------------------
mov cx,0
sub cx,1 ;CX = -1, SF = 1;
js sign
;If flow reached here, an error has been done.
jmp error
;---------------------------------
zero:
;If flow reached here, zero flag has set.It prints "Zero Flag" message to the screen.
mov edx,zeroLen
mov ecx,zeroMsg
jmp print
endZero:
error:
;If flow reached here, an error has occured.
mov edx,errLen
mov ecx,errMsg
jmp print
endError:
sign:
;If flow reached here, sign flag has set.It prints "Sign Flag" message to the screen.
mov edx,signLen
mov ecx,signMsg
jmp print
endSign:
print:
mov ebx,1 ; arg1, where to write, screen
mov eax,4 ; write sysout command to int 80 hex
int 0x80 ; interrupt 80 hex, call kernel
mov ebx,0 ; exit code, 0=normal
mov eax,1 ; exit command to kernel
int 0x80 ; interrupt 80 hex, call kernel
endprint:
I made ready this code with these commands:
assemble:nasm -f elf zs.asm
link:ld zs.o -o zs
At that point, I 've got such a warning:
Quote:
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048080
|
compile : gcc -g zs.o -o zs
run:./zs
Even it ran properly, I wonder the reason of this warning. What does it mean? My gcc version is:
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
I suspect that it is related with the crt0.o,(
http://docs.hp.com/en/B2355-90694/crt0.3.html) but I can not handle this.Thanks in advance.