C code for this ARM code -
hi can me c code arm code:
('...' means further instructions)
adr r1, table cmp r0, #tablemax ldrls pc, [r1,r0,lsl #2] ... ; statementsd b exit table dcd l0 dcd l1 ... dcd ln l0 ... ; statements0 b exit l1 ... ; statements1 b exit ... ln ... ; statementsn exit ...
this switch statement in original c code, like:
switch (a) { case 0: ... // statements 0 break; case 1: ... // statements 1 break; ... case table_max /* (maybe table_max -1) */ : ... // statements n break; default: ... // statements d break;
}
where = r0.
more recent versions of arm architecture in thumb-2 isa include 'table branch' instructions tbb, tbh code size reductions of particular case.
Comments
Post a Comment