File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -560,7 +560,7 @@ fn (mut c Amd64) mov64u(reg Register, val u64) {
560
560
c.g.write8 (0xbf )
561
561
}
562
562
else {
563
- eprintln ('unhandled mov64 ${reg} ' )
563
+ eprintln ('unhandled mov64u ${reg} ' )
564
564
}
565
565
}
566
566
c.g.write64 (val)
@@ -569,11 +569,12 @@ fn (mut c Amd64) mov64u(reg Register, val u64) {
569
569
570
570
fn (mut c Amd64) mov64 (reg Register, val i64 ) {
571
571
// see AMD64 Architecture Programmer's Manual Volume 3 about the MOV instruction to have a detailed explaination
572
- // if you wonder about the BF (B8+rq) there is an explaination about that in Table 2-2 (and a bit above in 2.5.2 Opcode Syntax)
572
+ // about the BF (B8+rq) there is an explaination in Table 2-2 (and a bit above in 2.5.2 Opcode Syntax)
573
573
// in short the 64 mov instruction is 0xB8 and after a 64 bits immediate value
574
574
// but for the cpu to know which register to move the value to, it adds a number to B8
575
575
// that number is the Value column in table 2-2
576
576
// for example the bytecode for mov rdx is 0xB8 + 2 so 0xBA
577
+ // 0x48 is the opcode for REX.W prefix for 64 bits MOV instruction
577
578
match reg as Amd64Register {
578
579
.rax {
579
580
c.g.write8 (0x48 )
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ fn (mut g Gen) expr(node ast.Expr) {
62
62
g.code_gen.infix_expr (node)
63
63
}
64
64
ast.IntegerLiteral {
65
- // Integer literal stores both signed and unsigned integers but sometimes unsigned integers are too big for i64 but not for u64
65
+ // Integer literal stores both signed and unsigned integers, some unsigned integers are too big for i64 but not for u64
66
66
println (node.val)
67
67
if node.val[0 ] == `-` { // if the number is negative
68
68
g.code_gen.mov64 (g.code_gen.main_reg (), node.val.i64 ())
You can’t perform that action at this time.
0 commit comments