0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

中古ノート、買ってみた。 その111

0
Posted at

概要

中古ノート買ってみた。
wsl1のubuntu18.04にnasm入れてみた。
練習問題、やってみた。

練習問題

1から100まで、数えよ。

実行結果

# gcc -o hyaku0 hyaku0.s

# ./hyaku0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

サンプルコード

.intel_syntax noprefix
.global main

.text
main:
	push 	rbp
	mov 	rbp, rsp

_start:
	mov 	r15, 0

_loop:
	inc 	r15
	mov		rsi, r15
	lea 	rdi, fmt[rip]
	mov 	rax, 0
	call 	printf@PLT
	cmp		r15, 100
	jne		_loop

_end:
	mov		rax, 0
	mov 	rsp, rbp
	pop 	rbp
	ret

.data
	fmt:  .string "%d "



以上。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?