muah ha ha ha.
Oct. 2nd, 2001 07:16 pmNot that you'd understand this, or anything...but here's a program in MIPS assembly to take a keyboard decimal number and turn it into a hexadecimal number. ph33r.
.data prompt: .asciiz "Give me a number\n" buffer: .asciiz "0x " .globl main .text main: li $v0,4 la $a0,prompt syscall li $v0,5 syscall move $a0,$v0 la $a1, buffer addi $a1,$a1, 10 li $s1,57 li $t0,8 hexloop: andi $t1, $a0, 15 addi $t1, $t1, 0x30 ble $t1,$s1, here addi $t1,$t1,7 here: sb $t1, 0($a1) addi $a1,$a1,-1 srl $a0,$a0,4 addi $t0,$t0,-1 bgtz $t0, hexloop li $v0,4 la $a0,buffer syscall li $v0,10 syscall
Now...to incorporate it into my first programming assignment...
Re: You are my personal goddess.
Date: 2001-10-03 06:07 am (UTC)bgtz == branch if greater than zero.
Close, Shad. :)
la is "load address", it's how something like a text string is loaded into memory. And the "0x " is definitely a text string. I'm adding more to that string, and then outputting.
-kat