File tree Expand file tree Collapse file tree 2 files changed +36
-8
lines changed Expand file tree Collapse file tree 2 files changed +36
-8
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,36 @@ sub emit {
21
21
push @buffer , $_ [0];
22
22
}
23
23
24
+
25
+ sub is_zero {
26
+ return $_ [0] == 0;
27
+ }
28
+
29
+ sub is_int8 {
30
+ return -128 <= $_ [0] && $_ [0] < 128;
31
+ }
32
+
33
+ sub is_int16 {
34
+ return -32768 <= $_ [0] && $_ [0] < 32768;
35
+ }
36
+
37
+ sub is_uint8 {
38
+ return 0 <= $_ [0] && $_ [0] < 256;
39
+ }
40
+
41
+ sub is_uint16 {
42
+ return 0 <= $_ [0] && $_ [0] < 65536;
43
+ }
44
+
45
+
24
46
# ---
25
47
48
+ sub nop {
49
+ emit(0x90);
50
+ }
51
+
26
52
sub ret {
27
- my ( $self , $ imm16 ) = @_ ;
53
+ my ( $imm16 ) = @_ ;
28
54
if ( !$imm16 ) {
29
55
emit(0xC3);
30
56
}
Original file line number Diff line number Diff line change @@ -12,17 +12,19 @@ use warnings;
12
12
use feature ' say' ;
13
13
use Perlito5::X64::Assembler;
14
14
15
- say " 1..1" ;
16
-
17
- my $asm = Perlito5::X64::Assembler-> new();
15
+ say " 1..2" ;
18
16
19
17
{
20
18
package Perlito5::X64::Assembler ;
19
+ my $out ;
21
20
22
21
ret();
23
- my $out = to_hex();
24
-
25
- print " not " if $out ne ' C3' ;
26
- say " ok # $out " ;
22
+ $out = to_hex();
23
+ print " not " if $out ne ' C3' ;
24
+ say " ok # $out " ;
25
+ ret(10);
26
+ $out = to_hex();
27
+ print " not " if $out ne ' C3 C2 0A 00' ;
28
+ say " ok # $out " ;
27
29
}
28
30
You can’t perform that action at this time.
0 commit comments