Saturday, April 8, 2017

Handy Perl One Liner for Debugging Hack Assembly Language Output

What should you do, if you'd rather see this

0 : // function Class1.set 0
0 : (Class1.set)
0 : // push argument 0
0 : @0
1 : D = A
2 : @ARG
3 : A = M + D
4 : D = M
5 :
5 : @SP
6 : AM = M + 1
7 : A = A - 1

instead of this :

// function Class1.set 0
(Class1.set)
// push argument 0
@0
D = A
@ARG
A = M + D
D = M

@SP
AM = M + 1
A = A - 1

????

perl -n -e 'BEGIN{$ln=0} print "$ln : " and print; $ln++ unless ( m#^\h*\r?$|^\(|^\h*//# );'

That's what! Thank you Larry Perl - please teach Guido van Rossum something..

No comments:

Post a Comment