Git Product home page Git Product logo

hariboteos's Introduction

haribote

memo

$ nasm hoge.nas -o hoge.img // -l hoge.lst を追加すると対応する機械語が表示できる
$ qemu-system-i386 hoge.img // 上手く行かないときは, -fda というオプションを付ける

day1

  • したこと

    1. バイナリ直書き.面倒.
    2. アセンブラで書き直す. 次の変更を加える. (NASMとnaskの違いによるエラー???)
        ; RESB  0x1fe-$         ; 0x001feまでを0x00で埋める命令
        RESB  0x1fe-($-$$)    ; 0x001feまでを0x00で埋める命令
      
      warning が出てくるのは REST を TIMES に変更すれば解消できる. 例) RESB 18 -> TIMES 18 DB 0
  • アセンブラ命令. NASM - The Netwide Assembler, docs, index

    • DB ... data byte. ファイルの内容を1バイトだけ直接書く命令.
    • RESB ... reserve byte.
    • DW ... data word. DB命令の仲間. word は16ビット=2バイトの事.
    • DD ... data double-word. 同上.
    • $ ... 現在の行が先頭から何バイト目がを教えてくれる変数.(厳密には違うらしい.)
    • $$ ... 現在のセクションの最初を表す.

day2

  • したこと

    1. CD-ROMの projects/02_days を作業ディレクトリにコピー.(アーカイブマネージャーを使えばCD-ROMの中身を見ることができる.)
    2. helloos3/helloos.nas のl.58をRESB 0x7dfe-0x7c00-($-$$)に変更すると動く.参考
    3. helloos4/ipl.nas も同様.
  • アセンブラ命令.

    • $$ ... 現在のセクションの最初を表す.

    • ORG ... origin. 機械語が実行時にPCのメモリのどこに読み込まれるかを教える命令.

      The function of the ORG directive is to specify the origin address which NASM will assume the program begins at when it is loaded into memory.

    • JUMP ... そのままの意味. C言語でいうgoto文.

    • MOV ... move. 代入.

    • <label name>: ... entry: , putloop: など. ラベルの宣言.

    • ADD ... 足し算.

    • CMP ... 比較命令.

    • JE ... 条件ジャンプ. 比較命令の結果によってジャンプをしたりしなかったりする.

        CMP AL,0
        JE fin
        MOV AH, 0x03
      

      は, C言語でいうと

        if (AL == 0) { goto fin; }
        AH = 0x03;
      
    • INT ... interrupt. ソフトウェア割り込み命令.

    • HLT ... halt. CPUを停止, 待機状態にする.

    に等しい.

  • レジスタ 16bit.

    • AX ... accumulator, AX = AH(high) + AL(low).
    • CX ... counter
    • DX ... data
    • BX ... base
    • SP ... stack pointer, スタック用ポインタ
    • BP ... base pointer, ベース用ポインタ
    • SI ... source index, 読み込みインデックス
    • DI ... destination index, 書き込みインデックス 8bit.
    • AL
    • CL
    • DL
    • BL
    • AH
    • CH
    • DH
    • BH セグメントレジスタ,16bit. day3で説明.
    • ES
    • CS
    • SS
    • DS
    • FS
    • GS

day3

著者作成のツールを使わない人向け.(面倒な所が多い)

day4

(メモを取るのを忘れてた.)

  • INSERT命令は追加せずにnasmのオプションで指定した.

  • アセンブラ命令.

day5

  • したこと
    • 5 フォントを増やしたい までは本に沿って進めていくだけ.
    • 5 でフォントを増やすために配布されていた makefont.c を改造して
       char hankaku[4096] = {
         0x00,0x00, ..., 0x00
         ... ...
         0x00, 0x18, ..., 0xe7, 0x00, 0x00 // A
         ... ...
         ...
       };
      
      というコードを hankaku.c というファイルに掃き出しそれを bootpack.c から読み込むようにした.
    • sprintf 動かず. 取り敢えず,sprintf を bootpack.c に直接書いた.
    • あとは本に従っていく.

day6

day7

  • したこと
    • 本のとおりに進めていくだけ.

day8

  • したこと
    • 本のとおりに進めていくだけ.

day9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.