Po hap nje teme e cila nuk eshte rrahur fare ose te pakten s'e kam vene re kund deri tani. Per mendimin tim s'ka sukses ne fushen e prog. pa njohur cfare ndodh ne thellesi...

################################################## ###
# WRITTEN DEC 2002 BY K. Mati
# INPUT: ???????
# OUTPUT: ???????
################################################## ###

.data
#-----------------------------------------------------------
entry: .space 12 # holds entry + CR + null
#------------------------
CR: .asciiz "\n" # a null-terminated carraige return
#------------------------
comma: .asciiz ", " # day-year separator: comma + space
#------------------------
Month: .asciiz "January " # each month name is followed by
.space 2 # a space, a null terminator and
.asciiz "February " # enough spaces to make all month
.space 1 # names the same size; namely, 11
.asciiz "March " # The number 11 derives from the
.space 4 # longest name (September) plus
.asciiz "April " # a space plus a null (9+1+1).
.space 4
.asciiz "May "
.space 6
.asciiz "June "
.space 5
.asciiz "July "
.space 5
.asciiz "August "
.space 3
.asciiz "September "
.asciiz "October "
.space 2
.asciiz "November "
.space 1
.asciiz "December "
.space 1
# ************************************************** ********
.text
.globl main
main: sw $ra, 0($sp) # push the return to SPIM address
addi $sp, $sp, -4 # adjust the stack pointer
#------------------------> input the date
addi $a1, $0, 11 # read upto 10 characters
la $a0, entry # a0 points to the buffer
addi $v0, $0, 8 # select service #8: read_string
syscall # branch to O/S
#------------------------> convert month digits to value
la $a0, entry # a0 points to entry
addi $a0, $a0, 3 # a0 points to the month substring
addi $a1, $0, 2 # a1 = 2 = lenght of month substring
jal value # get month value in v0
#------------------------> compute 11*(v0-1)
addi $v0, $v0, -1 # v0 = v0 - 1
addi $t0, $0, 11 # t0 = 11
mult $v0, $t0 # LO = 11 * v0
mflo $a0 # a0 = LO
#------------------------> print the month name (with space)
la $a1, Month # a1 = address of Month
add $a0, $a0, $a1 # a0 = address of month name
addi $v0, $0, 4 # service#4, print_string
syscall # print the month name
#------------------------> print the day
la $a0, entry # ao points to entry
sb $0, 2($a0) # store a null after the day#
addi $v0, $0, 4 # service#4, print_string
syscall # print the day
#------------------------> print comma and a space
la $a0, comma # a0 points to comma
addi $v0, $0, 4 # service#4: print_string
syscall # print cooma & space
#------------------------> print the year
la $a0, entry # a0 points at entry
addi $a0, $a0, 6 # a0 points at 1st byte of year
sb $0, 4($a0) # store a null after the year#
addi $v0, $0, 4 # service#4: print_string
syscall # print the year
#------------------------> print a trailing CR
la $a0, CR # a0 points at CR
addi $v0, $0, 4 # service#4: print_string
syscall # print a CR
#------------------------> end of program
addi $sp, $sp, 4 # re-adjust the stack pointer
lw $ra, 0($sp) # pop the stack
jr $ra # return to SPIM
# ************************************************** ********
# converts a string at a0 of length a1 into an integer in v0
# ----------------------------------------------------------
value: addi $t9, $0, 1 # t9:= 1
addi $t8, $0, 10 # t8:= 10
add $t0, $a0, $a1 # t0 points 1 byte beyond the string
add $v0, $0, $0 # v0:= 0
loop: sub $t0, $t0, 1 # look at previous character
lb $t1, 0($t0) # t1:= current character
sub $t1, $t1, 48 # t1:= value of current character
mult $t1, $t9 # LO:= positional value of current
mflo $t1 # t1:= positional value of current
add $v0, $v0, $t1 # v0:= accumulate values
mult $t9, $t8 # LO:= next power of 10
mflo $t9 # t9:= next power of 10
bne $t0, $a0, loop # repeat if 1st character not reached
jr $ra # return to caller
# ************************************************** ********

Cfare jane Input dhe Output.
Cfare realizohet?

Kush eshte gjuha ne te cilen eshte shkruar, cfare niveli i perket dhe nese ka dicka qe qellimisht eshte redundant ku dhe cfare eshte?

Pershendetje