Mostra notizie nelle discussioni
Avatar
☺
Scritto da
altg
utente che non utiene
il 2014-10-29 19:40:05.0 alle 2014-10-29 19:40:05.0
Trollate totali: 11540
Ci si capisce, vero?
Ci si capisce un casino!
E` tutto molto espressivo e ovvio. Ficoso

        include rc
        include text
        nameset text


        to From ByteString r    "binaural fn
        to From ByteString      "monaural fn
        
            creates a text object from a byte-aligned null-terminated string,
            such as those built by the compiler e.g. when you type @8:{ Hello! },
            or generally read from ASCII files (does not support UTF-8; another
            function will probably be developed for that, once someone provides
            means to render the characters outside the historical ASCII range...)

                --> m = firstByte       (byte select mask)
                --> n = R               (first unit in source buffer)
                --> p = r               (start address in source buffer)
                --> q                   (future start address in target buffer)
                --> r = 0               (source bytes counter, starts at zero)
                
                repeat if n has m       (as long as no null terminator found)

                        r + 1           (increment bytes counter)
                        m ] 8           (rotate mask, e.g. FF000000 -> 00FF0000)
                        
                        if m eq firstByte
                        
                                p + 1   (access next unit in source buffer)
                                n = P   (load new source buffer unit)

                <-- p                   (p = entry r, i.e. initial source address)

                q <- rc::Pick r Units   (q = target buffer)
                r <- rc::Size Of q      (r = back to abovely determined byte-size)
                
                --> q                   (will be returned to caller)
                --> v = firstByte       (free register v, use as byte select mask)
                
                m = 0                   (rotation magnitude, starts at zero)
                
                r times                 (each byte in source)

                        m + 8           (increase rotation: make that 8 for first byte)
                        n = P           (read current source unit)
                        n & v           (mask off all bytes except the relevant one)
                        n [ m           (rotate the relevant byte to its place, i.e...)
                        Q = n           (left-most of the target unit, hereby written)
                        
                        if m eq bitsPerUnit
                        
                                p + 1   (full circle? ok, access next unit in source)
                                m = 0   (and reset rotation magnitude)

                        q + 1           (access next unit in target buffer)
                        v ] 8           (rotate mask, e.g. FF000000 -> 00FF0000)
                
                <-- v                   (restore v - it's callers' vicinity pointer)
                <-- r                   (we had stacked target buffer before v)
                <-- q                   (callee-saved)
                <-- p                   (callee-saved)
                <-- n                   (callee-saved)
                <-- m                   (callee-saved)
                
                return r                (we return the target buffer address)


Oh ma comunque una cosa del genere (conversione di una stringa ASCII da un allineamento a 8 bit a uno a 32 bit per carattere), penso sarebbe piuttosto oscura anche se la scrivessi in javascript. Comunque ho commentato tutto, il che spiega molte cose e non sto affatto prendendo per il culo, no, cosa andate mai a pensare? A bocca storta

Vabbe' ragazzi, ovviamente poi uno 'ste cose se le trova pronte e le chiama e basta. Cioe` in un esempio da tutorial, 'sta roba e` solo usata, non scritta, il che viene fuori piu` comprensibilmente cosi`:

	startup displayStatus engage
	include text fromByteString
	include text say
	include util pause


	to Begin

		text::From ByteString @8:{ Hello } -> Say

		each P inside \

		[

			@8:{ _Mercury		},
			@8:{ _Venus		},
			@8:{ _Earth		},
			@8:{ _Mars		},
			@8:{ _Jupiter		},
			@8:{ _Saturn		},
			@8:{ _Uranus		},
			@8:{ _Neptune		},
			@8:{ _and_maybe_Pluto	}

		]

			text::From ByteString P -> Say

		util::Pause
		leave


E qui dai si capisce.
Testo::daStringaDiBytes @8:{ questa } -> Dillo
Dove @8 imposta la wordsize, cioe` gli dice fai 8 bit per carattere.
Per default la fa lunga un'unita`, cioe` una parola della CPU, cioe` 32 bit qui.
E poi "per ogni P in un array di stringhe di bytes", fai la stessa cosa con P.
Pausa e poi chiudi il programma.
L'output e` ovviamente "Hello Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune and maybe Pluto".
Ah, gli underscore nelle stringhe marcano gli spazi.
Dai che si capisce, dai, non mi puoi dire... no? come no? In lacrime

Pagina generata in 303 millisecondi

Utenti attivi: 6 nell'ultimo minuto, 35 negli ultimi cinque minuti, 56 negli ultimi 15 minuti