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?

アセンブラfasmでatcoder その3

0
Posted at

概要

アセンブラfasmで、atcoder、やってみた。

練習問題

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

投入するソース

3
8 12 40

期待値

2

サンプルコード


format PE64 console
entry start
include 'C:\Program Files (x86)\fasmw17334\INCLUDE\win64a.inc'

section '.idata' import data readable writeable
	library kernel32, 'kernel32.dll', msvcrt, 'MSVCRT.DLL'
	import kernel32, ExitProcess, 'ExitProcess'
	import msvcrt, printf, 'printf', scanf, 'scanf'

section '.data' data readable
	fmt		db "%d", 0;
	fmto	db "%d", 10, 0;

section '.bss' data readable writeable
	VA		dd ?

section '.text' code readable executable
start:
	cinvoke scanf, fmt, addr VA
	mov		r15d, 0
	mov		r13d, [VA]
_loop:
	cinvoke scanf, fmt, addr VA
	mov 	r14d, [VA]
	or 		r15d, r14d
	dec 	r13d
	cmp 	r13d, 0
	jnz 	_loop
	tzcnt 	rbx, r15
print_result:
	cinvoke printf, fmto, rbx
	cinvoke ExitProcess, 0




実行結果

>atcoder3
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?