changing the bytecodes print

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

changing the bytecodes print

Mariano Martinez Peck
 
Hi folks. Did you see that when you see the bytecodes of a method you see something like:

49 <70> self
50 <21> pushConstant: 'SQ_HOST32'
51 <8F 00 00 02> closureNumCopied: 0 numArgs: 0 bytes 55 to 56
55     <71> pushConstant: true
56     <7D> blockReturn
.......


The bytecode number here is printed in <hex> . However, in Interpreter and its #initializeBytecodeTable  they use base 10. So, each time I read a bytecode, and I want to know which is the method associated with that, I need to convert it.
So, I wonder if it makes sense to change the print, so that it prints in decimal. What do you think?

To change that, it seems to be in InstructionPrinter >> #print   but I cannot make it work yet :(

cheers

Mariano
Reply | Threaded
Open this post in threaded view
|

Re: changing the bytecodes print

Tobias Pape

Am 2011-03-08 um 09:06 schrieb Mariano Martinez Peck:

> Hi folks. Did you see that when you see the bytecodes of a method you see something like:
>
> 49 <70> self
> 50 <21> pushConstant: 'SQ_HOST32'
> 51 <8F 00 00 02> closureNumCopied: 0 numArgs: 0 bytes 55 to 56
> 55     <71> pushConstant: true
> 56     <7D> blockReturn
> .......
>
>
> The bytecode number here is printed in <hex> . However, in Interpreter and its #initializeBytecodeTable  they use base 10. So, each time I read a bytecode, and I want to know which is the method associated with that, I need to convert it.
> So, I wonder if it makes sense to change the print, so that it prints in decimal. What do you think?
>
> To change that, it seems to be in InstructionPrinter >> #print   but I cannot make it work yet :(


I can understand your urge, but be aware that
a Hex number in the bytecode range always takes
up (at max) two characters (as in 00 – FF).
Probably, using hex numbers ind the #initializeBytecodeTable
would be the better idea?

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: changing the bytecodes print

Levente Uzonyi-2
In reply to this post by Mariano Martinez Peck
 
On Tue, 8 Mar 2011, Mariano Martinez Peck wrote:

> The bytecode number here is printed in <hex> . However, in Interpreter
and its #initializeBytecodeTable  they use base 10. So, each time I read a
bytecode, and I want to know which is the method associated with that, I
need to convert it.

When I started programming, most programmers could convert a single
byte between binary, decimal and hexadecimal. If you're into low level
programming (e.g. VM), then you'll acquire this skill in no time IMHO.


Levente
Reply | Threaded
Open this post in threaded view
|

Re: changing the bytecodes print

Nicolas Cellier

2011/3/8 Levente Uzonyi <[hidden email]>:

>
> On Tue, 8 Mar 2011, Mariano Martinez Peck wrote:
>
>> The bytecode number here is printed in <hex> . However, in Interpreter
>
> and its #initializeBytecodeTable  they use base 10. So, each time I read a
> bytecode, and I want to know which is the method associated with that, I need to convert it.
>
> When I started programming, most programmers could convert a single byte between binary, decimal and hexadecimal. If you're into low level programming (e.g. VM), then you'll acquire this skill in no time IMHO.
>
>
> Levente
>

Mariano,
Quite sure you'll discover that one of your grand fathers could
program a machine directly by inputing some octal codes ;)
That does not tell however whether we have to do so in Smalltalk...
I would tend to prefer a power of two base because bytes codes are
designed as a bit pattern.
But changing the whole interpreter to use hex code is not a
lightweight change...
Sorry to not help.

Nicolas
Reply | Threaded
Open this post in threaded view
|

Re: changing the bytecodes print

Tobias Pape

Am 2011-03-08 um 22:59 schrieb Nicolas Cellier:
>
> 2011/3/8 Levente Uzonyi <[hidden email]>:
>>
>> On Tue, 8 Mar 2011, Mariano Martinez Peck wrote:
>>
>>> The bytecode number here is printed in <hex> . However, in Interpreter
>>
>
[…]
> But changing the whole interpreter to use hex code is not a
> lightweight change...

That was my idea, not Mariano's :)
He wanted just the other way round.

So Long,
        -tobias