Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 
;name: libhello.asm
;
;description: static library / archive libhello.a
;
;build: nasm -felf64 -Fdwarf -g -l libhello.lst libhello.asm -o libhello.o
;       ar rcs libhello-1.0.0-dev.a libhello.o
;
;license:
;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.
;
;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
;
;remark: use nm libhello.a for a list of published functions
bits 64
align 16

[list -]
    %include "libhello.inc"
[list +]

global  WriteString
global  Exit

section .text

WriteString:
    ; string and length is already in RSI, RDX
    syscall write, stdout, rsi, rdx
    ret
        
Exit:
    syscall exit, 0
%ifndef _static_libhello_inc_
%define _static_libhello_inc_

%include "unistd.inc"

%endif 		;; _static_libhello_inc_
;name: staticlibhellotest.asm
;
;description: demonstrates the use of a static library
;
;build: nasm -felf64 -Fdwarf -g -l staticlibhellotest.lst staticlibhellotest.asm -o staticlibhellotest.o
;       ld -g -melf_x86_64 staticlibhellotest.o -o staticlibhellotest libhello.a
;
;license:
;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.
;
;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <http://www.gnu.org/licenses/>.

bits 64

%include "staticlibhellotest.inc"

global _start

section .bss

section .data
    message: db  "Hello world!", 10
    .length: equ $-message

section .text

_start:
    mov     rsi, message
    mov     rdx, message.length
    call    WriteString
    xor     rdi, rdi
    call    Exit

%ifndef _staticlibhellotest_inc_

%define _staticlibhellotest_inc_

%include "unistd.inc"
extern WriteString
extern Exit

%endif 		;; _staticlibhellotest_inc_