Can anyone please fix this program for me and send it to my e-mail! i'd appreciate it

chinulatinu@yahoo.com


thnx
Posted on 2004-10-05 22:15:20 by BabyGirl
hi
ur link is not wrking.... atleast on my pc
please give another link and zip it with winzip
before u upload it
thank you
nickdigital
Posted on 2004-10-06 09:49:38 by nickdigital
please if anyone can do this for me within the next 12 hours i'd appreciate it : ((
Posted on 2004-10-06 12:11:49 by BabyGirl
People shouldn't be downloading MS Word documents from unknown sources. Maybe you could post your file in another format (like .rtf, .pdf, or some other)?
Posted on 2004-10-06 13:32:26 by QvasiModo
What kind of assembly language is that?
Posted on 2004-10-06 13:38:42 by Greg
this assembly program runs by PC spim


# This program converts between hex and single precision IEEE
# floating point numbers. The read_int syscall apparently does
# not understand inputing hex integers so this program converts
# hex strings (without the leading 0x) to an integer and determines
# the corresponding float value. Given a floating value, it will
# display the hex string that corresponds to that value. When a string
# of hex digits is entered, a 0x0a is at the end of that string prior
# to the terminating 0x00 and is thus used to find the end of the string.
# No error checking is performed on the hex strings that are input
# although either upper (A-F) or lower (a-f) case will work. Any
# mal-formed hex input will result in garbage.

.data
.align 2
temp: .space 4
buffer: .space 40
p1: .asciiz "Enter 1 to convert from hex to float.\n"
p2: .asciiz "Enter 2 to convert from float to hex.\n"
p3: .asciiz "Enter the bit pattern (in hex without 0x)\n:"
p4: .asciiz "Enter the float value to be converted\n:"
ans: .asciiz "The converted value is: "
nl: .asciiz "\n\n"

.text
.globl main # main must always be global

main: # start by printing the menu
li $v0, 4 # system call code for print_str
la $a0, p1 # address of string to print
syscall # print the first prompt
li $v0, 4 # system call code for print_str
la $a0, p2 # address of string to print
syscall # print the second prompt

# get user's menu choice
li $v0, 5 # system call code for read_int
syscall # read the integer
move $t0, $v0 # and store it

li $t1, 1 # prepare to compare selection to 1
beq $t0, $t1, one # branch to label one if convert from hex to float

li $t1, 2 # prepare to compare selection to 2
beq $t0, $t1, two # branch to label two if convert from float to hex

# bad user selection, loop back
j main

one: # begin process of converting from hex to float
li $v0, 4 # system call code for print_str
la $a0, p3 # address of string to print
syscall # print the "get hex" prompt

# get user's hex value
li $v0, 8 # system call code for read_string
la $a0, buffer # address to put string
li $a1, 40 # size of buffer
syscall # read the integer
li $t2, 0 # used to accumulate numeric value

loop: lb $t3, 0($a0) # get a character with load byte instruction
beq $t3, 0x0a, done # is it a newline character?
bgt $t3, '9', letr1 # branch if character is a letter
sub $t4, $t3, '0' # get value of numeric digit
j hexmul

letr1: ble $t3, 'F', letr2 # upper case hex digit?
sub $t3, $t3, 32 # convert to uppercase

letr2: sub $t4, $t3, 'A' # get value of letter digit
add $t4, $t4, 10

hexmul: mul $t2, $t2, 16 # shift previous value left
addu $t2, $t2, $t4 # and add in new digit
add $a0, $a0, 1 # go to next character of hex string
j loop

done: # there is no way to move a value directly from a general purpose
# register to a floating point register. We must temporarily
# store it to memory and then read into a float register to do this.
sw $t2, temp # store computed value to memory
l.s $f12, temp # and read it into a float register

# print it as a float
li $v0, 4 # system call code for print_str
la $a0, ans # address of string to print
syscall # print the answer prompt

li $v0, 2 # system call code for print_float
syscall # print the floating number in $f12

li $v0, 4 # system call code for print_str
la $a0, nl # address of string to print
syscall # print the new lines

j main # ready to solve another problem

two: # begin process of converting from float to hex
li $v0, 4 # system call code for print_str
la $a0, p4 # address of string to print
syscall # print the "get float" prompt

li $v0, 6 # system call code for read_float
syscall # result is in $f0

li $v0, 4 # system call code for print_str
la $a0, ans # address of string to print
syscall # print the answer prompt

# to move the value just received to a general purpose register, we
# must first store it to memory, then load it to a general purpose
# register.
s.s $f0, temp # store the value to memory
lw $t2, temp # get float bits to $t2
li $t3, 0xf0000000 # masking constant
li $t9, 8 # number of characters to print

loop1: and $t4, $t2, $t3 # use mask to get upper 4 bits
srl $t4, $t4, 28 # move these to lsb positions
bgt $t4, 9, let # branch if this hex digit is letter
add $t4, $t4, '0' # make digit an ascii char (add ascii of zero)
j fin

let: add $t4, $t4, -10 # convert >9 to ascii char
add $t4, $t4, 'A'

