Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Implemented LSL,ASL,ROL,ROXL instructions. (xxR variants are still open) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6036736179484b9d52d6c48a57b6da20 |
User & Date: | jos 2015-10-12 18:00:06.912 |
Context
2015-10-22
| ||
09:17 | Completed instructions LD.B LD.W ST.B and ST.W check-in: 260a245f88 user: jos tags: trunk | |
2015-10-12
| ||
18:00 | Implemented LSL,ASL,ROL,ROXL instructions. (xxR variants are still open) check-in: 6036736179 user: jos tags: trunk | |
12:36 | moved a file out of the way. check-in: 68539753e6 user: jos tags: trunk | |
Changes
Changes to eval_op.lua.
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | local result = opVal[op1]; if( result == nil ) then Error("ADDQ value must be #2, #1, #-1 or #-2"); end return result ; end -------------------------------------------------------------------------------- -- Chapter: Evaluate symbol: -------------------------------------------------------------------------------- require( './lib' ); require( 'symtab' ); -- -- Take a value in range 0..2^32-1 and return a table of byte-values -- in little-endian order -- function As_table(val) local r = {}; | > > > > > > > > > > > > > > > > > > > > | | | | 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | local result = opVal[op1]; if( result == nil ) then Error("ADDQ value must be #2, #1, #-1 or #-2"); end return result ; end function isShiftOp(b2,offset1,offset2) -- Evaluate an operand with one of the following formats -- : #00..#15 -- : #-16..#-1 -- : R0..R3 -- local result; if( b2:sub(1,1 ) == '#' ) then if( b2:sub(2,2) == '-' ) then result = 32 - Eval_as_byte(b2:sub(3,-1))[1]; -- TODO, find a more transparent form for this. else result = Eval_as_byte(b2:sub(2,-1))[1]; end Check( result, "Evaluation of bitop specifier failed."); result = result + offset1; else result = offset2 + isReg(b2); end--match '#' return result ; end -------------------------------------------------------------------------------- -- Chapter: Evaluate symbol: -------------------------------------------------------------------------------- require( './lib' ); require( 'symtab' ); -- -- Take a value in range 0..2^32-1 and return a table of byte-values -- in little-endian order -- function As_table(val) local r = {}; repeat local b = math.fmod(val,256); table.insert(r,b); val = math.floor(val / 256); until( val == 0 ); return r ; end -- -- Evaluate a constant expression in any of the formats below -- Decimal, just digits -- Hex, prefix 0x or 0X -- Binary, prefix 0b or '%' -- String, enclosed in single or double quotes. -- Symbol, start with underscore or letter, followed by one or more letters/digits/underscores -- -- Return a table with the bytes that compose the value described object. -- [==[ function Eval(exp) local capture, idx; if( exp == '' ) then Error("Empty expression, can't evaluate.") end; -- Decimal, just digits. capture = exp:match("^(%d+)") if( capture and not exp:match("%D+") ) then return( As_table(tonumber(capture)) ); end; -- Hex, prefix 0x or 0X capture = exp:match("^(0[xX]%x+)") |
︙ | ︙ | |||
103 104 105 106 107 108 109 | end--if capture = exp:match("^([_%a]+[_%w]*)"); if( capture ) then local result = symtab_lookup(capture); if( not result ) then | | < > > > | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | end--if capture = exp:match("^([_%a]+[_%w]*)"); if( capture ) then local result = symtab_lookup(capture); if( not result ) then Error("Undefined symbol"); end return( As_table( result ) ); end print( exp ); Error( "Failed to evaluate." ); end--Eval() function Eval_as_word(exp) local t = Eval(exp); if( #t == 1 ) then table.insert(t,0x00); end--if : append zero as most-significant byte. return t ; end function Eval_as_byte(exp) local t = Eval(exp); if( #t ~= 1 ) then Error("Byte operand expected"); end--if return t ; end --EOF-- |
Changes to opcodes.lua.
︙ | ︙ | |||
38 39 40 41 42 43 44 | if( f2:lower() ~= 'ps' ) then Error("This instruction is for PS only"); end return 0xf4, 0x00 ; -- TODO end function do_ASL(f1, f2, f3) | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | if( f2:lower() ~= 'ps' ) then Error("This instruction is for PS only"); end return 0xf4, 0x00 ; -- TODO end function do_ASL(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = isShiftOp(f3, 0x40, 0x60); return b1, b2 ; end function do_ASL_WT(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = 0x68 + isReg(f3); return b1, b2 ; end |
︙ | ︙ | |||
283 284 285 286 287 288 289 | else return 0x80 + (ourNr + 2*(ourNr2-2)) ; end end end function do_LSL(f1, f2, f3) | > > | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | else return 0x80 + (ourNr + 2*(ourNr2-2)) ; end end end function do_LSL(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = isShiftOp(f3, 0x00, 0x20); return b1, b2 ; end function do_LSL_WT(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = 0x28 + isReg(f3); return b1, b2 ; end |
︙ | ︙ | |||
382 383 384 385 386 387 388 | end function do_RETI(f1, f2, f3) return 0xc7 ; end function do_ROL(f1, f2, f3) | | > | > > | | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | end function do_RETI(f1, f2, f3) return 0xc7 ; end function do_ROL(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = isShiftOp(f3, 0x80, 0xa0); return b1, b2 ; end function do_ROL_WT(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = 0xa8 + isReg(f3); return b1, b2 ; end function do_ROR(f1, f2, f3) local b1,b2 = 0xd8, 0x00; return b1, b2 ; -- TODO end function do_ROR_WT(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = 0xb8 + isReg(f3); return b1, b2 ; end function do_ROXL(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = isShiftOp(f3, 0xc0, 0xe0); return b1, b2 ; end function do_ROXL_WT(f1, f2, f3) local b1 = 0xd8 + isReg(f2); local b2 = 0xe8 + isReg(f3); return b1, b2 ; end |
︙ | ︙ |