MegaProcessor

Check-in [8b4d99ed90]
Login

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

Overview
Comment:Added warning when Immediate-format operand for LD.B instruction evaluates to word-size with MSB != 0.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8b4d99ed900f6fd7a0ee8af4745e9553adae0c01
User & Date: jos 2015-10-22 16:56:59
Context
2015-10-22
17:54
Made function Error independent of Warn. Leaf check-in: 1b3f350d14 user: jos tags: trunk
16:56
Added warning when Immediate-format operand for LD.B instruction evaluates to word-size with MSB != 0. check-in: 8b4d99ed90 user: jos tags: trunk
12:28
Make the stack+offset instructions accept '+' as well as ',' check-in: 1a38e93721 user: jos tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib.lua.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--

function Printf( format, ... )
    io.write( string.format(format, ... ) );
end

function Warn( text )
    Printf("Line %04d : %s\n", LineNr, text );
end

function Error( text )
    Warn( text );
    os.exit(-1);
end








|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--

function Printf( format, ... )
    io.write( string.format(format, ... ) );
end

function Warn( text )
    Printf("Warning : %s\n       ", text );  -- text with newline and some indent.
end

function Error( text )
    Warn( text );
    os.exit(-1);
end

Changes to opcodes.lua.

231
232
233
234
235
236
237
238




239
240


241
242

243
244
245
246
247
248
249
    local ind_dst = (f3:match('%b()')~=nil);
    local autoinc = (ind_dst and (f3:match('++')~=nil) );
    local stack = f3:match("[sS][pP]");

    local ourNr = isReg(f2);

    if( not ind_dst ) then
        if( f3:match('#') ) 




        then 
            local dst = Eval_as_byte(f3:sub(2,-1))


            return 0xd4 + ourNr, table.unpack(dst) ;
        else 

            local dst = Eval_as_word(f3);
            return 0xb4 + ourNr, table.unpack(dst) ;
        end;
    else
        if( stack ) then 
            local dst = f3:match('[%+,](%S+)%)');
            local b2 = table.unpack( Eval_as_byte(dst) );







|
>
>
>
>
|
<
>
>

<
>







231
232
233
234
235
236
237
238
239
240
241
242
243

244
245
246

247
248
249
250
251
252
253
254
    local ind_dst = (f3:match('%b()')~=nil);
    local autoinc = (ind_dst and (f3:match('++')~=nil) );
    local stack = f3:match("[sS][pP]");

    local ourNr = isReg(f2);

    if( not ind_dst ) then
        if( f3:match('#') ) then -- Immediate mode.
            local dst = Eval_as_word(f3:sub(2,-1))
            if( #dst == 2 ) then
                if( dst[2] ~= 0x00 ) then
                     Warn("Non-zero MSB suppressed while forcing word-operand to byte.");
                end

                dst[2] = nil;
            end
            return 0xd4 + ourNr, table.unpack(dst) ;

        else -- Absolute address mode.
            local dst = Eval_as_word(f3);
            return 0xb4 + ourNr, table.unpack(dst) ;
        end;
    else
        if( stack ) then 
            local dst = f3:match('[%+,](%S+)%)');
            local b2 = table.unpack( Eval_as_byte(dst) );