Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
2019 spring WIP
Search
sksat
July 29, 2019
Programming
1
160
2019 spring WIP
sksat
July 29, 2019
Tweet
Share
More Decks by sksat
See All by sksat
同時複数機開発・運用のDevOpsサイクル高速化のための取り組み
sksat
0
720
探査機自作ゼミ2025スライド
sksat
3
1.5k
人になにかを教えるときに考えていること(2025-05版 / VRC-LT #18)
sksat
6
1.9k
人工衛星開発のための C2A フレームワークとその開発体験
sksat
1
520
人工衛星の開発体験向上のために、ソフトウェアからできること
sksat
4
1k
3ヶ月でできる! 探査機自作ゼミ教材自作入門
sksat
6
3.6k
セキュリティ・キャンプ全国大会2024 S17 探査機自作ゼミ 事前学習・当日資料
sksat
4
31k
AE Rust 勉強会: github-webhook-rs
sksat
0
310
万国のサーバ管理者よ, 自動化せよ!
sksat
1
8.2k
Other Decks in Programming
See All in Programming
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
170
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
0
410
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
360
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
610
株式会社 Sun terras カンパニーデック
sunterras
0
2k
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
750
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
470
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
220
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
390
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
130
CSC307 Lecture 13
javiergs
PRO
0
310
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
13
2.7k
Featured
See All Featured
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
150
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
310
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
New Earth Scene 8
popppiees
1
1.7k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
190
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
910
How STYLIGHT went responsive
nonsquared
100
6k
Skip the Path - Find Your Career Trail
mkilby
1
72
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
70
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Transcript
Emscriptenを用いたx86エミュレータの ブラウザへの移植 Arch B1 sksat
背景 ・過去にx86エミュレータを作っていた ・WebAssemblyがアツい 2
WebAssemblyとは 3 ・ブラウザ上で走るアセンブリ風(?)言語 ・JavaScriptを置換するわけではない ・大してWebでもAssemblyでもない ・ブラウザ上で高速に計算できる ・LLVM 8.0で正式サポート(2019/03/20)
自作エミュレータ ・高2の時に作ったもの ・https://github.com/sk2sat/emu で公開 ・ターゲットはx86 ・コンピュータの動作原理を知りたい ・はりぼてOS(教育用の小さなOS)が動く ・マルチプラットフォームで動く → ブラウザでも動いたら楽しい!
←今回のモチベーション 4
先行事例 ・JSLinux ・v86 5
Emscriptenとは 6 ・asm.js, WebAssemblyへのコンパイラツールチェーン ・C/C++をブラウザ向けにコンパイルできる(!?)
Emscriptenとは(2) 7
とりあえずやってみる make CC=emcc CXX=emcc ・これだけではうまくいかない ・なぜ?→ファイル読み込みと画面描画ができない 8
エミュレータの構造 9 CPU G U I V G A G
L F W memory glDrawPixels fetch, read set palette read VRAM O S s t d li b flo pp y B I O S write int 0x13 read disk load “haribote.img” fread
ブラウザ上では... 10 CPU G U I V G A G
L F W memory glDrawPixels fetch, read set palette read VRAM O S s t d li b flo pp y B I O S write int 0x13 read disk load “haribote.img” fread
今回やろうとしたこと 11 CPU G U I V G A G
L F W memory glDrawPixels fetch, read set palette read VRAM O S s t d li b flo pp y B I O S write int 0x13 read disk load “haribote.img” fread
進捗どうですか? できませんでした... 12
進捗 13 CPU G U I V G A G
L F W memory glDrawPixels fetch, read set palette read VRAM O S s t d li b flo pp y B I O S write int 0x13 read disk load “haribote.img” fread できた なんもわからん
なぜできなかったのか? ・WebAssemblyでのpthreadがまだproposalだった 14 ・glDrawPixels()が使えなかった glDrawPixels()はOpenGL ES 2.0で削除 WebGLはOpenGL ES 2.0相当
やったこと ・threadが無いなら定期的に描画してしまえばいいじゃない →main()が終了するまでDOMへの操作が反映されない emscripten_sleep()を入れるとそこで更新してくれるらしい →コンパイラが落ちる 15
やったこと(2) ・glDrawPixels()が使えないなら... 元々RGBを1つの関数で表示したかったがためにOpenGLを使っていた シェーダなんもわからん そもそもemscripten_sleep()が使えないから実行中の描画ができない 16
やったこと(3) ・実行中の描画はあきらめた とりあえず終了時の画面が描画できればいい ・RGBを描画する関数が無いならcanvasに直描きすればいいじゃない 17
デモ 18 https://sk2sat.github.io/emu/demo/emu.html
今後 ・新規にx86エミュレータを作りたい https://github.com/sk2sat/eucerca ・キーボード/マウスのエミュレーション ・メモリ保護機能 ・FPGAで自作CPU 19
エミュレータの構造 20 CPU G U I V G A G
L F W memory glDrawPixels fetch, read set palette read VRAM O S s t d l i b f l op p y B I O S write int 0x13 read disk load “haribote.img” fread