VOOZH about

URL: https://qiita.com/C_Assembly/items/b514bf02b90bbfc68dfb

⇱ NASMでファイル分割からのHello, World #Ubuntu - Qiita


👁 Image
3

Go to list of users who liked

1

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@C_Assembly(Ishige)

NASMでファイル分割からのHello, World

3
Last updated at Posted at 2018-10-29

環境

  • OS : Ubuntu 18.04
  • アセンブラ : nasm 2.13.02
  • リンカ : ld 2.30

ソースプログラム

main.asm
extern hello
extern end

global _start

[section .text]
_start:
	call hello
	call end
function.asm
global hello
global end

[section .data]
	string1: db "Hello, World", 0x0a
	length1: equ $ - string1

[section .text]

hello:
	mov rax, 1
	mov rdi, 1
	mov rsi, string1
	mov rdx, length1
	syscall
	ret

end:
	mov rax, 60
	mov rdi, 0
	syscall

コマンド

nasm -felf64 main.asm -o main.obj
nasm -felf64 function.asm -o function.obj
ld -o exe main.obj function.obj
./exe

最後に

記事の最初に書くべきなのでしょうが一応書いておきます。
「実行等は自己責任でお願いします。」
下の書籍は私が読んでいていいなと思ったものです。
ただ、30日でできるOS自作入門は、やっていることはすごいのですが、説明と開発環境がいまいちだと感じました。
あとセンター試験まで少ししかないので発狂しました。

おすすめの本

低レベルプログラミング
30日でできるOS自作入門

3

Go to list of users who liked

1
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3

Go to list of users who liked

1