SlideShare a Scribd company logo
1 of 18
よちよちバイナリアンの
BIOSコールで “HelloWorld”
Kashiwaba Yuki
(Twitter: @yuki_kashiwaba)
自己紹介
Kashiwaba Yuki
(Twitter: @yuki_kashiwaba)
 新米セキュリティエンジニア
 プログラミング歴は約3年くらい
 好きな言語は Python と C#
 よちよちバイナリアン
 マイブームは風呂読書
今回発表すること
アセンブリで BIOS コールを呼び出して、
システム起動時に “Hello, World” を表示させる
“For to know a man's library is, in some measure, to know his mind.”
― Geraldine Brooks
参考書籍
今回の発表の背景
• PC に電源を入れた直後に呼び出される BIOS で
Hello, World を呼び出したい!
• BIOS の操作はアセンブリ言語で実行したい!
• エミュレータではなく、物理マシンで起動してみたい!
※発表には含まない
コンピュータに電源を入れると
• コンピュータに電源を入れると、、、
1. CPU が ROM から BIOS を起動する (POST)
2. OS 起動用に設定したメディアから 512 バイトの情報を読み込んで
0x7C00 のメモリ番地にロードされる
3. 読み込んだブートコードの末尾 2 バイトが 「0x55, 0xAA」なら、
正しい MBR として実行
※x86系 CPU の場合
何をするのか
1. インテルの x86 系OSを対象とした
汎用アセンブリ言語 NASM を使って、
2. PC 起動時に読み込まれる 512 バイトのプログラムを作成し、
3. BIOS に “Hello, World” を表示させる
アセンブリとは
• 機械語と英単語や記号を「一対一」に対応させたもの
(ニーモニック)
• 単なる数字の羅列であり、非常に理解しづらい機械語の文字列を
人間が理解しやすい()形に対応づけたもの
機械語 と アセンブリ
アセンブリで何もしないをしよう
ぼくも毎日、
“何もしない”をしてるよ
512 バイトの末尾 2 バイトを書き換えてみる
末尾 2 バイトが
55 AA でないので、
ブートメディアとして
認識してもらえない
ブートコードを 512バイトより長くしてみる
こちらも同じく、
ブートメディアとして
認識してもらえない
一文字目を表示してみる
BIOS コールを利用して、
起動時に ‘A’ を表示する
BIOS コールとは
• BIOS が持っている機能を呼び出す命令
• AH レジスタで「ファンクションを選択し」 AL レジスタに「データパラメータ」を格納
• Interrrupt 命令を呼び出して使用する
• 文字表示に使用したのは、「Video Service Interrupt」
• 他にも、キーボード入力を受け取る命令や、コンピュータを再起動する命令など
様々な BIOS コールが存在する
BIOS コールで一文字を
出力する方法で、
パワー系 Hello, World を実装
できた
よちよちバイナリアンの
BIOSコールで “HelloWorld”
ご清聴ありがとうございました!

More Related Content

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Bios helloworld