fin: # First fill a word with nulls, then copy the char to the first byte.
# The result is a string of one character and then a null
sw $zero, temp # make word of nulls
sb $t4, temp # our char goes to the first byte of this word.

li $v0, 4 # now print it
la $a0, temp
syscall # print a hex digit

mul $t2, $t2, 16
add $t9, $t9, -1 # one more done. is there another character
# to process?
bgtz $t9, loop1

li $v0, 4 # system call code for print_str
la $a0, nl # address of string to print
syscall # print the new lines

j main # ready to solve another problem

# will never get to the following statement. This program is an infinite loop!
jr $31 # return to system
Posted on 2004-10-06 14:00:07 by BabyGirl
I'm sorry, don't know this language... :(
Posted on 2004-10-06 15:15:09 by QvasiModo
That's MIPS R3000 assembly.
What you have to remember is that when you use branch instructions, the following instruction will always be executed. So you have to order the instructions appropriately, and use NOPs when necessary.
Anothing thing that must be kept in mind is when you use a load instruction, the following instruction may not use the loaded register.
Posted on 2004-10-06 17:26:14 by Sephiroth3
Hmm, all right, I fixed it up a bit. Maybe it will work now?


.data
.align 2
temp: .space 4
buffer: .space 40
p1: .asciiz "Enter 1 to convert from hex to float.\n"
p2: .asciiz "Enter 2 to convert from float to hex.\n"
p3: .asciiz "Enter the bit pattern (in hex without 0x)\n:"
p4: .asciiz "Enter the float value to be converted\n:"
ans: .asciiz "The converted value is: "
nl: .asciiz "\n\n"

.text
.globl main # main must always be global

main: # start by printing the menu
li $v0, 4 # system call code for print_str
main_2:
la $a0, p1 # address of string to print
syscall # print the first prompt
li $v0, 4 # system call code for print_str
la $a0, p2 # address of string to print
syscall # print the second prompt

# get user's menu choice
li $v0, 5 # system call code for read_int
syscall # read the integer
li $t1, 2 # prepare to compare selection to 2
beq $v0, $t1, two # branch to label two if convert from float to hex
li $t1, 1 # prepare to compare selection to 1
bne $v0, $t1, main_2 # bad user selection, loop back
li $v0, 4 # system call code for print_str

# begin process of converting from hex to float
la $a0, p3 # address of string to print
syscall # print the "get hex" prompt

# get user's hex value
li $v0, 8 # system call code for read_string
la $a0, buffer # address to put string
li $a1, 40 # size of buffer
syscall # read the integer
li $t2, 0 # used to accumulate numeric value

loop: lb $t3, 0($a0) # get a character with load byte instruction
li $t4,10
beq $t3, $t4, done # is it a newline character?
sltiu $v0, $t3, 58
bne $v0,$zr, hexmul # branch if character is a letter
addi $t3, $t3, -48 # get value of numeric digit
andi $t3, $t3, 223 # convert to uppercase
addi $t3, $t3, -7 # get value of letter digit
hexmul: sll $t2, $t2, 4 # shift previous value left
addu $t2, $t2, $t3 # and add in new digit
j loop
addiu $a0, $a0, 1 # go to next character of hex string

done: # there is no way to move a value directly from a general purpose
# register to a floating point register. We must temporarily
# store it to memory and then read into a float register to do this.
sw $t2, temp # store computed value to memory
l.s $f12, temp # and read it into a float register

# print it as a float
li $v0, 4 # system call code for print_str
la $a0, ans # address of string to print
syscall # print the answer prompt

li $v0, 2 # system call code for print_float
syscall # print the floating number in $f12

li $v0, 4 # system call code for print_str
la $a0, nl # address of string to print
syscall # print the new lines

j main_2 # ready to solve another problem
li $v0,4
two: # begin process of converting from float to hex
li $v0, 4 # system call code for print_str
la $a0, p4 # address of string to print
syscall # print the "get float" prompt

li $v0, 6 # system call code for read_float
syscall # result is in $f0

li $v0, 4 # system call code for print_str
la $a0, ans # address of string to print
syscall # print the answer prompt

# to move the value just received to a general purpose register, we
# must first store it to memory, then load it to a general purpose
# register.
s.s $f0, temp # store the value to memory
lw $t2, temp # get float bits to $t2
lui $t3, 0xf000 # masking constant
li $t9, 7 # number of characters to print
loop1: and $t4, $t2, $t3 # use mask to get upper 4 bits
srl $t4, $t4, 28 # move these to lsb positions
sltiu $v0,$t4,10
bne $v0,$zr,fin # branch if this hex digit is letter
addiu $t4, $t4, '0' # make digit an ascii char (add ascii of zero)
addiu $t4, $t4, 7 # convert >9 to ascii char

fin:
sw $t4, temp # our char goes to the first byte of this word.

li $v0, 4 # now print it
la $a0, temp
syscall # print a hex digit

sll $t2, $t2, 4
bgtz $t9, loop1 # one more done. is there another character
# to process?
addi $t9, $t9, -1

li $v0, 4 # system call code for print_str
la $a0, nl # address of string to print
syscall # print the new lines

j main_2 # ready to solve another problem
li $v0, 4
Posted on 2004-10-07 18:11:46 by Sephiroth3