MCPcopy Create free account
hub / github.com/ararog/Unrar4iOS / ExecuteCode

Method ExecuteCode

Unrar4iOS/unrar/rarvm.cpp:179–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177 Cmd=PreparedCode+(IP);
178
179bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,uint CodeSize)
180{
181 int MaxOpCount=25000000;
182 VM_PreparedCommand *Cmd=PreparedCode;
183 while (1)
184 {
185#ifndef NORARVM
186 // Get addresses to quickly access operands.
187 uint *Op1=GetOperand(&Cmd->Op1);
188 uint *Op2=GetOperand(&Cmd->Op2);
189#endif
190 switch(Cmd->OpCode)
191 {
192#ifndef NORARVM
193 case VM_MOV:
194 SET_VALUE(Cmd->ByteMode,Op1,GET_VALUE(Cmd->ByteMode,Op2));
195 break;
196#ifdef VM_OPTIMIZE
197 case VM_MOVB:
198 SET_VALUE(true,Op1,GET_VALUE(true,Op2));
199 break;
200 case VM_MOVD:
201 SET_VALUE(false,Op1,GET_VALUE(false,Op2));
202 break;
203#endif
204 case VM_CMP:
205 {
206 uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
207 uint Result=GET_UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2));
208 Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
209 }
210 break;
211#ifdef VM_OPTIMIZE
212 case VM_CMPB:
213 {
214 uint Value1=GET_VALUE(true,Op1);
215 uint Result=GET_UINT32(Value1-GET_VALUE(true,Op2));
216 Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
217 }
218 break;
219 case VM_CMPD:
220 {
221 uint Value1=GET_VALUE(false,Op1);
222 uint Result=GET_UINT32(Value1-GET_VALUE(false,Op2));
223 Flags=Result==0 ? VM_FZ:(Result>Value1)|(Result&VM_FS);
224 }
225 break;
226#endif
227 case VM_ADD:
228 {
229 uint Value1=GET_VALUE(Cmd->ByteMode,Op1);
230 uint Result=GET_UINT32(Value1+GET_VALUE(Cmd->ByteMode,Op2));
231 if (Cmd->ByteMode)
232 {
233 Result&=0xff;
234 Flags=(Result<Value1)|(Result==0 ? VM_FZ:((Result&0x80) ? VM_FS:0));
235 }
236 else

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected