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 > Didattica in generale > [Progetto IJVM] Aiuto
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
maxzulli
.novellino.

User info:
Registered: Jan 2004
Posts: 2 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 1:00:52 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
AIUTO: progetto IJVM (come si fa la divisione?)

Stavo cercando di shiftare verso destra un numero binario in modo da simulare la sua divisione per 2.
Questo in ambiente IJVM (MIC-1).
Per lo shift a sinistra, la moltiplicazione, non c'e' problema... lo sommo a se' stesso ed in pratica e' come se lo moltiplicassi per 2.
ma per la divisione per 2 come si fa? Non posso sottrarlo da se stesso...
AIUTO!!!!
Grazie
maximus70@yahoo.com

27-03-2004 18:45
Click Here to See the Profile for maxzulli Click here to Send maxzulli a Private Message Find more posts by maxzulli Add maxzulli to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
LjL
.consigliere.

User info:
Registered: Dec 2003
Posts: 144 (0.02 al dì)
Location: Milano
Corso: Informatica
Anno: Primo
Time Online: 16:25:17 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Bel macello.
La prima cosa che mi viene in mente è questa: se tu hai, per dire, 32 bit, shiftare di uno a destra è equivalente a ruotare di 31 volte a sinistra.

[Ruotare è la stessa cosa di shiftare, con l'aggiunta che, quando ruoti, la cifra che "esce" dall'MSB del numero (il carry out se così vuoi chiamarlo) deve andare a finire nell'LSB del risultato; quindi, se hai 4 bit e vuoi routare il numero 1010 di uno a sinistra, il risultato è 0101, e non 0100 come nel caso dello shift.]

Ora... tu *puoi* shiftare a sinistra; se hai anche un'istruzione per chiedere al processore "c'è o non c'è carry out?", puoi sommare 1 al risultato nel caso in cui il carry out ci sia, e hai la tua rotazione a sinistra.

A questo punto ti "basta" ripetere l'operazione 31 volte. Gran metodo eh...? E tra l'altro non mi ricordo se esiste un'istruzione IJVM che permette di effettuare un salto a seconda del carry out.

Il problema a trovare un algoritmo decente è che, mentre su Internet trovi tutti gli algoritmi che vuoi per la generica divisione intera x/y, fai fatica a trovarne per la divisione per 2, dato che chiunque suppone che tu possa shiftare in quel caso... (e tra l'altro il MIC-1 ha un registro di shift, a cosa diavolo serviva?)

Pubblicità: se vuoi dài un'occhiata a http://www.sf.net/projects/micsimkit , è un simulatore MIC-1, microassembler e macroassembler IJVM adattabile che ho scritto due anni fa. Pieno di bug, ma se c'è qualcuno tipo te a cui magari interessa potrei rimettermi lì...

__________________
by LjL
ljlbox@tiscali.it
http://ljl.150m.com - appunti corsi

27-03-2004 19:22
Click Here to See the Profile for LjL Click here to Send LjL a Private Message Visit LjL's homepage! Find more posts by LjL Add LjL to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
maxzulli
.novellino.

User info:
Registered: Jan 2004
Posts: 2 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 1:00:52 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Smile Grazie!

Ci ragiono su...
GRAZIE INFINITE!!!
PS Ti ho mandato una email...

28-03-2004 08:14
Click Here to See the Profile for maxzulli Click here to Send maxzulli a Private Message Find more posts by maxzulli Add maxzulli to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
LjL
.consigliere.

User info:
Registered: Dec 2003
Posts: 144 (0.02 al dì)
Location: Milano
Corso: Informatica
Anno: Primo
Time Online: 16:25:17 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Edited: come non detto.

__________________
by LjL
ljlbox@tiscali.it
http://ljl.150m.com - appunti corsi

28-03-2004 15:01
Click Here to See the Profile for LjL Click here to Send LjL a Private Message Visit LjL's homepage! Find more posts by LjL Add LjL to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 14:51.    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.074 seconds (52.13% PHP - 47.87% MySQL) con 25 query.