<Hunar>
Hello :) Regenaxer is there a way to view the underlying structure of the cells? I mean when the (doc) explains the picolisp machine, it mentions the pointers in binary and how they are connected with each other and how each datatype is represented .. is there a way for example to see a bignum cells, with each cell pointers bits binary?
<Regenaxer>
Good morning Hunar!
<Regenaxer>
You can do that with 'adr' and 'byte' or 'struct'
<Regenaxer>
A bignum cannot be accessed directly, but via the value of a sym or the CAR of a cell for example
Hunar71 has joined #picolisp
Hunar has quit [Ping timeout: 256 seconds]
Hunar71 is now known as Hunar
<Hunar>
Is this correct? (setq A 5) (bin (adr (sym A)))
<Regenaxer>
Why 'sym' of a number#
<Regenaxer>
?
<Regenaxer>
(adr 'A) gives a pointer to 'A'
<Hunar>
I just want to see how a symbol's cell is represented in binary
<Hunar>
I can read the documentation of course :) but just wanted to see it in pil for fun
<Regenaxer>
("12" "4") is the encoding of the symbol name "A" as a short num
<Regenaxer>
"52" is the short num '5'
<Hunar>
why 52 is 5? is short num a different thing than normal representation?
<Regenaxer>
Take a look into doc/structures
<Hunar>
Ok :)
<Regenaxer>
'cnt' is short num
<Regenaxer>
...xxxxS010
<Regenaxer>
So the lowest nibble is 0010 or 2
<Regenaxer>
(S is the sign)
<Regenaxer>
hex 52 is the value shifted left by 4 plus the four tag bits
<Regenaxer>
Same for the name "A"
<Regenaxer>
: (hex (+ 2 (>> -4 (char "A"))))
<Regenaxer>
-> "412"
<Regenaxer>
It gives the bytes ("12" "4") in little endian
<Hunar>
Thank you very much :D now it's very clear
<Regenaxer>
:)
<Regenaxer>
Hello tankf33der! Are you here?
<Hunar>
Extra questions: you said 16 bytes, so that's a complete cell 128bits instead of only head or tail right? .. I made this (pack (mapcar '((N) (pad 8 (bin N))) (struct (- (adr 'A) 8) '(B . 16)))) but it's not what I want, I want to output the format that is used in the documentation xxxxx...xxxS010 I have to reorder the bytes right?
<Hunar>
changing the 16 bytes from A B C D E F G H - I J K L M N O P to H G F E D C B A - P O N M L K J I
<tankf33der>
Morning all
<tankf33der>
here
<Hunar>
Good morning tankf33der :)
<Regenaxer>
Hi tankf33der! I changed a lot in the base system (see mailing list). Can you run your tests?
<Regenaxer>
Hunar, yes, one cell
<Regenaxer>
Yes, little endian
<Regenaxer>
better fetch two longs
<Regenaxer>
(struct ... '(N . 2))
<Hunar>
Yeah that was much better :D
<tankf33der>
Regenaxer: all passed
<Hunar>
I got what I want :D (setq A 5) (de viewCell (Var) (let Cell (struct (- (adr Var) 8) '(N . 2)) (pack (pad 64 (bin (car Cell))) " | " (pad 64 (bin (cadr Cell)))))) (viewCell 'A)