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?

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

0
Posted at

概要

中古ノート買ってみた。
windows10でfasmをやってみた。
練習問題、やってみた。

練習問題

fizzbuzzを書け。

コンパイル、実行結果

>fasm fizz.asm
flat assembler  version 1.73.34  (1048576 kilobytes memory)
4 passes, 2048 bytes.

>fizz
1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
16
17
fizz
19
buzz
fizz
22
23
fizz
buzz
26
fizz
28
29
fizzbuzz
31
32
fizz
34
buzz
fizz
37
38
fizz
buzz
41
fizz
43
44
fizzbuzz
46
47
fizz
49
buzz
fizz
52
53
fizz
buzz
56
fizz
58
59
fizzbuzz
61
62
fizz
64
buzz
fizz
67
68
fizz
buzz
71
fizz
73
74
fizzbuzz
76
77
fizz
79
buzz
fizz
82
83
fizz
buzz
86
fizz
88
89
fizzbuzz
91
92
fizz
94
buzz
fizz
97
98
fizz
buzz



サンプルコード


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

section '.idata' data readable import
	library kernel32, 'kernel32.dll', msvcrt, 'msvcrt.dll'
	import kernel32, ExitProcess, 'ExitProcess'
	import msvcrt, printf, 'printf', getchar, 'getchar'

section '.text' code executable

main:
	push	rbp
	mov		rbp, rsp
_start:
	mov 	r15, 0
	mov 	r14, 0
_loop:
	inc 	r15
_mod15:
	mov 	r14, 15
	mov		edx, 0
	mov		eax, r15d
	mov		ecx, r14d
	div		ecx
_cmp15:
	cmp		edx, 0
	jne		_mod5
_print15:
	cinvoke printf, fmt15
	jmp 	_cmp100
_mod5:
	mov 	r14, 5
	mov		edx, 0
	mov		eax, r15d
	mov		ecx, r14d
	div		ecx
_cmp5:
	cmp		edx, 0
	jne		_mod3
_print5:
	cinvoke printf, fmt5
	jmp 	_cmp100
_mod3:
	mov 	r14, 3
	mov		edx, 0
	mov		eax, r15d
	mov		ecx, r14d
	div		ecx
_cmp3:
	cmp		edx, 0
	jne		_printn
_print3:
	cinvoke printf, fmt3
	jmp 	_cmp100
_printn:
	cinvoke printf, fmt, r15
_cmp100:
	cmp		r15, 100
	jne		_loop
_end:
	mov		eax, 0
	invoke 	ExitProcess, 0

section '.data' data readable
	fmt			db "%d",10,0
	fmt15		db "fizzbuzz",10,0
	fmt5		db "buzz",10,0
	fmt3		db "fizz",10,0





以上。

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?