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?

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

0
Last updated at Posted at 2025-11-08

概要

中古ノート買ってみた。
wsl1のubuntu18.04にnasm入れてみた。
アセンブラで、atcoder、見つけたので、やってみた。

参考にしたページ

練習問題

ABC 086 A - Product
2つの整数値を受け取り、その積が2の倍数かを判定する問題です。

投入するソース

1 21

期待値

Odd

サンプルコード




global main
extern puts, scanf
section .text

main:
	push 	rbp
	mov 	rbp, rsp
	sub 	rsp, 128
	lea 	rdi, [rel fmt]
	lea 	rsi, [rsp]
	lea 	rdx, [rsp + 4]
	call 	scanf WRT ..plt
	mov 	rax, [rsp]
	mov 	rbx, [rsp + 4]
	mul 	rbx
	test 	rax, 1
	jz 		res1
	lea 	rdi, [rel odd]
	jmp 	ep
res1:
	lea 	rdi, [rel even]
ep:
	call 	puts WRT ..plt
	mov 	eax, 0
	mov 	rsp, rbp
	pop 	rbp
	ret

section .data
	fmt db "%d%d", 0;
	odd db "Odd", 10, 0;
	even db "Even", 10, 0;




コンパイル、実行結果

# nasm -f elf64 at1.s
# gcc -o at1 at1.o -lc
# ./at1
1 21
Odd

以上。

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?