自作エミュレータで学ぶx86アーキテクチャ
『自作エミュレータで学ぶx86アーキテクチャ』のエミュレータを [[ Elixir ]]を使って実装した記録。 GitHubリポジトリ。
!Next
- レジスタ周りをDRYに
- コマンドインターフェース
- Dialyzer
実装メモ
read_modrmではEmulatorのEIPを変更するので{emu, modrm}を返している- 1つしか命令実行してなかったヤバい
emu.memoryに保存する際はunsignedに統一しなきゃ- macro???
X86emu.Instruction.Macros??? &&&よりも==の結合度のほうが高いget_register32_signedはいらないの?- https://github.com/benjamintanweihao/chip8
汎用的な知見
- クソデカイ配列が使いたい
- Listは連結リストなのでアクセスするのに最悪O(N)かかって厳しい
- Mapで代用
1..length(list) |> Stream.zip(list) |> Enum.into(%{})- https://elixirforum.com/t/transform-a-list-into-an-map-with-indexes-using-enum-module/1523/2
- https://github.com/benjamintanweihao/chip8/blob/master/lib/chip8/memory.ex#L102
- Tupleは挿入されるごとにまるごと作り変えるのでつらい(要検証
- Erlang
:arrayhttps://elixirforum.com/t/arrays/8850/14 - structが
Accessビヘイビアを実装していないのでput_in/3が使えないつらい defdelegateで解決- https://github.com/benjamintanweihao/chip8/blob/master/lib/chip8/io.ex
- ModR/M バイトがわざわざ REG を挟んでいるのはなぜか?
- OFとCFの違い
- https://beiznotes.org/difference-between-carry-and-overflow-flag/
- ブートセクタなど
- MBRはデバイスに一つ、PBRはパーティションに一つ
- いまではGPTが主流
- [MBR Revealed! https://www.cgsecurity.org/STDMBR.htm#SPART]
- ELECOMのFAT16フォーマットされたUSBはMBR, BUFFALOのFAT32はGPTだった
- ハードとソフトの橋渡し BIOS→UEFI
- パーティション管理 MBR→GPT
- ファイルシステム FAT32など
[[ 低レイヤ ]]
Backlinks
There are no notes linking to this note.