tomoyuki-nakabayashi / Rustemu86

Apache License 2.0
5 stars 0 forks source link

push/popを実装する #17

Closed tomoyuki-nakabayashi closed 6 years ago

tomoyuki-nakabayashi commented 6 years ago

地味に一命令でできない。 スタックポインタの変更と、ロード/ストア命令に分割して実行する。

tomoyuki-nakabayashi commented 6 years ago
$ ndisasm -b 64 push_pop
00000000  BC00010000        mov esp,0x100
00000005  B801000000        mov eax,0x1
0000000A  50                push rax
0000000B  5B                pop rbx
tomoyuki-nakabayashi commented 6 years ago
0000000C  6650              push ax

なるほど。デフォルトレジスタサイズじゃないものをpushするときには、0x66でオーバーライトする、と。 もしくはRexPrefix。

tomoyuki-nakabayashi commented 6 years ago

OK!