-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlet_output_byte.js
82 lines (61 loc) · 2.2 KB
/
let_output_byte.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*****************************************************************************
LET BYTE
*****************************************************************************/
//============================================================================
// Output code for byte expression
//============================================================================
function output6502CodeForByteExpression() {
let opcode_nr = 0;
for( var i=0; i<tac.length; i++) {
if ( tac[i].load_left != false ) {
emitLDA( tac[i].left_value );
}
switch ( tac[i].operator ) {
case "+":
if ( opcode_nr == 0 || target_operand.data_type == "byte" ) {
emitCLC();
}
emitADC( tac[i].right_value );
break;
case "-":
emitSEC();
emitSBC( tac[i].right_value );
break;
case "*":
if ( tac[i].right_addressing_mode == "imm" ) {
emitMacro( "+_IMUL888I_ " + tac[i].right_value.substring(1) );
} else {
emitMacro( "+_CALL_PROC_IMUL888_ " + tac[i].right_value );
}
break;
case "/":
if ( tac[i].right_addressing_mode == "imm" ) {
emitMacro( "+_IDIV888I_ " + tac[i].right_value.substring(1) );
} else {
emitMacro( "+_CALL_PROC_IDIV888_ " + tac[i].right_value );
}
break;
case "&":
emitAND( tac[i].right_value );
break;
case "|":
emitORA( tac[i].right_value );
break;
case "^":
emitEOR( tac[i].right_value );
break;
case "<<":
ThrowSyntaxErrorIfOperandIsNotImmediate( tac[i].right_addressing_mode, tac[i].right_value );
emitMacro( "+_SHL_ " + tac[i].right_value.substring(1) );
break;
case ">>":
ThrowSyntaxErrorIfOperandIsNotImmediate( tac[i].right_addressing_mode, tac[i].right_value );
emitMacro( "+_SHR_ " + tac[i].right_value.substring(1) );
break;
}
if ( tac[i].store_dest != false ) {
emitSTA( tac[i].dest_value );
}
opcode_nr++;
}
}