initial import
[staff/goc4/2018bti7061.git] / asm-8-strings / examples / clib / eatclib2.asm
1 ; Source name : EATCLIB.ASM
2 ; Executable name : EATCLIB
3 ; Version : 2.0
4 ; Created date : 10/1/1999
5 ; Last update : 11/16/2015
6 ; Author : Jeff Duntemann
7 ;;; Modifications: E. Benoist
8 ; Description : Demonstrates calls made into clib, using NASM 2.05
9 ; to send a short text string to stdout with puts().
10 ;
11 ; Build using these commands:
12 ; nasm -f elf64 -g -F stabs eatclib.asm
13 ; gcc eatclib.o -o boiler
14
15 [SECTION .data] ; Section containing initialised data
16
17 EatMsg: db "Eat at Joe's!",10,0 ; We do not need the length because of c library
18
19 [SECTION .bss] ; Section containing uninitialized data
20
21 [SECTION .text] ; Section containing code
22
23 extern puts ; Simple "put string" routine from clib
24 global main ; Required so linker can find entry point
25
26 main:
27 push rbp ; Set up stack frame for debugger
28 mov rbp,rsp
29 push rbx ; Must preserve ebp, ebx, esi, & edi
30 push rsi
31 push rdi
32 ;;; Everything before this is boilerplate; use it for all ordinary apps!
33 mov rdi, EatMsg ; Write address of message in RDI
34 call puts ; Call clib function for displaying strings
35
36
37 ;;; Everything after this is boilerplate; use it for all ordinary apps!
38 pop rdi ; Restore saved registers
39 pop rsi
40 pop rbx
41 mov rsp,rbp ; Destroy stack frame before returning
42 pop rbp
43 ret ; Return control to Linux