MegaProcessor

Check-in [d1e029084f]
Login

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

Overview
Comment:Corrected ihex checksum calculation, investigated on bit_op redundant ranges.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d1e029084f8b8b331a77145e2f90ac1b8cd12e8a
User & Date: jos 2015-08-14 10:12:02
Context
2015-08-14
10:43
Added ProgramCounter and Symbol table functionality. check-in: ff3e1a01ea user: jos tags: trunk
10:12
Corrected ihex checksum calculation, investigated on bit_op redundant ranges. check-in: d1e029084f user: jos tags: trunk
2015-08-13
13:00
Restructured some tests involving ihex records and bitwise operations. check-in: 19c2dad8e4 user: jos tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bit_ops.txt.

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
83
84
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

Decoding of second byte [b2] for instructions 0xD8..0xDB
<table>
2nd byte    : fixed part : variable part
0x00..0x0f  :   LSL Rx,    #0 .. #15
0x10..0x1f  :   LSL Rx,    #-16 .. #-1
0x20..0x23  :   LSL Rx,    R0 .. R3
0x24..0x27  :   -- Redundant
0x28..0x2b  :   LSL.WT Rx, R0 .. R3
0x2c..0x2f  :   -- Redundant
0x30..0x33  :   LSR Rx,    R0 .. R3
0x34..0x37  :   -- Redundant
0x38..0x3b  :   LSR.WT Rx, R0 .. R3
0x3c..0x3f  :   -- Redundant
0x40..0x4f  :   ASL Rx,    #0 .. #15
0x50..0x5f  :   ASL Rx,    #-16 .. #-1
0x60..0x63  :   ASL Rx,    R0 .. R3
0x64..0x67  :   -- Redundant
0x68..0x6b  :   ASL.WT,    R0 .. R3
0x6c..0x6f  :   -- Redundant
0x70..0x73  :	ASR Rx,    R0 .. R3
0x74..0x77  :   -- Redundant
0x78..0x7b  :   ASR.WT Rx, R0 .. R3
0x7c..0x7f  :   -- Redundant
0x80..0x8f  :   ROL Rx,    #0 .. #15
0x90..0x9f  :   ROL Rx,    #-16 .. #-1
0xa0..0xa3  :   ROL Rx,    R0 .. R3
0xa4..0xa7  :   -- Redundant
0xa8..0xab  :   ROL.WT Rx, R0 .. R3
0xac..0xaf  :   -- Redundant
0xb0..0xbb  :   ROR Rx,    R0 .. R3
0xb4..0xb7  :   -- Redundant
0xb8..0xbb  :   ROR.WT Rx, R0 .. R3
0xbc..0xbf  :   -- Redundant
0xc0..0xcf  :   ROXL Rx,   #0 .. #15
0xd0..0xdf  :   ROXL Rx,   #-16 .. #-1
0xe0..0xe3  :   ROXL Rx,   R0 .. R3
0xe4..0xe7  :   -- Redundant
0xe8..0xeb  :   ROXL.WT Rx, R0 .. R3
0xec..0xef  :   -- Redundant
0xf0..0xf3  :	ROXR Rx,    R0 .. R3
0xf4..0xf7  :   -- Redundant
0xf8..0xfb  :   ROXR.WT Rx, R0 .. R3
0xfc..0xff  :   -- Redundant
</table>

Decoding of second byte [b2] for instructions 0xDC..0xDF



<table>
2nd byte    : fixed part : variable part
0x00..0x0f  :   BTST Rx,   #0 .. #15
0x10..0x1f  :   -- Redundant
0x20..0x23  :   BTST Rx,    R0 .. R3
0x24..0x27  :   -- Redundant
0x28..0x2c  :   -- Redundant
................................................................................
0xb8..0xbc  :   -- Redundant
0xbd..0xbf  :   -- Redundant
0xc0..0xcf  :   BSET Rx,   #0 .. #15
0xd0..0xdf  :   -- Redundant
0xe0..0xe3  :   BSET Rx,    R0 .. R3
0xe4..0xe7  :   -- Redundant
0xe8..0xec  :   -- Redundant

There are 8 different instructions in the category 'test-or-set'.
These are positioned at the bytes with even values for the high-nibble.
0xed..0xef  :   -- Redundant
0xf0..0xf3  :   -- Redundant
0xf4..0xf7  :   -- Redundant
0xf8..0xfc  :   -- Redundant
0xfd..0xff  :   -- Redundant

</table>








|

|

|

|



|

|

|

|



|

|

|

|



|

|

|

|



>
>
>







 







<
<
<








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
83
84
85
86
87
...
111
112
113
114
115
116
117



118
119
120
121
122
123
124
125

