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?

More than 5 years have passed since last update.

#概要

paizaでアセンブラ、やってみた。
練習問題やってみた。

#練習問題

fizzbuzzやって。

#サンプルコード

.code32
.text
.global main

main:
    mov     $1, %esi
loop:
    mov     %esi, %eax
    mov     $15, %ebx
    div     %bl
    cmp     $0, %ah
    jz      loop15
    mov     %esi, %eax
    mov     $5, %ebx
    div     %bl
    cmp     $0, %ah
    jz      loop5
    mov     %esi, %eax
    mov     $3, %ebx
    div     %bl
    cmp     $0, %ah
    jz      loop3
	mov 	$fmt, %edi
loop2:	
	mov 	$0, %eax
    push    %esi
	call 	printf
    pop     %esi
loop1:
	add     $1, %esi
	cmp     $101, %esi
    jnz     loop
	ret

loop15:
    mov 	$fizzbuzz, %edi
    jmp     loop2
loop5:
    mov 	$buzz, %edi
    jmp     loop2
loop3:
    mov 	$fizz, %edi
    jmp     loop2
	
.data
fmt:
	.asciz 	"%d "
num:
	.asciz 	"%i "
fizz:
	.asciz 	"Fizz "
buzz:
	.asciz 	"Buzz "
fizzbuzz:
	.asciz 	"FizzBuzz "	
	


#成果物

以上。

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?