push 명령은 어떤 구조인지 알아본다.
FF /6 PUSH r/m32
| Byte1 |
Byte2 |
http:// |
appleii. |
tistory. |
com |
| 11111111 |
00 |
110 |
R/M |
방문해 |
주셔서 |
감사합니다. |
|
| Byte1 |
Byte2 |
Byte3 |
| http://appleii. |
tistory.com |
| 11111111 |
01 |
110 |
R/M |
Data1 |
|
|
|
| Byte1 |
Byte2 |
Byte3 |
Byte4 |
Byte5 |
Byte6 |
| 11111111 |
10 |
110 |
R/M |
Data1 |
Data2 |
Data3 |
Data4 |
push dword ptr [eax] 는
| Byte1 |
Byte2 |
|
|
|
|
| 11111111 |
00 |
110 |
000 |
http:// |
appleii. |
tistory.com |
|
11111111 00110000 = FF 30
push dword ptr [eax+8] 은
| Byte1 |
Byte2 |
Byte3 |
|
|
|
| 11111111 |
01 |
110 |
000 |
00001000 |
http://appleii. |
tistory.com |
|
11111111 01110000 00001000 = FF 70 08
push dword ptr [eax+128] 은
| Byte1 |
Byte2 |
Byte3 |
Byte4 |
Byte5 |
Byte6 |
| 11111111 |
10 |
110 |
000 |
10000000 |
00000000 |
00000000 |
00000000 |
11111111 10110000 10000000 00000000 00000000 00000000 = FF B0 80 00 00 00
50+rd PUSH r32
| Byte1 |
|
|
|
|
|
| 01010 |
REG |
http:// |
appleii. |
tistory. |
.com |
|
6A PUSH imm8
| Byte1 |
Byte2 |
|
|
|
|
| 01101010 |
Data1 |
http:// |
appleii. |
tistory |
.com |
68 PUSH imm32
| Byte1 |
Byte2 |
Byte3 |
Byte4 |
Byte5 |
|
| 01101000 |
Data1 |
Data2 |
Data3 |
Data4 |
|
push eax 같은 경우는 REG = eax = 000 이므로 01010000 = 50 이 된다.
범용 레지스터 8개를 모두 표시하면 다음과 같다.
| push eax |
50 |
| push ecx |
51 |
| push edx |
52 |
| push ebx |
53 |
| push esp |
54 |
| push ebp |
55 |
| push esi |
56 |
| push edi |
57 |
push 127 같은 경우는 8비트 변위이므로
| Byte1 |
Byte2 |
|
|
|
|
| 01101010 |
01111111 |
|
01101010 01111111 = 6A 7F
push 128 은 32비트 변위이므로
| Byte1 |
Byte2 |
Byte3 |
Byte4 |
Byte5 |
|
| 01101000 |
10000000 |
00000000 |
00000000 |
00000000 |
|
01101000 10000000 00000000 00000000 00000000 = 68 80 00 00 00
pop 명령은 다음과 같이 표시한다.
8F /0 POP r/m32
| Byte1 |
Byte2 |
|
|
|
|
| 10001111 |
00 |
000 |
R/M |
|
|
|
|
| Byte1 |
Byte2 |
Byte3 |
|
|
|
| 10001111 |
01 |
000 |
R/M |
Data1 |
|
|
|
| Byte1 |
Byte2 |
Byte3 |
Byte4 |
Byte5 |
Byte6 |
| 10001111 |
10 |
000 |
R/M |
Data1 |
Data2 |
Data3 |
Data4 |
pop dword ptr [eax]
| Byte1 |
Byte2 |
|
|
|
|
| 10001111 |
00 |
000 |
000 |
|
|
|
|
10001111 00000000 = 8F 00
pop dword ptr [eax+8]
| Byte1 |
Byte2 |
Byte3 |
|
|
|
| 10001111 |
01 |
000 |
000 |
00001000 |
|
|
|
10001111 01000000 00001000 = 8F 40 08
pop dword ptr [eax+128]
| Byte1 |
Byte2 |
Byte3 |
Byte4 |
Byte5 |
Byte6 |
| 10001111 |
10 |
000 |
000 |
10000000 |
00000000 |
00000000 |
00000000 |
10001111 10000000 10000000 00000000 00000000 00000000 = 8F 80 80 00 00 00
58+rd POP r32
pop eax 는 REG = 000 이므로
01011000 = 58
범용 레지스터 8개를 모두 표시하면 다음과 같다.
| pop eax |
58 |
| pop ecx |
59 |
| pop edx |
5A |
| pop ebx |
5B |
| pop esp |
5C |
| pop ebp |
5D |
| pop esi |
5E |
| pop edi |
5F |
push ax , pop ax 를 하면 Prefix 66h 가 붙는 것은 mov 명령어와 같다.