MegaProcessor

Check-in [dcc9eecbd2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:DRYed up the output of listing-file lines.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dcc9eecbd2c53b5c885fe95c449ce68a4278659d
User & Date: jos 2015-08-22 18:12:36
Context
2015-09-19
17:59
Added operand evaluation with symbol-table lookup, TODO: integrate it with the appropriate opcode-generating functions. In this commit, only "jmp start" gets assembled correctly. check-in: 8d5232f487 user: jos tags: trunk
2015-08-22
18:12
DRYed up the output of listing-file lines. check-in: dcc9eecbd2 user: jos tags: trunk
17:59
Have the EQU directive only handled in pass 1, and fix a list-file issue for the ORG directive. check-in: 34e6793e25 user: jos tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to asm.lua.

84
85
86
87
88
89
90




91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
        if( label ) then symtab_addLabel(label) end;
        insLen = asm_instr[1];
        if( type(insLen)== 'function' ) then insLen = insLen(Mnemonic,op1,op2) end;
    end

    PC_add(insLen);
end





function ProcessLine( l ) -- Processing for pass 2
    local asm_instr;
    local n,label,Mnemonic,op1,op2 = Fields(l);
    local b1, b2, b3;
    local insLen = 0;

    if( not Mnemonic ) then Printf("%s : %s: %s\n", PC_get(), fmtBytes(), l ); return; end

    Mnemonic = Mnemonic:upper();

    asm_instr = Directive[ Mnemonic ];
    if( asm_instr ) then -- ORG is a special case, listing output must reflect value of PC after evaluation
        if(Mnemonic ~= 'ORG') then Printf("%s : %s\n",PC_get(),l); end;--if
        asm_instr(label,Mnemonic,op1,l); 
        if(Mnemonic == 'ORG') then Printf("%s : %s\n",PC_get(),l); end;--if
        return; 
    end
    
    asm_instr = CPU_instr[ Mnemonic ];
    if( asm_instr ) then
        insLen = asm_instr[1];
        if( type(insLen)== 'function' ) then insLen = insLen(Mnemonic,op1,op2) end;
        b1, b2, b3 = asm_instr[2](Mnemonic,op1,op2);
    end

    Printf("%s : %s: %s\n", PC_get(), fmtBytes(b1,b2,b3), l );
    PC_add(insLen);

end


-- Main line
--







>
>
>
>







|





|

|










|







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
        if( label ) then symtab_addLabel(label) end;
        insLen = asm_instr[1];
        if( type(insLen)== 'function' ) then insLen = insLen(Mnemonic,op1,op2) end;
    end

    PC_add(insLen);
end

function ListLine( l, b1, b2, b3 )
    Printf("%s : %s: %s\n", PC_get(), fmtBytes(b1,b2,b3), l );
end

function ProcessLine( l ) -- Processing for pass 2
    local asm_instr;
    local n,label,Mnemonic,op1,op2 = Fields(l);
    local b1, b2, b3;
    local insLen = 0;

    if( not Mnemonic ) then ListLine(l); return; end

    Mnemonic = Mnemonic:upper();

    asm_instr = Directive[ Mnemonic ];
    if( asm_instr ) then -- ORG is a special case, listing output must reflect value of PC after evaluation
        if(Mnemonic ~= 'ORG') then ListLine(l); end;--if
        asm_instr(label,Mnemonic,op1,l); 
        if(Mnemonic == 'ORG') then ListLine(l); end;--if
        return; 
    end
    
    asm_instr = CPU_instr[ Mnemonic ];
    if( asm_instr ) then
        insLen = asm_instr[1];
        if( type(insLen)== 'function' ) then insLen = insLen(Mnemonic,op1,op2) end;
        b1, b2, b3 = asm_instr[2](Mnemonic,op1,op2);
    end

    ListLine( l, b1, b2, b3 ); 
    PC_add(insLen);

end


-- Main line
--