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?

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

0
Posted at

概要

中古ノート買ってみた。
wsl1のubuntu18.04にnasm入れてみた。
printfを呼び出しても、値の変わらないレジスタを探してみた。

実行結果

# gcc -o avi0 avi0.s

# ./avi0
rbx = 9
rbx = 9
r15 = 9
r14 = 9
r13 = 9
r12 = 9
r11 = 0

サンプルコード

.intel_syntax noprefix
.global main

.text
main:
	push 	rbp
	mov 	rbp, rsp

_start:
	mov 	rbx, 9 
	mov 	r15, 9 
	mov 	r14, 9 
	mov 	r13, 9 
	mov 	r12, 9 
	mov 	r11, 9 

	mov		rsi, rbx
	lea 	rdi, fmt0[rip]
	mov 	rax, 0
	call 	printf@PLT

	mov		rsi, rbx
	lea 	rdi, fmt0[rip]
	mov 	rax, 0
	call 	printf@PLT

	mov		rsi, r15
	lea 	rdi, fmt1[rip]
	mov 	rax, 0
	call 	printf@PLT

	mov		rsi, r14
	lea 	rdi, fmt2[rip]
	mov 	rax, 0
	call 	printf@PLT

	mov		rsi, r13
	lea 	rdi, fmt3[rip]
	mov 	rax, 0
	call 	printf@PLT

	mov		rsi, r12
	lea 	rdi, fmt4[rip]
	mov 	rax, 0
	call 	printf@PLT

	mov		rsi, r11
	lea 	rdi, fmt5[rip]
	mov 	rax, 0
	call 	printf@PLT

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

.data
	fmt0:  .string "rbx = %d\n"
	fmt1:  .string "r15 = %d\n"
	fmt2:  .string "r14 = %d\n"
	fmt3:  .string "r13 = %d\n"
	fmt4:  .string "r12 = %d\n"
	fmt5:  .string "r11 = %d\n"




以上。

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?