Skip to content

Commit d67c4c6

Browse files
xclaessejpakkane
authored andcommitted
nasm: Use an hello world test that works on 32bits too
Fixes: #10956
1 parent 32bc64e commit d67c4c6

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed
Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
%include "config.asm"
2-
3-
global main
4-
extern puts
1+
; hello.asm a first program for nasm for Linux, Intel, gcc
2+
;
3+
; assemble: nasm -f elf -l hello.lst hello.asm
4+
; link: gcc -o hello hello.o
5+
; run: hello
6+
; output is: Hello World
57

6-
section .data
7-
hi db 'Hello, World', 0
8+
%include "config.asm"
89

910
%ifdef FOO
1011
%define RETVAL HELLO
1112
%endif
1213

13-
section .text
14-
main:
15-
push rbp
16-
lea rdi, [rel hi]
17-
call puts wrt ..plt
18-
pop rbp
19-
mov ebx,RETVAL
20-
mov eax,1
21-
int 0x80
14+
SECTION .data ; data section
15+
msg: db "Hello World",10 ; the string to print, 10=cr
16+
len: equ $-msg ; "$" means "here"
17+
; len is a value, not an address
18+
19+
SECTION .text ; code section
20+
global main ; make label available to linker
21+
main: ; standard gcc entry point
22+
23+
mov edx,len ; arg3, length of string to print
24+
mov ecx,msg ; arg2, pointer to string
25+
mov ebx,1 ; arg1, where to write, screen
26+
mov eax,4 ; write sysout command to int 80 hex
27+
int 0x80 ; interrupt 80 hex, call kernel
28+
29+
mov ebx,RETVAL ; exit code, 0=normal
30+
mov eax,1 ; exit command to kernel
31+
int 0x80 ; interrupt 80 hex, call kernel

test cases/nasm/2 asm language/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ config_file = configure_file(
1717
output_format: 'nasm',
1818
)
1919

20+
cc = meson.get_compiler('c')
21+
link_args = cc.get_supported_link_arguments(['-no-pie'])
22+
2023
exe = executable('hello', 'hello.asm',
2124
nasm_args: '-DFOO',
25+
link_args: link_args,
2226
)
2327
test('hello', exe)

0 commit comments

Comments
 (0)