Created
October 10, 2012 23:07
-
-
Save Rhomboid/3869129 to your computer and use it in GitHub Desktop.
Fizzbuzz in assembly on 9 architectures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int i; | |
for(i = 1; i <= 100; i++) { | |
if(i % 15 == 0) { | |
puts("FizzBuzz"); | |
} else if(i % 3 == 0) { | |
puts("Fizz"); | |
} else if(i % 5 == 0) { | |
puts("Buzz"); | |
} else { | |
printf("%d\n", i); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.cpu arm9tdmi | |
.fpu softvfp | |
.eabi_attribute 20, 1 | |
.eabi_attribute 21, 1 | |
.eabi_attribute 23, 3 | |
.eabi_attribute 24, 1 | |
.eabi_attribute 25, 1 | |
.eabi_attribute 26, 2 | |
.eabi_attribute 30, 2 | |
.eabi_attribute 18, 4 | |
.file "fizzbuzz.c" | |
.section .rodata.str1.4,"aMS",%progbits,1 | |
.align 2 | |
.LC0: | |
.ascii "FizzBuzz\000" | |
.align 2 | |
.LC1: | |
.ascii "Fizz\000" | |
.align 2 | |
.LC2: | |
.ascii "Buzz\000" | |
.align 2 | |
.LC3: | |
.ascii "%d\012\000" | |
.text | |
.align 2 | |
.global main | |
.type main, %function | |
main: | |
@ Function supports interworking. | |
@ args = 0, pretend = 0, frame = 0 | |
@ frame_needed = 0, uses_anonymous_args = 0 | |
stmfd sp!, {r4, r5, r6, r7, lr} | |
ldr r5, .L12 | |
sub sp, sp, #4 | |
ldr r6, .L12+4 | |
ldr r7, .L12+8 | |
mov r4, #1 | |
b .L6 | |
.L2: | |
smull r3, r2, r6, r4 | |
rsb r2, r1, r2 | |
mov r3, r2, asl #1 | |
add r3, r3, r2 | |
cmp r4, r3 | |
beq .L10 | |
smull r3, r2, r7, r4 | |
rsb r2, r1, r2, asr #1 | |
mov r3, r2, asl #2 | |
add r3, r3, r2 | |
cmp r4, r3 | |
mov r1, r4 | |
ldr r0, .L12+12 | |
bne .L5 | |
bl puts | |
.L3: | |
add r4, r4, #1 | |
cmp r4, #101 | |
beq .L11 | |
.L6: | |
smull r3, r2, r5, r4 | |
mov r1, r4, asr #31 | |
add r2, r2, r4 | |
rsb r2, r1, r2, asr #3 | |
mov r3, r2, asl #4 | |
rsb r3, r2, r3 | |
cmp r4, r3 | |
bne .L2 | |
ldr r0, .L12+16 | |
add r4, r4, #1 | |
bl puts | |
cmp r4, #101 | |
bne .L6 | |
.L11: | |
add sp, sp, #4 | |
ldmfd sp!, {r4, r5, r6, r7, lr} | |
bx lr | |
.L5: | |
ldr r0, .L12+20 | |
bl printf | |
b .L3 | |
.L10: | |
ldr r0, .L12+24 | |
bl puts | |
b .L3 | |
.L13: | |
.align 2 | |
.L12: | |
.word -2004318071 | |
.word 1431655766 | |
.word 1717986919 | |
.word .LC2 | |
.word .LC0 | |
.word .LC3 | |
.word .LC1 | |
.size main, .-main | |
.ident "GCC: (Debian 4.3.5-4) 4.3.5" | |
.section .note.GNU-stack,"",%progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.LEVEL 1.1 | |
.section .rodata.str1.4,"aMS",@progbits,1 | |
.align 4 | |
.LC0: | |
.stringz "FizzBuzz" | |
.align 4 | |
.LC1: | |
.stringz "Fizz" | |
.align 4 | |
.LC2: | |
.stringz "Buzz" | |
.align 4 | |
.LC3: | |
.stringz "%d\n" | |
.section .rodata.cst8,"aM",@progbits,8 | |
.align 8 | |
.LC4: | |
.word 0 | |
.word -2004318071 | |
.align 8 | |
.LC5: | |
.word 0 | |
.word 1431655766 | |
.align 8 | |
.LC6: | |
.word 0 | |
.word 1717986919 | |
.text | |
.align 4 | |
.globl main | |
.type main, @function | |
main: | |
.PROC | |
.CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=11 | |
.ENTRY | |
ldil L'-2004320256,%r28 | |
ldil L'1431650304,%r19 | |
stw %r2,-20(%r30) | |
stwm %r11,128(%r30) | |
stw %r5,-104(%r30) | |
ldo 2185(%r28),%r5 | |
ldil L'1717993472,%r28 | |
stw %r8,-116(%r30) | |
ldo -6553(%r28),%r8 | |
ldil LR'.LC2,%r28 | |
stw %r6,-108(%r30) | |
ldo 5462(%r19),%r6 | |
ldil LR'.LC3,%r19 | |
stw %r10,-124(%r30) | |
ldo RR'.LC3(%r19),%r10 | |
ldil LR'.LC1,%r19 | |
stw %r9,-120(%r30) | |
ldo RR'.LC1(%r19),%r11 | |
stw %r7,-112(%r30) | |
ldo RR'.LC2(%r28),%r7 | |
ldil LR'.LC0,%r28 | |
stw %r4,-100(%r30) | |
ldo RR'.LC0(%r28),%r9 | |
ldi 101,%r4 | |
stw %r3,-96(%r30) | |
b .L6 | |
ldi 1,%r3 | |
.L2: | |
sub %r21,%r19,%r21 | |
sub %r21,%r20,%r28 | |
sh1addl %r28,%r28,%r28 | |
comb,= %r28,%r3,.L10 | |
and %r20,%r8,%r19 | |
sub %r23,%r19,%r23 | |
extrs %r23,30,31,%r28 | |
sub %r28,%r20,%r28 | |
sh2addl %r28,%r28,%r28 | |
comb,<> %r28,%r3,.L5 | |
copy %r7,%r26 | |
bl puts,%r2 | |
ldo 1(%r3),%r3 | |
.L12: | |
comb,= %r4,%r3,.L13 | |
ldw -148(%r30),%r2 | |
.L6: | |
ldil LR'.LC4,%r19 | |
.L14: | |
ldo RR'.LC4(%r19),%r19 | |
stws %r3,-16(%sp) | |
fldws -16(%sp),%fr23L | |
fldds 0(%r19),%fr22 | |
ldil LR'.LC5,%r19 | |
xmpyu %fr23L,%fr22R,%fr22 | |
ldo RR'.LC5(%r19),%r19 | |
fstds %fr22,-16(%sp) | |
ldws -16(%sp),%r28 | |
ldws -12(%sp),%r29 | |
fldds 0(%r19),%fr22 | |
ldil LR'.LC6,%r19 | |
xmpyu %fr23L,%fr22R,%fr22 | |
ldo RR'.LC6(%r19),%r19 | |
fstds %fr22,-16(%sp) | |
ldws -16(%sp),%r21 | |
ldws -12(%sp),%r22 | |
extrs %r3,0,1,%r20 | |
fldds 0(%r19),%fr22 | |
and %r20,%r5,%r19 | |
xmpyu %fr23L,%fr22R,%fr22 | |
sub %r28,%r19,%r28 | |
fstds %fr22,-16(%sp) | |
ldws -16(%sp),%r23 | |
ldws -12(%sp),%r24 | |
extrs %r28,28,29,%r28 | |
sub %r28,%r20,%r28 | |
zdep %r28,27,28,%r19 | |
sub %r19,%r28,%r19 | |
comb,<> %r19,%r3,.L2 | |
and %r20,%r6,%r19 | |
bl puts,%r2 | |
copy %r9,%r26 | |
ldo 1(%r3),%r3 | |
comb,<> %r4,%r3,.L14 | |
ldil LR'.LC4,%r19 | |
ldw -148(%r30),%r2 | |
.L13: | |
ldw -124(%r30),%r10 | |
ldw -120(%r30),%r9 | |
ldw -116(%r30),%r8 | |
ldw -112(%r30),%r7 | |
ldw -108(%r30),%r6 | |
ldw -104(%r30),%r5 | |
ldw -100(%r30),%r4 | |
ldw -96(%r30),%r3 | |
bv %r0(%r2) | |
ldwm -128(%r30),%r11 | |
.L5: | |
copy %r3,%r25 | |
bl printf,%r2 | |
copy %r10,%r26 | |
b .L12 | |
ldo 1(%r3),%r3 | |
.L10: | |
bl puts,%r2 | |
copy %r11,%r26 | |
b .L12 | |
ldo 1(%r3),%r3 | |
.EXIT | |
.PROCEND | |
.size main, .-main | |
.ident "GCC: (Debian 4.3.5-4) 4.3.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.pred.safe_across_calls p1-p5,p16-p63 | |
.section .rodata.str1.8,"aMS",@progbits,1 | |
.align 8 | |
.LC0: | |
stringz "FizzBuzz" | |
.align 8 | |
.LC1: | |
stringz "Fizz" | |
.align 8 | |
.LC2: | |
stringz "Buzz" | |
.align 8 | |
.LC3: | |
stringz "%d\n" | |
.text | |
.align 16 | |
.align 64 | |
.global main# | |
.type main#, @function | |
.proc main# | |
main: | |
.prologue 12, 33 | |
.mmb | |
.save ar.pfs, r34 | |
alloc r34 = ar.pfs, 0, 4, 2, 0 | |
adds r16 = -32, r12 | |
nop 0 | |
.mmi | |
adds r17 = -16, r12 | |
.fframe 48 | |
adds r12 = -48, r12 | |
.save rp, r33 | |
mov r33 = b0 | |
;; | |
.mlx | |
.save.f 0x1 | |
stf.spill [r16] = f2, 32 | |
movl r14 = -8608480567731124087 | |
.mmi | |
.save.f 0x2 | |
stf.spill [r17] = f3 | |
mov r35 = r1 | |
addl r32 = 1, r0 | |
;; | |
.mmi | |
nop 0 | |
.save.f 0x4 | |
stf.spill [r16] = f4 | |
.body | |
nop 0 | |
.mlx | |
setf.sig f4 = r14 | |
movl r14 = 6148914691236517206 | |
;; | |
.mlx | |
setf.sig f3 = r14 | |
movl r14 = 7378697629483820647 | |
;; | |
.mmi | |
setf.sig f2 = r14 | |
nop 0 | |
nop 0 | |
.align 32 | |
.L6: | |
.mii | |
nop 0 | |
sxt4 r14 = r32 | |
addl r36 = @ltoffx(.LC2), r1 | |
.mmi | |
mov r37 = r32 | |
;; | |
setf.sig f6 = r14 | |
shr r15 = r14, 63 | |
.mmi | |
nop 0 | |
ld8.mov r36 = [r36], .LC2 | |
nop 0 | |
;; | |
.mmf | |
nop 0 | |
nop 0 | |
xmpy.h f6 = f6, f4 | |
;; | |
.mmi | |
getf.sig r18 = f6 | |
setf.sig f6 = r14 | |
nop 0 | |
;; | |
.mfi | |
nop 0 | |
xmpy.h f6 = f6, f2 | |
add r18 = r18, r14 | |
;; | |
.mii | |
nop 0 | |
shr r18 = r18, 3 | |
nop 0 | |
;; | |
.mmi | |
getf.sig r16 = f6 | |
setf.sig f6 = r14 | |
nop 0 | |
;; | |
.mfi | |
nop 0 | |
xmpy.h f6 = f6, f3 | |
shr r16 = r16, 1 | |
;; | |
.mmi | |
sub r16 = r16, r15 | |
;; | |
shladd r16 = r16, 2, r16 | |
nop 0 | |
;; | |
.mmi | |
sub r16 = r14, r16 | |
;; | |
getf.sig r17 = f6 | |
cmp4.ne p10, p11 = 0, r16 | |
;; | |
.mmi | |
sub r17 = r17, r15 | |
nop 0 | |
sub r15 = r18, r15 | |
;; | |
.mii | |
shladd r17 = r17, 1, r17 | |
shladd r18 = r15, 4, r0 | |
;; | |
sub r17 = r14, r17 | |
.mmi | |
sub r15 = r18, r15 | |
;; | |
cmp4.ne p8, p9 = 0, r17 | |
cmp4.ne p6, p7 = r14, r15 | |
.bbb | |
(p7) br.cond.dpnt .L10 | |
(p9) br.cond.dpnt .L11 | |
(p10) br.cond.dptk .L5 | |
.mib | |
adds r32 = 1, r32 | |
nop 0 | |
br.call.sptk.many b0 = puts# | |
;; | |
.mib | |
mov r1 = r35 | |
cmp4.ne p6, p7 = 101, r32 | |
(p6) br.cond.dptk .L6 | |
.L12: | |
.mmi | |
adds r18 = 16, r12 | |
adds r19 = 32, r12 | |
mov ar.pfs = r34 | |
;; | |
.mmi | |
nop 0 | |
ldf.fill f2 = [r18], 32 | |
mov b0 = r33 | |
.mmi | |
nop 0 | |
ldf.fill f3 = [r19] | |
nop 0 | |
;; | |
.mib | |
ldf.fill f4 = [r18] | |
.label_state 1 | |
.restore sp | |
adds r12 = 48, r12 | |
br.ret.sptk.many b0 | |
.L10: | |
.body | |
.copy_state 1 | |
.mmi | |
addl r36 = @ltoffx(.LC0), r1 | |
nop 0 | |
adds r32 = 1, r32 | |
;; | |
.mib | |
ld8.mov r36 = [r36], .LC0 | |
nop 0 | |
br.call.sptk.many b0 = puts# | |
;; | |
.mib | |
mov r1 = r35 | |
cmp4.ne p6, p7 = 101, r32 | |
(p6) br.cond.dptk .L6 | |
.mib | |
nop 0 | |
nop 0 | |
br .L12 | |
;; | |
.L5: | |
.mmi | |
addl r36 = @ltoffx(.LC3), r1 | |
nop 0 | |
adds r32 = 1, r32 | |
;; | |
.mib | |
ld8.mov r36 = [r36], .LC3 | |
nop 0 | |
br.call.sptk.many b0 = printf# | |
;; | |
.mib | |
mov r1 = r35 | |
cmp4.ne p6, p7 = 101, r32 | |
(p6) br.cond.dptk .L6 | |
.mib | |
nop 0 | |
nop 0 | |
br .L12 | |
;; | |
.L11: | |
.mmi | |
addl r36 = @ltoffx(.LC1), r1 | |
nop 0 | |
adds r32 = 1, r32 | |
;; | |
.mib | |
ld8.mov r36 = [r36], .LC1 | |
nop 0 | |
br.call.sptk.many b0 = puts# | |
;; | |
.mib | |
mov r1 = r35 | |
cmp4.ne p6, p7 = 101, r32 | |
(p6) br.cond.dptk .L6 | |
.mib | |
nop 0 | |
nop 0 | |
br .L12 | |
.endp main# | |
.ident "GCC: (Debian 4.4.5-8) 4.4.5" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file 1 "fizzbuzz.c" | |
.section .mdebug.abi32 | |
.previous | |
.gnu_attribute 4, 1 | |
.abicalls | |
.section .rodata.str1.4,"aMS",@progbits,1 | |
.align 2 | |
$LC0: | |
.ascii "FizzBuzz\000" | |
.align 2 | |
$LC1: | |
.ascii "Fizz\000" | |
.align 2 | |
$LC2: | |
.ascii "Buzz\000" | |
.align 2 | |
$LC3: | |
.ascii "%d\012\000" | |
.text | |
.align 2 | |
.globl main | |
.ent main | |
.type main, @function | |
main: | |
.set nomips16 | |
.frame $sp,64,$31 # vars= 0, regs= 10/0, args= 16, gp= 8 | |
.mask 0xc0ff0000,-4 | |
.fmask 0x00000000,0 | |
.set noreorder | |
.set nomacro | |
lui $28,%hi(__gnu_local_gp) | |
addiu $sp,$sp,-64 | |
addiu $28,$28,%lo(__gnu_local_gp) | |
sw $31,60($sp) | |
sw $fp,56($sp) | |
sw $23,52($sp) | |
sw $22,48($sp) | |
sw $21,44($sp) | |
sw $20,40($sp) | |
sw $19,36($sp) | |
sw $18,32($sp) | |
sw $17,28($sp) | |
sw $16,24($sp) | |
.cprestore 16 | |
lui $2,%hi($LC3) | |
lui $3,%hi($LC2) | |
addiu $23,$2,%lo($LC3) | |
addiu $21,$3,%lo($LC2) | |
lui $2,%hi($LC1) | |
lui $3,%hi($LC0) | |
addiu $fp,$2,%lo($LC1) | |
addiu $22,$3,%lo($LC0) | |
li $16,1 # 0x1 | |
li $17,15 # 0xf | |
li $18,3 # 0x3 | |
li $20,5 # 0x5 | |
b $L6 | |
li $19,101 # 0x65 | |
$L2: | |
bne $18,$0,1f | |
div $0,$16,$18 | |
break 7 | |
1: | |
mfhi $2 | |
beq $2,$0,$L10 | |
move $4,$21 | |
bne $20,$0,1f | |
div $0,$16,$20 | |
break 7 | |
1: | |
lw $25,%call16(puts)($28) | |
lw $3,%call16(printf)($28) | |
mfhi $2 | |
bne $2,$0,$L5 | |
move $5,$16 | |
jalr $25 | |
addiu $16,$16,1 | |
lw $28,16($sp) | |
$L12: | |
beq $16,$19,$L11 | |
nop | |
$L6: | |
bne $17,$0,1f | |
div $0,$16,$17 | |
break 7 | |
1: | |
mfhi $2 | |
bne $2,$0,$L2 | |
move $4,$22 | |
lw $25,%call16(puts)($28) | |
nop | |
jalr $25 | |
addiu $16,$16,1 | |
lw $28,16($sp) | |
bne $16,$19,$L6 | |
nop | |
$L11: | |
lw $31,60($sp) | |
lw $fp,56($sp) | |
lw $23,52($sp) | |
lw $22,48($sp) | |
lw $21,44($sp) | |
lw $20,40($sp) | |
lw $19,36($sp) | |
lw $18,32($sp) | |
lw $17,28($sp) | |
lw $16,24($sp) | |
j $31 | |
addiu $sp,$sp,64 | |
$L5: | |
move $25,$3 | |
jalr $25 | |
move $4,$23 | |
lw $28,16($sp) | |
b $L12 | |
addiu $16,$16,1 | |
$L10: | |
lw $25,%call16(puts)($28) | |
nop | |
jalr $25 | |
move $4,$fp | |
lw $28,16($sp) | |
b $L12 | |
addiu $16,$16,1 | |
.set macro | |
.set reorder | |
.end main | |
.ident "GCC: (Debian 4.3.5-4) 4.3.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.gnu_attribute 4, 1 | |
.gnu_attribute 8, 1 | |
.section ".text" | |
.align 2 | |
.globl main | |
.type main, @function | |
main: | |
mflr 0 | |
stwu 1,-48(1) | |
lis 9,0x5555 | |
lis 11,.LC2@ha | |
stw 29,36(1) | |
ori 29,9,21846 | |
stw 0,52(1) | |
lis 9,.LC3@ha | |
lis 0,0x8888 | |
stw 25,20(1) | |
stw 28,32(1) | |
la 25,.LC3@l(9) | |
stw 30,40(1) | |
la 28,.LC2@l(11) | |
ori 30,0,34953 | |
lis 9,.LC1@ha | |
lis 0,0x6666 | |
lis 11,.LC0@ha | |
stw 24,16(1) | |
la 24,.LC1@l(9) | |
stw 26,24(1) | |
la 26,.LC0@l(11) | |
stw 27,28(1) | |
ori 27,0,26215 | |
stw 31,44(1) | |
li 31,1 | |
b .L6 | |
.L2: | |
mulhw 0,31,29 | |
subf 0,9,0 | |
mulli 0,0,3 | |
cmpw 7,31,0 | |
beq- 7,.L10 | |
mulhw 0,31,27 | |
mr 3,28 | |
mr 4,31 | |
srawi 0,0,1 | |
subf 0,9,0 | |
mulli 0,0,5 | |
cmpw 7,31,0 | |
bne- 7,.L5 | |
bl puts | |
.L3: | |
cmpwi 7,31,100 | |
addi 31,31,1 | |
beq- 7,.L11 | |
.L6: | |
mulhw 0,31,30 | |
srawi 9,31,31 | |
add 0,0,31 | |
srawi 0,0,3 | |
subf 0,9,0 | |
mulli 0,0,15 | |
cmpw 7,31,0 | |
bne+ 7,.L2 | |
mr 3,26 | |
bl puts | |
cmpwi 7,31,100 | |
addi 31,31,1 | |
bne+ 7,.L6 | |
.L11: | |
lwz 0,52(1) | |
lwz 24,16(1) | |
mtlr 0 | |
lwz 25,20(1) | |
lwz 26,24(1) | |
lwz 27,28(1) | |
lwz 28,32(1) | |
lwz 29,36(1) | |
lwz 30,40(1) | |
lwz 31,44(1) | |
addi 1,1,48 | |
blr | |
.L5: | |
mr 3,25 | |
crxor 6,6,6 | |
bl printf | |
b .L3 | |
.L10: | |
mr 3,24 | |
bl puts | |
b .L3 | |
.size main, .-main | |
.section .rodata.str1.4,"aMS",@progbits,1 | |
.align 2 | |
.LC0: | |
.string "FizzBuzz" | |
.zero 3 | |
.LC1: | |
.string "Fizz" | |
.zero 3 | |
.LC2: | |
.string "Buzz" | |
.zero 3 | |
.LC3: | |
.string "%d\n" | |
.ident "GCC: (Debian 4.3.5-4) 4.3.5" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.section .rodata.str1.2,"aMS",@progbits,1 | |
.align 2 | |
.LC0: | |
.string "FizzBuzz" | |
.align 2 | |
.LC3: | |
.string "Fizz" | |
.align 2 | |
.LC5: | |
.string "Buzz" | |
.align 2 | |
.LC7: | |
.string "%d\n" | |
.text | |
.align 4 | |
.globl main | |
.type main, @function | |
main: | |
stm %r6,%r15,24(%r15) | |
basr %r13,0 | |
.L12: | |
ahi %r15,-96 | |
l %r6,.L13-.L12(%r13) | |
lhi %r12,1 | |
lhi %r10,15 | |
lhi %r9,3 | |
lhi %r8,5 | |
lr %r7,%r6 | |
lhi %r11,100 | |
.L6: | |
lr %r2,%r12 | |
lhi %r3,0 | |
srda %r2,32 | |
dr %r2,%r10 | |
ltr %r2,%r2 | |
lr %r4,%r12 | |
lr %r0,%r12 | |
lhi %r5,0 | |
lhi %r1,0 | |
je .L10 | |
srda %r4,32 | |
dr %r4,%r9 | |
ltr %r4,%r4 | |
je .L11 | |
srda %r0,32 | |
dr %r0,%r8 | |
ltr %r0,%r0 | |
lr %r3,%r12 | |
jne .L5 | |
l %r2,.L14-.L12(%r13) | |
basr %r14,%r6 | |
.L3: | |
ahi %r12,1 | |
brct %r11,.L6 | |
l %r4,152(%r15) | |
lm %r6,%r15,120(%r15) | |
br %r4 | |
.L10: | |
l %r2,.L15-.L12(%r13) | |
basr %r14,%r7 | |
j .L3 | |
.L5: | |
l %r1,.L16-.L12(%r13) | |
l %r2,.L17-.L12(%r13) | |
basr %r14,%r1 | |
j .L3 | |
.L11: | |
l %r1,.L13-.L12(%r13) | |
l %r2,.L18-.L12(%r13) | |
basr %r14,%r1 | |
j .L3 | |
.align 4 | |
.L18: | |
.long .LC3 | |
.L17: | |
.long .LC7 | |
.L16: | |
.long printf | |
.L15: | |
.long .LC0 | |
.L14: | |
.long .LC5 | |
.L13: | |
.long puts | |
.align 2 | |
.size main, .-main | |
.ident "GCC: (Debian 4.3.5-4) 4.3.5" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.section .rodata.str1.8,"aMS",@progbits,1 | |
.align 8 | |
.LLC0: | |
.asciz "FizzBuzz" | |
.align 8 | |
.LLC1: | |
.asciz "Fizz" | |
.align 8 | |
.LLC2: | |
.asciz "Buzz" | |
.align 8 | |
.LLC3: | |
.asciz "%d\n" | |
.section ".text" | |
.align 4 | |
.global main | |
.type main, #function | |
.proc 04 | |
main: | |
save %sp, -112, %sp | |
sethi %hi(-2004318208), %g1 | |
sethi %hi(1431655424), %g2 | |
or %g1, 137, %l0 | |
sethi %hi(1717986304), %g1 | |
or %g2, 342, %l1 | |
or %g1, 615, %l2 | |
sethi %hi(.LLC3), %g2 | |
sethi %hi(.LLC2), %g1 | |
or %g2, %lo(.LLC3), %l5 | |
or %g1, %lo(.LLC2), %l4 | |
sethi %hi(.LLC1), %g2 | |
sethi %hi(.LLC0), %g1 | |
or %g2, %lo(.LLC1), %l6 | |
or %g1, %lo(.LLC0), %l3 | |
ba,pt %xcc, .LL6 | |
mov 1, %i0 | |
.LL2: | |
smul %i0, %l1, %g0 | |
rd %y, %g1 | |
sub %g1, %g3, %g1 | |
add %g1, %g1, %g2 | |
add %g2, %g1, %g2 | |
cmp %i0, %g2 | |
be,pn %icc, .LL10 | |
nop | |
smul %i0, %l2, %g0 | |
rd %y, %g2 | |
sra %g2, 1, %g2 | |
sub %g2, %g3, %g2 | |
sll %g2, 2, %g1 | |
add %g1, %g2, %g1 | |
cmp %i0, %g1 | |
bne,pt %icc, .LL5 | |
mov %i0, %o1 | |
call puts, 0 | |
mov %l4, %o0 | |
add %i0, 1, %i0 | |
.LL12: | |
cmp %i0, 101 | |
be,pn %icc, .LL14 | |
nop | |
.LL6: | |
sra %i0, 31, %g3 | |
.LL13: | |
smul %i0, %l0, %g0 | |
rd %y, %g1 | |
add %g1, %i0, %g1 | |
sra %g1, 3, %g1 | |
sub %g1, %g3, %g1 | |
sll %g1, 4, %g2 | |
sub %g2, %g1, %g2 | |
cmp %i0, %g2 | |
bne,pt %icc, .LL2 | |
nop | |
call puts, 0 | |
mov %l3, %o0 | |
add %i0, 1, %i0 | |
cmp %i0, 101 | |
bne,pt %icc, .LL13 | |
sra %i0, 31, %g3 | |
.LL14: | |
return %i7+8 | |
nop | |
.LL5: | |
call printf, 0 | |
mov %l5, %o0 | |
ba,pt %xcc, .LL12 | |
add %i0, 1, %i0 | |
.LL10: | |
call puts, 0 | |
mov %l6, %o0 | |
ba,pt %xcc, .LL12 | |
add %i0, 1, %i0 | |
.size main, .-main | |
.ident "GCC: (Debian 4.3.5-4) 4.3.5" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.section .rodata.str1.1,"aMS",@progbits,1 | |
.LC0: | |
.string "FizzBuzz" | |
.LC1: | |
.string "Fizz" | |
.LC2: | |
.string "Buzz" | |
.LC3: | |
.string "%d\n" | |
.section .text.startup,"ax",@progbits | |
.p2align 4,,15 | |
.globl main | |
.type main, @function | |
main: | |
pushq %rbp | |
movl $-2004318071, %ebp | |
pushq %rbx | |
movl $1, %ebx | |
subq $8, %rsp | |
jmp .L6 | |
.p2align 4,,10 | |
.p2align 3 | |
.L2: | |
movl $1431655766, %edx | |
movl %ebx, %eax | |
imull %edx | |
subl %ecx, %edx | |
leal (%rdx,%rdx,2), %edx | |
cmpl %edx, %ebx | |
je .L9 | |
movl $1717986919, %edx | |
movl %ebx, %eax | |
imull %edx | |
sarl %edx | |
subl %ecx, %edx | |
leal (%rdx,%rdx,4), %edx | |
cmpl %edx, %ebx | |
jne .L5 | |
movl $.LC2, %edi | |
call puts | |
.L3: | |
addl $1, %ebx | |
cmpl $101, %ebx | |
je .L10 | |
.L6: | |
movl %ebx, %eax | |
movl %ebx, %ecx | |
imull %ebp | |
sarl $31, %ecx | |
addl %ebx, %edx | |
sarl $3, %edx | |
subl %ecx, %edx | |
movl %edx, %eax | |
sall $4, %eax | |
subl %edx, %eax | |
cmpl %eax, %ebx | |
jne .L2 | |
movl $.LC0, %edi | |
addl $1, %ebx | |
call puts | |
cmpl $101, %ebx | |
jne .L6 | |
.L10: | |
addq $8, %rsp | |
popq %rbx | |
popq %rbp | |
ret | |
.p2align 4,,10 | |
.p2align 3 | |
.L5: | |
movl %ebx, %edx | |
movl $.LC3, %esi | |
movl $1, %edi | |
xorl %eax, %eax | |
call __printf_chk | |
jmp .L3 | |
.p2align 4,,10 | |
.p2align 3 | |
.L9: | |
movl $.LC1, %edi | |
call puts | |
.p2align 4,,3 | |
jmp .L3 | |
.size main, .-main | |
.ident "GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.intel_syntax noprefix | |
.section .rodata.str1.1,"aMS",@progbits,1 | |
.LC0: | |
.string "FizzBuzz" | |
.LC1: | |
.string "Fizz" | |
.LC2: | |
.string "Buzz" | |
.LC3: | |
.string "%d\n" | |
.section .text.startup,"ax",@progbits | |
.p2align 4,,15 | |
.globl main | |
.type main, @function | |
main: | |
push rbp | |
mov ebp, -2004318071 | |
push rbx | |
mov ebx, 1 | |
sub rsp, 8 | |
jmp .L6 | |
.p2align 4,,10 | |
.p2align 3 | |
.L2: | |
mov edx, 1431655766 | |
mov eax, ebx | |
imul edx | |
sub edx, ecx | |
lea edx, [rdx+rdx*2] | |
cmp ebx, edx | |
je .L9 | |
mov edx, 1717986919 | |
mov eax, ebx | |
imul edx | |
sar edx | |
sub edx, ecx | |
lea edx, [rdx+rdx*4] | |
cmp ebx, edx | |
jne .L5 | |
mov edi, OFFSET FLAT:.LC2 | |
call puts | |
.L3: | |
add ebx, 1 | |
cmp ebx, 101 | |
je .L10 | |
.L6: | |
mov eax, ebx | |
mov ecx, ebx | |
imul ebp | |
sar ecx, 31 | |
add edx, ebx | |
sar edx, 3 | |
sub edx, ecx | |
mov eax, edx | |
sal eax, 4 | |
sub eax, edx | |
cmp ebx, eax | |
jne .L2 | |
mov edi, OFFSET FLAT:.LC0 | |
add ebx, 1 | |
call puts | |
cmp ebx, 101 | |
jne .L6 | |
.L10: | |
add rsp, 8 | |
pop rbx | |
pop rbp | |
ret | |
.p2align 4,,10 | |
.p2align 3 | |
.L5: | |
mov edx, ebx | |
mov esi, OFFSET FLAT:.LC3 | |
mov edi, 1 | |
xor eax, eax | |
call __printf_chk | |
jmp .L3 | |
.p2align 4,,10 | |
.p2align 3 | |
.L9: | |
mov edi, OFFSET FLAT:.LC1 | |
call puts | |
.p2align 4,,3 | |
jmp .L3 | |
.size main, .-main | |
.ident "GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.section .rodata.str1.1,"aMS",@progbits,1 | |
.LC0: | |
.string "FizzBuzz" | |
.LC1: | |
.string "Fizz" | |
.LC2: | |
.string "Buzz" | |
.LC3: | |
.string "%d\n" | |
.section .text.startup,"ax",@progbits | |
.p2align 4,,15 | |
.globl main | |
.type main, @function | |
main: | |
pushl %ebp | |
movl %esp, %ebp | |
pushl %edi | |
movl $1431655766, %edi | |
pushl %esi | |
movl $-2004318071, %esi | |
pushl %ebx | |
movl $1, %ebx | |
andl $-16, %esp | |
subl $16, %esp | |
jmp .L6 | |
.p2align 4,,7 | |
.p2align 3 | |
.L2: | |
movl %ebx, %eax | |
imull %edi | |
subl %ecx, %edx | |
leal (%edx,%edx,2), %eax | |
cmpl %eax, %ebx | |
je .L9 | |
movl %ebx, %eax | |
movl $1717986919, %edx | |
imull %edx | |
sarl %edx | |
subl %ecx, %edx | |
leal (%edx,%edx,4), %eax | |
cmpl %eax, %ebx | |
jne .L5 | |
movl $.LC2, (%esp) | |
call puts | |
.L3: | |
addl $1, %ebx | |
cmpl $101, %ebx | |
je .L10 | |
.L6: | |
movl %ebx, %eax | |
movl %ebx, %ecx | |
imull %esi | |
sarl $31, %ecx | |
addl %ebx, %edx | |
sarl $3, %edx | |
subl %ecx, %edx | |
movl %edx, %eax | |
sall $4, %eax | |
subl %edx, %eax | |
cmpl %eax, %ebx | |
jne .L2 | |
addl $1, %ebx | |
movl $.LC0, (%esp) | |
call puts | |
cmpl $101, %ebx | |
jne .L6 | |
.L10: | |
leal -12(%ebp), %esp | |
popl %ebx | |
popl %esi | |
popl %edi | |
popl %ebp | |
ret | |
.p2align 4,,7 | |
.p2align 3 | |
.L5: | |
movl %ebx, 8(%esp) | |
movl $.LC3, 4(%esp) | |
movl $1, (%esp) | |
call __printf_chk | |
jmp .L3 | |
.p2align 4,,7 | |
.p2align 3 | |
.L9: | |
movl $.LC1, (%esp) | |
call puts | |
jmp .L3 | |
.size main, .-main | |
.ident "GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1" | |
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.file "fizzbuzz.c" | |
.intel_syntax noprefix | |
.section .rodata.str1.1,"aMS",@progbits,1 | |
.LC0: | |
.string "FizzBuzz" | |
.LC1: | |
.string "Fizz" | |
.LC2: | |
.string "Buzz" | |
.LC3: | |
.string "%d\n" | |
.section .text.startup,"ax",@progbits | |
.p2align 4,,15 | |
.globl main | |
.type main, @function | |
main: | |
push ebp | |
mov ebp, esp | |
push edi | |
mov edi, 1431655766 | |
push esi | |
mov esi, -2004318071 | |
push ebx | |
mov ebx, 1 | |
and esp, -16 | |
sub esp, 16 | |
jmp .L6 | |
.p2align 4,,7 | |
.p2align 3 | |
.L2: | |
mov eax, ebx | |
imul edi | |
sub edx, ecx | |
lea eax, [edx+edx*2] | |
cmp ebx, eax | |
je .L9 | |
mov eax, ebx | |
mov edx, 1717986919 | |
imul edx | |
sar edx | |
sub edx, ecx | |
lea eax, [edx+edx*4] | |
cmp ebx, eax | |
jne .L5 | |
mov DWORD PTR [esp], OFFSET FLAT:.LC2 | |
call puts | |
.L3: | |
add ebx, 1 | |
cmp ebx, 101 | |
je .L10 | |
.L6: | |
mov eax, ebx | |
mov ecx, ebx | |
imul esi | |
sar ecx, 31 | |
add edx, ebx | |
sar edx, 3 | |
sub edx, ecx | |
mov eax, edx | |
sal eax, 4 | |
sub eax, edx | |
cmp ebx, eax | |
jne .L2 | |
add ebx, 1 | |
mov DWORD PTR [esp], OFFSET FLAT:.LC0 | |
call puts | |
cmp ebx, 101 | |
jne .L6 | |
.L10: | |
lea esp, [ebp-12] | |
pop ebx | |
pop esi | |
pop edi | |
pop ebp | |
ret | |
.p2align 4,,7 | |
.p2align 3 | |
.L5: | |
mov DWORD PTR [esp+8], ebx | |
mov DWORD PTR [esp+4], OFFSET FLAT:.LC3 | |
mov DWORD PTR [esp], 1 | |
call __printf_chk | |
jmp .L3 | |
.p2align 4,,7 | |
.p2align 3 | |
.L9: | |
mov DWORD PTR [esp], OFFSET FLAT:.LC1 | |
call puts | |
jmp .L3 | |
.size main, .-main | |
.ident "GCC: (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1" | |
.section .note.GNU-stack,"",@progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment