MegaProcessor

Check-in [b37e57a31d]
Login

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

Overview
Comment:This fixes the ST.B (sp,0xvv),Rx problem. The second field is captured as everything between balanced parenteses, (including a ',').
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b37e57a31d3c955039966f2c9f3aa50ac6d0bf9f
User & Date: jos 2015-08-11 14:49:26.678
Context
2015-08-11
21:50
Added opcode for NOP_x (0xc5) check-in: 2acd1fa545 user: jos tags: trunk
14:49
This fixes the ST.B (sp,0xvv),Rx problem. The second field is captured as everything between balanced parenteses, (including a ','). check-in: b37e57a31d user: jos tags: trunk
13:50
Tried to duplicate the good work for instruction LD.B to instruction ST.B This version generates the same bytes for ST.B (SP,0xVV),Rx and ST.B 0xWWWW,Rx The trouble seems to be in string "(SP,0xVV)" not being kept together due to the ','; This needs to be fixed in another place. check-in: 9741453f2c user: jos tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to asm.lua.
18
19
20
21
22
23
24

25
26
27
28



29

30
31
32
33
34
35
36
    end
end

function Fields( line )
    if( line == "" or line:match("^%s*//") ) then return 0; end;
    local retVal = 0;
    local n, n1, label, instr, dst, src;

    label,n1 = line:match("^(%S+)()");  -- Start of string, (one+ non-space), (empty capture)
    if( label ) then n=n1; retVal = retVal + 1; end
    instr,n1 = line:match("%s+([^%s,;]+)%s+()",n); -- one+ space, (one+ non-space), one+ space, (empty capture)
    if( instr ) then n=n1; retVal = retVal + 1; end



    dst,n1 = line:match("([^%s,;]+)()",n);

    if( dst ) then n=n1; retVal = retVal + 1; end
    src,n1  = line:match("[%s,]+([^%s;]+)()",n);
    if( src ) then n=n1; retVal = retVal + 1; end
    return retVal, label, instr, dst, src;
end

function ProcessLine( l )







>




>
>
>
|
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    end
end

function Fields( line )
    if( line == "" or line:match("^%s*//") ) then return 0; end;
    local retVal = 0;
    local n, n1, label, instr, dst, src;
    n = 1;
    label,n1 = line:match("^(%S+)()");  -- Start of string, (one+ non-space), (empty capture)
    if( label ) then n=n1; retVal = retVal + 1; end
    instr,n1 = line:match("%s+([^%s,;]+)%s+()",n); -- one+ space, (one+ non-space), one+ space, (empty capture)
    if( instr ) then n=n1; retVal = retVal + 1; end
    if( line:sub(n,n) == '(' ) then
        dst,n1 = line:match("(%b())()")
    else
        dst,n1 = line:match("([^%s,;]+)()",n);
    end
    if( dst ) then n=n1; retVal = retVal + 1; end
    src,n1  = line:match("[%s,]+([^%s;]+)()",n);
    if( src ) then n=n1; retVal = retVal + 1; end
    return retVal, label, instr, dst, src;
end

function ProcessLine( l )
Changes to opcodes.lua.
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
end

function do_ST_B(f1, f2, f3)
    local ind_dst = (f2:match('%b()')~=nil);
    local autoinc = (ind_dst and (f2:match('++')~=nil) );
    local stack = f2:match("[sS][pP]");

    -- io.write( string.format("|%s|%s|%s| :: ",f1,f2,f3) );

    local ourNr = isReg(f3);

    if( not ind_dst ) then
        return 0xbc + ourNr, 0x00, 0x00;  -- ST.B 0xWWWW,Rx ;
    else
        if( stack ) then return 0xac + ourNr, 0x00; end;  -- ST.B (SP,0xVV),Rx ;

        local ourNr2 = tonumber( f2:match("[23]") );
        if( ourNr2 == nil ) then
            error("Line ".. string.format("%04d",LineNr) .. ": Operand must be R2 or R3", 0 )
        end
        if( autoinc ) then return 0x9c + (ourNr + 2*(ourNr2-2)) ;  -- ST.B (Rb++),Rx ;
        else 
            return 0x8c + (ourNr + 2*(ourNr2-2)) ;  -- ST.B (Rb),Rx
        end
    end
end

function do_ST_W(f1, f2, f3)
    return 0xb8 + isReg(f3), 0x00, 0x00
end

function do_SUB(f1, f2, f3)
    return( 0x60 + isReg2(f2,f3) );
end

function do_SUBX(f1, f2, f3)







<
<



















|







366
367
368
369
370
371
372


373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
end

function do_ST_B(f1, f2, f3)
    local ind_dst = (f2:match('%b()')~=nil);
    local autoinc = (ind_dst and (f2:match('++')~=nil) );
    local stack = f2:match("[sS][pP]");



    local ourNr = isReg(f3);

    if( not ind_dst ) then
        return 0xbc + ourNr, 0x00, 0x00;  -- ST.B 0xWWWW,Rx ;
    else
        if( stack ) then return 0xac + ourNr, 0x00; end;  -- ST.B (SP,0xVV),Rx ;

        local ourNr2 = tonumber( f2:match("[23]") );
        if( ourNr2 == nil ) then
            error("Line ".. string.format("%04d",LineNr) .. ": Operand must be R2 or R3", 0 )
        end
        if( autoinc ) then return 0x9c + (ourNr + 2*(ourNr2-2)) ;  -- ST.B (Rb++),Rx ;
        else 
            return 0x8c + (ourNr + 2*(ourNr2-2)) ;  -- ST.B (Rb),Rx
        end
    end
end

function do_ST_W(f1, f2, f3)
    return 0xb8, 0x00, 0x00
end

function do_SUB(f1, f2, f3)
    return( 0x60 + isReg2(f2,f3) );
end

function do_SUBX(f1, f2, f3)