Created
June 19, 2009 12:40
-
-
Save built/132596 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use constant StartY => 123; | |
use constant BP => 0; | |
use constant PATTERN_BUFFER => 0x7F800; | |
sub register | |
{ | |
my $register = shift; | |
return sub | |
{ | |
return $$register if( scalar(@_) == 0 ); | |
$$register = new_value(shift, $$register); | |
} | |
} | |
sub new_value | |
{ | |
my ($arg, $current_value) = shift; | |
if( ref($arg) eq 'CODE' ) { return $arg->(); } | |
elsif( ref($arg) eq 'ARRAY' ) { return @$arg[0]; } | |
else { return $arg eq "" ? $current_value : $arg; } | |
} | |
sub MOV { my $partial = shift; $partial->(shift); } | |
sub AND { my $register = shift; $register->( $register->() & shift ); } | |
sub ADD { my $register = shift; $register->( $register->() + shift ); } | |
my ($AX, $SI) = 0; | |
sub AX { register(\$AX); } | |
sub SI { register(\$SI); } | |
MOV AX, [BP + StartY] ; # of bytes offset | |
MOV SI, AX ; | |
AND AX, 0x03 ; | |
ADD SI, PATTERN_BUFFER ; | |
print "AX is now: $AX\n"; | |
print "SI is now: $SI\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment