MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / patchtestreg

Function patchtestreg

libraries/AP_Scripting/lua/src/lcode.c:202–214  ·  view source on GitHub ↗

** Patch destination register for a TESTSET instruction. ** If instruction in position 'node' is not a TESTSET, return 0 ("fails"). ** Otherwise, if 'reg' is not 'NO_REG', set it as the destination ** register. Otherwise, change instruction to a simple 'TEST' (produces ** no register value) */

Source from the content-addressed store, hash-verified

200** no register value)
201*/
202static int patchtestreg (FuncState *fs, int node, int reg) {
203 Instruction *i = getjumpcontrol(fs, node);
204 if (GET_OPCODE(*i) != OP_TESTSET)
205 return 0; /* cannot patch other instructions */
206 if (reg != NO_REG && reg != GETARG_B(*i))
207 SETARG_A(*i, reg);
208 else {
209 /* no register to put value or register already has the value;
210 change instruction to simple test */
211 *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
212 }
213 return 1;
214}
215
216
217/*

Callers 2

removevaluesFunction · 0.85
patchlistauxFunction · 0.85

Calls 1

getjumpcontrolFunction · 0.85

Tested by

no test coverage detected