summary refs log blame commit diff stats
path: root/test/tc_newkeys.py
blob: aca6ba980621c98e1e6860c9275f2f0f0f8db53d (plain) (tree)
ass="p">].i = 0x0000000a; run( "== code 0x1\n" // code segment // op ModR/M SIB displacement immediate " 53 \n" // push EBX to stack ); CHECK_TRACE_CONTENTS( "run: push EBX\n" "run: decrementing ESP to 0xbd000004\n" "run: pushing value 0x0000000a\n" ); } :(before "End Single-Byte Opcodes") case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: { // push r32 to stack uint8_t reg = op & 0x7; trace(Callstack_depth+1, "run") << "push " << rname(reg) << end(); //? cerr << "push: " << NUM(reg) << ": " << Reg[reg].u << " => " << Reg[ESP].u << '\n'; push(Reg[reg].u); break; } //:: pop :(before "End Initialize Op Names") put_new(Name, "58", "pop top of stack to EAX (pop)"); put_new(Name, "59", "pop top of stack to ECX (pop)"); put_new(Name, "5a", "pop top of stack to EDX (pop)"); put_new(Name, "5b", "pop top of stack to EBX (pop)"); put_new(Name, "5c", "pop top of stack to ESP (pop)"); put_new(Name, "5d", "pop top of stack to EBP (pop)"); put_new(Name, "5e", "pop top of stack to ESI (pop)"); put_new(Name, "5f", "pop top of stack to EDI (pop)"); :(code) void test_pop_r32() { Mem.push_back(vma(0xbd000000)); // manually allocate memory Reg[ESP].u = 0xbd000008; write_mem_i32(0xbd000008, 0x0000000a); // ..before this write run( "== code 0x1\n" // code segment // op ModR/M SIB displacement immediate " 5b \n" // pop stack to EBX "== data 0x2000\n" // data segment "0a 00 00 00\n" // 0x0000000a ); CHECK_TRACE_CONTENTS( "run: pop into EBX\n" "run: popping value 0x0000000a\n" "run: incrementing ESP to 0xbd00000c\n" ); } :(before "End Single-Byte Opcodes") case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: { // pop stack into r32 const uint8_t reg = op & 0x7; trace(Callstack_depth+1, "run") << "pop into " << rname(reg) << end(); //? cerr << "pop from " << Reg[ESP].u << '\n'; Reg[reg].u = pop(); //? cerr << "=> " << NUM(reg) << ": " << Reg[reg].u << '\n'; break; } :(code) uint32_t pop() { const uint32_t result = read_mem_u32(Reg[ESP].u); trace(Callstack_depth+1, "run") << "popping value 0x" << HEXWORD << result << end(); Reg[ESP].u += 4; trace(Callstack_depth+1, "run") << "incrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); assert(Reg[ESP].u < AFTER_STACK); return result; }