Saturday, May 9, 2009

If I were to translate this program from c: #include <stdio.h>#include <stdlib.h>int main ( ) { int a;

Disassembly of section .text:





0000000000000000 %26lt;main%26gt;:


0: 3c1c0000 lui $gp,0x0


4: 279c0000 addiu $gp,$gp,0


8: 0399e021 addu $gp,$gp,$t9


c: 27bdffc0 addiu $sp,$sp,-64


10: afbc0010 sw $gp,16($sp)


14: afbf003c sw $ra,60($sp)


18: afbc0038 sw $gp,56($sp)


1c: afb10034 sw $s1,52($sp)


20: afb00030 sw $s0,48($sp)


24: 27a40020 addiu $a0,$sp,32


28: 2405000a li $a1,10


2c: 8f860000 lw $a2,0($gp)


30: 8cc60000 lw $a2,0($a2)


34: 8f990000 lw $t9,0($gp)


38: 0320f809 jalr $t9 #fgets1


3c: 00000000 nop


40: 8fbc0010 lw $gp,16($sp)


44: 27b00020 addiu $s0,$sp,32


48: 02002021 move $a0,$s0


4c: 00002821 move $a1,$zero


50: 2406000a li $a2,10


54: 00003821 move $a3,$zero


58: 8f990000 lw $t9,0($gp)


5c: 0320f809 jalr $t9 #atoi1


60: 00000000 nop


64: 8fbc0010 lw $gp,16($sp)


68: 00408821 move $s1,$v0 #s1=a


6c: 02002021 move $a0,$s0


70: 2405000a li $a1,10


74: 8f860000 lw $a2,0($gp)


78: 8cc60000 lw $a2,0($a2)


7c: 8f990000 lw $t9,0($gp)


80: 0320f809 jalr $t9 #fgets2


84: 00000000 nop


88: 8fbc0010 lw $gp,16($sp)


8c: 02002021 move $a0,$s0


90: 00002821 move $a1,$zero


94: 2406000a li $a2,10


98: 00003821 move $a3,$zero


9c: 8f990000 lw $t9,0($gp)


a0: 0320f809 jalr $t9 #atoi2


a4: 00000000 nop


a8: 8fbc0010 lw $gp,16($sp)


ac: 00402021 move $a0,$v0 #a0 is b


b0: 00003021 move $a2,$zero


b4: 1a20000d blez $s1,ec %26lt;main+0xec%26gt;


b8: 00002821 move $a1,$zero


bc: 00000000 nop


c0: 18800006 blez $a0,dc %26lt;main+0xdc%26gt;


c4: 00001821 move $v1,$zero


c8: 24a50001 addiu $a1,$a1,1


cc: 24630001 addiu $v1,$v1,1


d0: 0064102a slt $v0,$v1,$a0


d4: 1440fffc bnez $v0,c8 %26lt;main+0xc8%26gt;


d8: 00000000 nop


dc: 24c60001 addiu $a2,$a2,1


e0: 00d1102a slt $v0,$a2,$s1


e4: 1440fff6 bnez $v0,c0 %26lt;main+0xc0%26gt;


e8: 00000000 nop


ec: 8f840000 lw $a0,0($gp)


f0: 24840000 addiu $a0,$a0,0


f4: 8f990000 lw $t9,0($gp)


f8: 0320f809 jalr $t9 #


fc: 00000000 nop


100: 8fbc0010 lw $gp,16($sp)


104: 00001021 move $v0,$zero


108: 8fbf003c lw $ra,60($sp)


10c: 8fb10034 lw $s1,52($sp)


110: 8fb00030 lw $s0,48($sp)


114: 03e00008 jr $ra


118: 27bd0040 addiu $sp,$sp,64


11c: 00000000 nop

If I were to translate this program from c: #include %26lt;stdio.h%26gt;#include %26lt;stdlib.h%26gt;int main ( ) { int a;
THE ANSWER IS ( WHAT !!!!!!!!!) JOKING I HAVE NO CLUE

marigold

No comments:

Post a Comment