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?

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

0
Posted at

概要

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

練習問題

ABC 081 B - Shift Only
N個の整数値を受け取り、一度の操作ですべての数を2で割る。割り切れなくなるまで割っていった時、何回割ることが出来るか?

投入するソース

3
8 12 40

期待値

2

サンプルコード

.intel_syntax noprefix
.global main
.extern scanf, printf
.text

main:
	push 	rbp
	lea 	rdi, fmti[rip]
	lea 	rsi, [rsp]
	call 	scanf
	xor 	rbx, rbx
	mov 	r13, [rsp]
loop:
	lea 	rdi, fmto[rip]
	lea 	rsi, [rsp]
	call 	scanf
	mov 	rax, [rsp]
	or 		rbx, rax
	dec 	r13
	cmp 	r13, 0
	jz 		loop
	lea 	rdi, fmto[rip]
	tzcnt 	rsi, rbx
	sub 	rsi, 1
	call 	printf
	xor 	eax, eax
	pop 	rbp
	ret

.data
	fmti: 	.string "%d\n"
	fmto: 	.string "%d"


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

# ./at3
3
8 12 40
2

以上。

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?