Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | DRYed up most io.write(string.format(...)) things, and some other cleanup. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
a639fc91863b329b4976692f49228d25 |
| User & Date: | jos 2015-08-13 12:07:54.745 |
Context
|
2015-08-13
| ||
| 13:00 | Restructured some tests involving ihex records and bitwise operations. check-in: 19c2dad8e4 user: jos tags: trunk | |
| 12:07 | DRYed up most io.write(string.format(...)) things, and some other cleanup. check-in: a639fc9186 user: jos tags: trunk | |
|
2015-08-11
| ||
| 23:19 | Added logic to calculate the length of an instruction. check-in: 0791033629 user: jos tags: trunk | |
Changes
Changes to asm.lua.
| ︙ | ︙ | |||
8 9 10 11 12 13 14 |
function ProcessFile( inFileName )
local inFile = Check( io.open(inFileName,"r"),
"Can't open file " .. inFileName
);
for l in inFile:lines() do
| | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
function ProcessFile( inFileName )
local inFile = Check( io.open(inFileName,"r"),
"Can't open file " .. inFileName
);
for l in inFile:lines() do
Printf("%04d ", LineNr);
ProcessLine( Chomp(l) );
LineNr = LineNr + 1;
end
end
function Fields( line )
if( line == "" or line:match("^%s*[;//]") ) then return 0; end;
|
| ︙ | ︙ | |||
55 56 57 58 59 60 61 |
if( asm_instr ) then
insLen = asm_instr[1];
if( type(insLen)== 'function' ) then insLen = insLen(f2,f3,f4) end;
b1, b2, b3 = asm_instr[2](f2,f3,f4);
end
n, formBytes = fmtBytes(b1, b2, b3);
| | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
if( asm_instr ) then
insLen = asm_instr[1];
if( type(insLen)== 'function' ) then insLen = insLen(f2,f3,f4) end;
b1, b2, b3 = asm_instr[2](f2,f3,f4);
end
n, formBytes = fmtBytes(b1, b2, b3);
Printf("%d:%s %s",insLen,formBytes, l );
end
-- Main line
--
if( not arg[1] ) then
|
| ︙ | ︙ |
Changes to dis_d8_db.lua.
1 2 | #!/usr/bin/env lua | < < < | < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/env lua
require('./lib')
--
-- Disassembly function for instructions 0xd8..0xdf
-- which take one post-byte
-- The lower-case 'd' in each line will be replaced with the destination (0..3)
-- as derived from the instruction.
--
|
| ︙ | ︙ | |||
56 57 58 59 60 61 62 | "ROXL Rd, R", -- 0xe0..0xe3 : 0xe4..0xe7 : "-- redundant" "ROXL.WT Rd, R", -- 0xe8..0xeb : 0xec..0xef : "-- redundant" "ROXR Rd, R", -- 0xf0..0xf3 : 0xf4..0xf7 : "-- redundant" "ROXR.WT Rd, R" -- 0xf8..0xfb : 0xfc..0xff : "-- redundant" }; function dis_d8_db( instr, postb) | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
"ROXL Rd, R", -- 0xe0..0xe3 : 0xe4..0xe7 : "-- redundant"
"ROXL.WT Rd, R", -- 0xe8..0xeb : 0xec..0xef : "-- redundant"
"ROXR Rd, R", -- 0xf0..0xf3 : 0xf4..0xf7 : "-- redundant"
"ROXR.WT Rd, R" -- 0xf8..0xfb : 0xfc..0xff : "-- redundant"
};
function dis_d8_db( instr, postb)
Printf( "%02x %02x .. : ", instr, postb );
if( instr >= 0xd8 and instr <= 0xdb ) then
local dst = bit32.band( instr, 0x03 );
local src = bit32.rshift(postb,3);
local result = I_d8_db[src]:gsub("d",tostring(dst),1);
local lastChar = result:sub(-1);
if( lastChar == 'R' ) then result = result .. tostring( bit32.band( postb,0x03) ) end;
|
| ︙ | ︙ | |||
83 84 85 86 87 88 89 | "BCLR Rd, #", "BCLR Rd, R", "BSET Rd, #", "BSET Rd, R" }; function dis_dc_df( instr, postb) | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
"BCLR Rd, #",
"BCLR Rd, R",
"BSET Rd, #",
"BSET Rd, R"
};
function dis_dc_df( instr, postb)
Printf( "%02x %02x .. : ", instr, postb );
if( instr >= 0xdc and instr <= 0xdf ) then
local dst = bit32.band(instr, 0x03);
local src = bit32.rshift(postb,5);
-- printf( "%02x %02x", dst, src );
local result = I_dc_df[src]:gsub("d",tostring(dst),1);
local lastchar = result:sub(-1);
if( lastchar == '#' ) then result = result .. tostring( bit32.band(postb,0x0f) ) end;
|
| ︙ | ︙ |
Changes to lib.lua.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
--
-- File: lib.lua
-- usage: require('lib');
-- as early as possible, preferrably before all other requires,
--
--
-- If cond evaluates to false (or nil), then print errmsg
-- otherwise, return the condition.
--
function Check( cond, errmsg )
errmsg = errmsg or "Check failed..";
if( not cond ) then
| > > > > > > > > > > > > > > > > | 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 |
--
-- File: lib.lua
-- usage: require('lib');
-- as early as possible, preferrably before all other requires,
--
function Printf( format, ... )
io.write( string.format(format, ... ) );
end
function htob_2( s )
local hi,lo = s:byte(1,2);
local hiA,loA;
hi = bit32.band(hi,0xDF); hiA = bit32.band(hi,0x0F);
lo = bit32.band(lo,0xDF); loA = bit32.band(lo,0x0F);
if( hi >= 0x40 ) then hiA = hiA + 9 end
if( lo >= 0x40 ) then loA = loA + 9 end
return( bit32.bor( bit32.lshift(hiA,4), loA ) );
end
--
-- If cond evaluates to false (or nil), then print errmsg
-- otherwise, return the condition.
--
function Check( cond, errmsg )
errmsg = errmsg or "Check failed..";
if( not cond ) then
|
| ︙ | ︙ |
Deleted r0tst.lua.
|
| < < < < < < < < < < < < < < < < < < < < < < |