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?

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

0
Posted at

概要

中古ノート買ってみた。
wsl1のubuntu18.04にnasm入れてみた。
nasmをgasに置き換えてみた。
練習問題やってみた。

練習問題

loopを回せ。

実行結果

# gcc -o loopint_64 loopint_64.s -no-pie

# ./loopint_64
dd1[0]=5, dd1[1]=7, dd1[98]=7, dd1[99]=9

サンプルコード

.intel_syntax noprefix
.global main
.extern printf
.text

main:
	push	rbp
_start:
	mov		qword ptr [dd1], 5
	mov		qword ptr [dd1 + 99 * 8], 9
	mov 	rdi, 1 * 8
_loop:
	mov 	qword ptr [dd1 + rdi], 7
	add		rdi, 8
	cmp		rdi, 8 * 99
	jne		_loop
	lea		rdi, fmt[rip]
	mov		rsi, qword ptr [dd1]
	mov		rdx, qword ptr [dd1 + 1 * 8]
	mov		rcx, qword ptr [dd1 + 98 * 8]
	mov		r8,  qword ptr [dd1 + 99 * 8]
	mov		rax, 0
	call	printf
_end:
	pop		rbp
	mov		rax, 0
	ret

.data
	fmt:	.string "dd1[0]=%ld, dd1[1]=%ld, dd1[98]=%ld, dd1[99]=%ld"

.bss
	.comm 	dd1, 800



以上。

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?