Decoding of second byte [b2] for instructions 0xD8..0xDB
<table>
2nd byte    : fixed part : variable part
0x00..0x0f  :   LSL Rx,    #0 .. #15
0x10..0x1f  :   LSL Rx,    #-16 .. #-1
0x20..0x23  :   LSL Rx,    R0 .. R3
0x24..0x27  :   -- Redundant (4)
0x28..0x2b  :   LSL.WT Rx, R0 .. R3
0x2c..0x2f  :   -- Redundant (4)
0x30..0x33  :   LSR Rx,    R0 .. R3
0x34..0x37  :   -- Redundant (4)
0x38..0x3b  :   LSR.WT Rx, R0 .. R3
0x3c..0x3f  :   -- Redundant (4)
0x40..0x4f  :   ASL Rx,    #0 .. #15
0x50..0x5f  :   ASL Rx,    #-16 .. #-1
0x60..0x63  :   ASL Rx,    R0 .. R3
0x64..0x67  :   -- Redundant (4)
0x68..0x6b  :   ASL.WT,    R0 .. R3
0x6c..0x6f  :   -- Redundant (4)
0x70..0x73  :	ASR Rx,    R0 .. R3
0x74..0x77  :   -- Redundant (4)
0x78..0x7b  :   ASR.WT Rx, R0 .. R3
0x7c..0x7f  :   -- Redundant (4)
0x80..0x8f  :   ROL Rx,    #0 .. #15
0x90..0x9f  :   ROL Rx,    #-16 .. #-1
0xa0..0xa3  :   ROL Rx,    R0 .. R3
0xa4..0xa7  :   -- Redundant (4)
0xa8..0xab  :   ROL.WT Rx, R0 .. R3
0xac..0xaf  :   -- Redundant (4)
0xb0..0xbb  :   ROR Rx,    R0 .. R3
0xb4..0xb7  :   -- Redundant (4)
0xb8..0xbb  :   ROR.WT Rx, R0 .. R3
0xbc..0xbf  :   -- Redundant (4)
0xc0..0xcf  :   ROXL Rx,   #0 .. #15
0xd0..0xdf  :   ROXL Rx,   #-16 .. #-1
0xe0..0xe3  :   ROXL Rx,   R0 .. R3
0xe4..0xe7  :   -- Redundant (4)
0xe8..0xeb  :   ROXL.WT Rx, R0 .. R3
0xec..0xef  :   -- Redundant (4)
0xf0..0xf3  :	ROXR Rx,    R0 .. R3
0xf4..0xf7  :   -- Redundant (4)
0xf8..0xfb  :   ROXR.WT Rx, R0 .. R3
0xfc..0xff  :   -- Redundant (4)
</table>

Decoding of second byte [b2] for instructions 0xDC..0xDF

There are 8 different instructions in the category 'test-or-set'.
These are positioned at the bytes with even values for the high-nibble.
<table>
2nd byte    : fixed part : variable part
0x00..0x0f  :   BTST Rx,   #0 .. #15
0x10..0x1f  :   -- Redundant
0x20..0x23  :   BTST Rx,    R0 .. R3
0x24..0x27  :   -- Redundant
0x28..0x2c  :   -- Redundant
................................................................................
0xb8..0xbc  :   -- Redundant
0xbd..0xbf  :   -- Redundant
0xc0..0xcf  :   BSET Rx,   #0 .. #15
0xd0..0xdf  :   -- Redundant
0xe0..0xe3  :   BSET Rx,    R0 .. R3
0xe4..0xe7  :   -- Redundant
0xe8..0xec  :   -- Redundant



0xed..0xef  :   -- Redundant
0xf0..0xf3  :   -- Redundant
0xf4..0xf7  :   -- Redundant
0xf8..0xfc  :   -- Redundant
0xfd..0xff  :   -- Redundant

</table>

Changes to dis_d8_db.lua.

94
95
96
97
98
99
100






101
102
103
104
105
106
      and postb and postb:match('%x%x'),
      "Please supply 2 hex-format bytevalues");


dis_d8_db( htob_2(instr), htob_2(postb) );
--]]
--







for instr = 0xdc,0xdf do
        for postb = 0x00,0xff do
                dis_dc_df(instr,postb);
        end
end







>
>
>
>
>
>






94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
      and postb and postb:match('%x%x'),
      "Please supply 2 hex-format bytevalues");


dis_d8_db( htob_2(instr), htob_2(postb) );
--]]
--

for instr = 0xd8,0xdb do
        for postb = 0x00,0xff do
                dis_d8_db(instr,postb);
        end
end

for instr = 0xdc,0xdf do
        for postb = 0x00,0xff do
                dis_dc_df(instr,postb);
        end
end

Changes to ihex.lua.

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
	ihex_address = 0x0000;
end

function ihex_set( value )
    ihex_address = value;
