URL
https://opencores.org/ocsvn/lxp32/lxp32/trunk
Subversion Repositories lxp32
[/] [lxp32/] [trunk/] [verify/] [lxp32/] [src/] [firmware/] [test001.asm] - Rev 2
Go to most recent revision | Compare with Previous | Blame | View Log
/** This test verifies that basic instructions* (data transfers, addition/subtraction, jumps) work.*/lc r100, 0x10000000 // test result output pointerlc r101, haltlc r102, bad_jump// All registers should be zero-initialized after resetlc r0, jump0add r1, r1, 1cjmpe r0, r1, 1sw r100, 2 // failure: r1 not initializedjmp r101// Test different jump conditionsjump0:lc r0, jump1jmp r0sw r100, 3 // failure: this instruction should not be reachablejmp r101jump1:lc r0, jump2mov r1, 100cjmpne r0, r1, 101sw r100, 4 // failure: required jump is not takenjmp r101jump2:lc r0, jump3cjmpe r0, r1, 100sw r100, 5 // failure: required jump is not takenjmp r101jump3:lc r0, jump4cjmpuge r0, r1, 99sw r100, 6 // failure: required jump is not takenjmp r101jump4:lc r0, jump5cjmpuge r0, r1, 100sw r100, 7 // failure: required jump is not takenjmp r101jump5:lc r0, jump6cjmpug r0, r1, 99sw r100, 8 // failure: required jump is not takenjmp r101jump6:lc r0, jump7cjmpsge r0, r1, -128sw r100, 9 // failure: required jump is not takenjmp r101jump7:lc r0, jump8cjmpsge r0, r1, 100sw r100, 10 // failure: required jump is not takenjmp r101jump8:lc r0, jump9cjmpsg r0, r1, 99sw r100, 11 // failure: required jump is not takenjmp r101jump9:lc r0, 2227053353lc r1, 2933288161cjmpug r102, r0, r1lc r0, 3957963761lc r1, 4048130130cjmpug r102, r0, r1lc r0, 1021028019lc r1, 2570980487cjmpug r102, r0, r1lc r0, 470638116lc r1, 3729241862cjmpug r102, r0, r1lc r0, 2794175299lc r1, 3360494259cjmpug r102, r0, r1lc r0, 522532873lc r1, 2103051039cjmpug r102, r0, r1lc r0, 994440598lc r1, 4241216605cjmpug r102, r0, r1lc r0, 176753939lc r1, 850320156cjmpug r102, r0, r1lc r0, 3998259744lc r1, 4248205376cjmpug r102, r0, r1lc r0, 3695803806lc r1, 4130490642cjmpug r102, r0, r1lc r0, -798605244lc r1, -233549907cjmpsg r102, r0, r1lc r0, -1221540757lc r1, 580991794cjmpsg r102, r0, r1lc r0, -1651432714lc r1, -635466783cjmpsg r102, r0, r1lc r0, 43633328lc r1, 1235055289cjmpsg r102, r0, r1lc r0, -2132159079lc r1, -981565396cjmpsg r102, r0, r1lc r0, -859182414lc r1, -697843885cjmpsg r102, r0, r1lc r0, 1720638509lc r1, 2127959231cjmpsg r102, r0, r1lc r0, -1888878751lc r1, 1230499715cjmpsg r102, r0, r1lc r0, 517066081lc r1, 1914084509cjmpsg r102, r0, r1lc r0, -266475918lc r1, 2001358724cjmpsg r102, r0, r1mov r1, 100cjmpe r102, r1, 101cjmpne r102, r1, 100cjmpuge r102, r1, 101cjmpug r102, r1, 100cjmpug r102, r1, 101cjmpsge r102, r1, 101cjmpsg r102, r1, 101cjmpsg r102, r1, 100cjmpsg r102, -128, r1lc r0, jump10jmp r0bad_jump:sw r100, 12 // failure: jump should not be takenjmp r101jump10:// Copy itself to another portion of memorymov r0, 0 // source pointerlc r1, 0x00008000 // destination pointerlc r2, end // size of block to copy, in byteslc r32, copy_loopcopy_loop:lw r3, r0sw r1, r3add r0, r0, 4add r1, r1, 4cjmpul r32, r0, r2// Calculate sum of program body in a post-condition loopmov r0, 0 // pointermov r16, 0 // sumlc r32, sum_loopsum_loop:lw r1, r0add r16, r16, r1add r0, r0, 4cjmpul r32, r0, r2// Calculate sum of copied program body with negative sign, in a pre-condition looplc r0, 0x00008000 // pointeradd r2, r0, r2 // end pointermov r17, 0 // sumlc r32, sum2_looplc r33, sum2_endsum2_loop:cjmpuge r33, r0, r2lw r1, r0sub r17, r17, r1add r0, r0, 4jmp r32sw r100, 13 // failure: this instruction should not be reachablejmp r101sum2_end:// Check that sums are equal (but with opposite signs)add r0, r16, r17 // r0 should be zero nowlc r32, successcjmpe r32, r0, 0sw r100, 14 // failure: results do not matchjmp r101success:sw r100, 1halt:hltjmp r101end:
Go to most recent revision | Compare with Previous | Blame | View Log
