Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Architettura degli elaboratori e delle reti > [ASSEMBLY] Problema funzione
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
LiLywhite
.novellino.

User info:
Registered: Feb 2006
Posts: 3 (0.00 al dì)
Location:
Corso: Informatica
Anno:
Time Online: 1:33:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Problema funzione in assembly

Ciao a tutti. vi scrivo disperata perché non riesco a creare un programma funzionamente in Assembly. prima di tutto mi scuso per l'intrusione perché io studio alla Sapienza.

Ho un problema con una funzione ITERATIVA, non tanto con l'assembly quanto con il concetto :-P

la funzione è :
f (0,0)=6
f(x,y)=10 se x=0 o y=0
f(x,y)=3x+y+f(x-1,y-1) con x>=0,y>=0

esempio: f(3,2)=28
f(2,2)=18

n è interopositivo incluso lo zero.

vi sposto il codice in linguaggio assembly, non so nemmeno se voi usate questo, so che non è il massimo...cmq il mio problema è che mi perdo in contenuto di f(x,y), perché a questo svrappongo f(x-1,y-1)... come addizionarlo sena perderli è una cosa che dai tempi del c non mi è affato chiara, soprattutto inquesto caso.


ecco il codice:
#scrivere un programm che dati in input x e y si comporti così
# f(x,y)=10 se x=0 o y=0
#f(x,y)=3x+y+f(x-1,y-1) se x>=0,y>=0

.text
.globl main

main:
li $v0,5 #x
syscall
move $t0,$v0

li $v0,5 #y
syscall
move $t1,$v0

li $t3,0 #dato che $t potrebbe essere sporco

blt $t0,$t1,xminy
beq $t0,$t1,xugy

xmaggy:
beqz $t1,min0
mul $t2,$t0,3 #3x
add $t3,$t2,$t1 #z=3x+y
sub $t0,$t0,1 #x=x-1
sub $t1,$t1,1 #y=y-1
addi $t3,$t3,0 #z=z+0 questo non va
bgt $t0,$t1,xmaggy

xminy:
beqz $t0,min0
mul $t2,$t0,3 #3x
add $t3,$t2,$t1
sub $t0,$t0,1 #x=x-1
sub $t1,$t1,1 #y=y-1
addi $t3,$t3,0 #z=z+0
blt $t0,$t1,xminy

min0:
addi $t3,$t3,10

li $v0,1
move $a0,$t3
syscall
j fine


xugy:
beqz $t0,zero
mul $t2,$t0,3
add $t3,$t2,$t1
sub $t0,$t0,1
sub $t1,$t1,1
addi $t3,$t3,0
bgtz $t0,xugy

zero:
addi $t3,$t3,6
li $v0,1
move $a0,$t3
syscall


fine:
li $v0,10
syscall



se qualcuno riuscirà ad aiutarmi, gli sarò infinitamente grata

10-05-2006 21:44
Click Here to See the Profile for LiLywhite Click here to Send LiLywhite a Private Message Find more posts by LiLywhite Add LiLywhite to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
LiLywhite
.novellino.

User info:
Registered: Feb 2006
Posts: 3 (0.00 al dì)
Location:
Corso: Informatica
Anno:
Time Online: 1:33:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Sono riuscita risolvere il problema, grazie comunque a chi avrebbe voluto aiutarmi :-)

LiLy

10-05-2006 23:56
Click Here to See the Profile for LiLywhite Click here to Send LiLywhite a Private Message Find more posts by LiLywhite Add LiLywhite to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lallyblue
.grande:maestro.

User info:
Registered: Sep 2002
Posts: 2868 (0.35 al dì)
Location: un puntino nello spazio infinito
Corso: Informatica
Anno: ZERO!
Time Online: 29 Days, 9:48:21 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

beh se posti anche come hai risolto penso possa aiutare chi in futuro si trovi questo problema ;)

__________________
*** Proposta di legge di iniziativa popolare: "8x1000 ALLA RICERCA"
Informati e firma la petizione! E' nel tuo interesse! ;)

*** Browse my dA gallery ! ;)
***In medio stat virtus

11-05-2006 09:38
Click Here to See the Profile for lallyblue Click Here to See the Blog of lallyblue Click here to Send lallyblue a Private Message Visit lallyblue's homepage! Find more posts by lallyblue Add lallyblue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
LiLywhite
.novellino.

User info:
Registered: Feb 2006
Posts: 3 (0.00 al dì)
Location:
Corso: Informatica
Anno:
Time Online: 1:33:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Giusto! Fino ad oranon ho avuto tempo..cmq ecco il codice funzionante:

#scrivere un programm che dati in input x e y si comporti così
# f(x,y)=10 se x=0 o y=0
#f(x,y)=3x+y+f(x-1,y-1) se x>=0,y>=0

.text
.globl main

main:
li $v0,5 #x
syscall
move $t0,$v0
bltz $t0,fine #se x<0 esci

li $v0,5 #y
syscall
move $t1,$v0
bltz $t1,fine #se y<0 esci

li $t3,0 #$t3 potrebbe essere sporco
li $t4,0 #$t4è necessario che $t4 sia a 0 per il primo ciclo

blt $t0,$t1,xminy #analisi dei vari casi
beq $t0,$t1,xugy

xmaggy:
beqz $t1,min0 #se y=0 vai a min0
mul $t2,$t0,3 #3x
add $t3,$t2,$t1 #z=3x+y
sub $t0,$t0,1 #x=x-1
sub $t1,$t1,1 #y=y-1
add $t4,$t3,$t4 #$t4=$t3+$t4
bgt $t0,$t1,xmaggy #finché x>y vai a "xmaggy"

xminy:
beqz $t0,min0 #se x=0 vai a min0
mul $t2,$t0,3 #3x
add $t3,$t2,$t1
sub $t0,$t0,1 #x=x-1
sub $t1,$t1,1 #y=y-1
add $t4,$t3,$t4 #z=z+0
blt $t0,$t1,xminy

min0:
addi $t4,$t4,10

li $v0,1
move $a0,$t4
syscall
j fine


xugy:
beqz $t0,zero
mul $t2,$t0,3
add $t3,$t2,$t1
sub $t0,$t0,1
sub $t1,$t1,1
add $t4,$t3,$t4
bgtz $t0,xugy

zero:
addi $t4,$t4,6
li $v0,1
move $a0,$t4 #stampo a video il risultato
syscall


fine:
li $v0,10 #esci dal prgramma
syscall

.data


ciao a tutti..!

Avrei un'altra domanda:
data una matrice,come faccio a caricare l'elemento i-esimo??
c'è quacuno che lo sa?

11-05-2006 20:47
Click Here to See the Profile for LiLywhite Click here to Send LiLywhite a Private Message Find more posts by LiLywhite Add LiLywhite to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 03:15.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.031 seconds (78.31% PHP - 21.69% MySQL) con 26 query.