end

function ihex_chksum( buf,startVal )
	local ourSum = startVal or 0;

	for i=1,#buf,1 do
		ourSum = ourSum + buf:byte(i);
	end--for

	ourSum = ourSum + bit32.band(ihex_address,0xff);
	ourSum = ourSum + bit32.band( bit32.rshift(ihex_address,8),0xff);

	ourSum = bit32.bnot(ourSum) + 1;
	ourSum = bit32.band(ourSum,0xff);

	return( ourSum );
end

function table.byte(t,i)
    return( t[i] );
end

function table.len(t)
    return( #t );
end
--
-- Input : string or an array of byte-values and an optional length
-- If the first parameter is a table, then it gets 2 additional method-fields
-- that type 'string' already has by itself.
--


-- Outputs a ihex-format record and updates global ihex_address
--

function ihex_datarecord(buf,len)

    if( type(buf) == 'table' ) then -- Add 'string' methods that 'table' misses.
        buf.byte = table.byte; buf.len = table.len;
    end

	local ourLen = len or buf:len();
	local ourSum = ihex_chksum(buf,ourLen);

	io.write( string.format(':%02X%04X00',ourLen,ihex_address) );




	for i=1,ourLen do io.write( string.format('%02X',buf:byte(i)) ); end


	ihex_address = ihex_address + ourLen;






	io.write( string.format('%02X', ourSum ) );
	io.write( '\n' );


end

function ihex_endrecord()
	io.write(':00000001FF\n');
end

-- EOF --







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












>
>
|

>
|
>





|
>

>
>
>
>
|
>

<
>
>
>
>
>
>


>
>







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
	ihex_address = 0x0000;
end

function ihex_set( value )
    ihex_address = value;
end

















function table.byte(t,i)
    return( t[i] );
end

function table.len(t)
    return( #t );
end
--
-- Input : string or an array of byte-values and an optional length
-- If the first parameter is a table, then it gets 2 additional method-fields
-- that type 'string' already has by itself.
--
-- Outputs a ihex-format record containing 'len' bytes,
-- starting from byte 'start' (default: first)
-- and updates global ihex_address
--
--
function ihex_datarecord(buf,len,start)
    start = (start or 1) - 1;
    if( type(buf) == 'table' ) then -- Add 'string' methods that 'table' misses.
        buf.byte = table.byte; buf.len = table.len;
    end

	local ourLen = len or buf:len();
	local ourSum = ourLen;

	io.write( string.format(':%02X%04X00',ourLen,ihex_address) );

	for i=1,ourLen do
        local ourByte = buf:byte(i+start) ;
        ourSum = ourSum + ourByte;
        io.write( string.format('%02X', ourByte ) );
    end


	ourSum = ourSum + bit32.band(ihex_address,0xff);
	ourSum = ourSum + bit32.band( bit32.rshift(ihex_address,8),0xff);

	ourSum = bit32.bnot(ourSum) + 1;
	ourSum = bit32.band(ourSum,0xff);

	io.write( string.format('%02X', ourSum ) );
	io.write( '\n' );

	ihex_address = ihex_address + ourLen;
end

function ihex_endrecord()
	io.write(':00000001FF\n');
end

-- EOF --

Changes to opcodes.lua.

501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
    if( f2:match("^%( *[rR]") ) then return 1 end; -- ST.W (Rb[++]),Ra (8 cases, 4 w/o and 4 with '++' )
    return 3; -- ST.W Rx 0xWWWW (4 cases)
end

----------------------------------------------------------------------------------------
--
-- Table for CPU instructions in mnemonic format
--   element 1 = instruction length in bytes: 0 means operand-dependent length.
--   emement 2
--
CPU_instr = {
  ['ABS'] = { 1, do_ABS },
  ['ADD'] = { 1, do_ADD },
  ['ADDI'] = { 1, do_ADDI },
  ['ADDQ'] = { 1, do_ADDQ },
  ['ADDX'] = { 1, do_ADDX },







|
|







501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
    if( f2:match("^%( *[rR]") ) then return 1 end; -- ST.W (Rb[++]),Ra (8 cases, 4 w/o and 4 with '++' )
    return 3; -- ST.W Rx 0xWWWW (4 cases)
end

----------------------------------------------------------------------------------------
--
-- Table for CPU instructions in mnemonic format
--   element 1 = instruction length in bytes: direct numeric, or function for variable-length cases.
--   emement 2 = function returning the corresponding byte-values for the translated instruction.
--
CPU_instr = {
  ['ABS'] = { 1, do_ABS },
  ['ADD'] = { 1, do_ADD },
  ['ADDI'] = { 1, do_ADDI },
  ['ADDQ'] = { 1, do_ADDQ },
  ['ADDX'] = { 1, do_ADDX },