├── .emurc ├── .gitignore ├── .gitmodules ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── TODO ├── arch ├── Makefile ├── arch.h ├── osecpu │ ├── Makefile │ ├── emulator.cc │ ├── emulator.h │ ├── instruction.cc │ └── instruction.h └── x86 │ ├── Makefile │ ├── emulator.cc │ ├── emulator.h │ ├── insndata.cc │ ├── insndata.h │ ├── instruction.cc │ ├── instruction.h │ ├── instruction16.cc │ ├── instruction16.h │ ├── instruction32.cc │ ├── instruction32.h │ ├── register.cc │ └── register.h ├── bios ├── .gitignore ├── Makefile ├── base.h ├── junk_base.h └── junk_x86.h ├── com_mak.txt ├── common.h ├── common.mk ├── debug.cc ├── debug.h ├── device ├── Makefile ├── device.h ├── display.cc ├── display.h ├── floppy.cc ├── floppy.h ├── keyboard.h └── pic.h ├── docs ├── demo │ ├── emu.data │ ├── emu.html │ ├── emu.js │ └── emu.wasm ├── format.md └── memo.md ├── emulator.cc ├── emulator.h ├── emulator_base.cc ├── emulator_base.h ├── font ├── .gitignore ├── Makefile ├── font.cc ├── font.h ├── hankaku.txt ├── makefont.c └── sjis2utf8.sh ├── gui.cc ├── gui.h ├── gui_old ├── Makefile ├── gui.cc └── gui.h ├── insn_base.h ├── interrupt.h ├── io.h ├── main.cc ├── memory.cc ├── memory.h ├── register_base.cc ├── register_base.h ├── sample ├── .gitignore ├── Makefile ├── main.c ├── osecpu │ ├── app0100.ose │ └── app0102.ose └── startup.asm ├── script_out.txt └── shell ├── Makefile ├── command.cc ├── command.h ├── shell.cc └── shell.h /.emurc: -------------------------------------------------------------------------------- 1 | init 1MB 0x7c00 0x7c00 2 | load binary sample/test.bin 3 | startg 4 | congui 5 | run 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | emu 2 | *.bin 3 | *.o 4 | *.a 5 | *.d 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libsksat"] 2 | path = libsksat 3 | url = https://github.com/sk2sat/libsksat.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: cpp 3 | git: 4 | submodules: false 5 | compiler: 6 | - g++ 7 | - clang++ 8 | install: 9 | - if [ "$CXX" = "g++" ]; then export CXX="g++-5"; fi 10 | - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7"; fi 11 | - git submodule update --init 12 | addons: 13 | apt: 14 | sources: 15 | - ubuntu-toolchain-r-test 16 | - llvm-toolchain-precise-3.7 17 | - llvm-toolchain-precise 18 | - eglibc 19 | - sourceline: 'ppa:keithw/glfw3' 20 | packages: 21 | - gcc-5 22 | - g++-5 23 | - clang-3.7 24 | - libc6-i386 25 | - libglfw3 26 | - libglfw3-dev 27 | script: 28 | - $CC --version 29 | - $CXX --version 30 | - make CC=$CC CXX=$CXX BUILD_TYPE=Release 31 | - make run CC=$CC CXX=$CXX UI="" 32 | notifications: 33 | slack: 34 | secure: pzxYsGiMg8632aYlAl4EtK9P491X4BY6d3V207VhzXr+gADnW278/9R2t6+YLi1EPRj+qQraVsA/wXuFFHGhqdYHS3kbaB7jcyICilaK7kaMbnnuIVcG/+LBcchxL9aMQVJv7DpZ4cQYWvoHGb2JjSomkdY6PAGsRdfp3z69c+tQghuUiZ1RCjn6QYV/qA/UViC/8BLjo4sdjqKvlteyWgfn33Gv03JHo/vZPX7m+6N1j7cyqZYyBRrvNW43HD3HJFw0RA+WShJeK+uXnVi1sNLKB1iBgVLQRW4Qp4wwrSLqRi+tgkIkIgGQ+Mtl8MFN2M/7CUFK9BEDWN46+mhSo0+GMGUJchCSX0ZlGiC+l5T1xGX7cFaO9pUfytcKZ7FIeqnXsdsNMAQVnn/szlvgwaUz4YcrvkiPLfnNKJSUthb3XqxcTcqNAxamGLGcSrx+ItGQHb3YBkKuq3n05S0ZYDNnYw8dd0AqWzTHS/6qQpU8QvZMkaCqXxCC1e8Cf6xFP1UR/fJ9GWQ5vo6cEnpwZ9COKhj+5jsggkpe0yHdAXhR/Rwqc74Nqpa915xMFrMGOGRCVxk1SxUfNpXrlxxNX6FunTH/WHiaw0snJtGAm5tJm6P080s3YQVpA6DRkjX6fLJdaeFtmY2XZUYzodKEToKgKorVyceuRsElHmlwe/4= 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 sk2sat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # default build type 2 | BUILD_TYPE = Debug 3 | 4 | TARGET = emu 5 | OBJS = main.o emulator_base.o emulator.o register_base.o memory.o \ 6 | device/device.a \ 7 | font/font.o \ 8 | gui.o \ 9 | arch/arch.a \ 10 | debug.o 11 | 12 | LDFLAGS += -pthread -lglfw -lGL 13 | 14 | EMU_BIN := haribote.img 15 | ARCH := x86 16 | MEMSIZE := 4 17 | BIOS := --junk-bios 18 | FLOPPY := --fda sample/$(EMU_BIN) 19 | DEV := $(FLOPPY) 20 | UI := --gui 21 | RUNFLAGS:= --arch $(ARCH) --memory-size $(MEMSIZE) $(BIOS) $(DEV) $(UI) 22 | 23 | default: 24 | make $(TARGET) 25 | 26 | include common.mk 27 | export 28 | 29 | run: $(TARGET) sample/$(EMU_BIN) 30 | make 31 | ./$(TARGET) $(RUNFLAGS) 32 | 33 | clean : _clean 34 | #make -C gui clean 35 | #make -C shell clean 36 | make -C font clean 37 | make -C device clean 38 | make -C sample clean 39 | make -C arch clean 40 | rm -f $(TARGET) 41 | 42 | full : 43 | make clean 44 | make 45 | 46 | full_run : 47 | make full 48 | make run 49 | 50 | $(TARGET) : $(OBJS) 51 | $(CXX) -o $@ $^ $(LDFLAGS) 52 | 53 | sample/$(EMU_BIN): DUMMY 54 | make -C sample $(EMU_BIN) 55 | 56 | device/device.a: DUMMY 57 | make -C device 58 | 59 | font/font.o: DUMMY 60 | make -C font 61 | 62 | shell/shell.a: DUMMY 63 | make -C shell 64 | 65 | gui/gui.a: DUMMY 66 | make -C gui 67 | 68 | arch/arch.a: DUMMY 69 | make -C arch 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # emu 2 | 3 | master: [![Build Status](https://api.travis-ci.org/sk2sat/emu.svg?branch=master)](https://travis-ci.org/sk2sat/emu) 4 | develop: [![Build Status](https://api.travis-ci.org/sk2sat/emu.svg?branch=develop)](https://travis-ci.org/sk2sat/emu) 5 | 6 | https://github.com/sk2sat/vm の設計とか色々見直して新しく作っているx86エミュレータ 7 | 8 | # ビルド 9 | ``` 10 | make 11 | ``` 12 | 13 | ビルドには以下のオプションが指定できます. 14 | 15 | 16 | * ```BUILD_TYPE```: 17 | ビルドのタイプを指定できます. 18 | ```Debug```と```Release```が選択可能です. 19 | ```Debug```を指定すると,```DOUT()```マクロによるデバッグ情報がエミュレーション時に表示されます. 20 | ```Release```を指定すると,同マクロを無効化してコンパイルします. 21 | デフォルトでは```Debug```が指定されています. 22 | 23 | 24 | # サンプル実行 25 | ``` 26 | make run 27 | ``` 28 | サンプルのバイナリのエミュレーションのテストが行えます. 29 | これには以下のオプションが指定できます. 30 | 31 | * ```ARCH``` 32 | アーキテクチャが選択できるような見た目をしていますが気のせいです. 33 | x86しか指定できないと思って下さい. 34 | 35 | 36 | * ```MEMSIZE``` 37 | メモリサイズを指定できます. 38 | 単位はMBです. 39 | デフォルトでは4MBになっています. 40 | 41 | 42 | * ```BIOS``` 43 | BIOSを指定できるような見た目をしていますが,これも気のせいです. 44 | 必ず```--junk-bios```を指定してください. 45 | 46 | 47 | * ```FLOPPY``` 48 | フロッピーディスクイメージが指定できます. 49 | ようはブートデバイスを設定するところです. 50 | ```--fda hoge.img```のように指定してください. 51 | 52 | 53 | * ```UI``` 54 | ユーザーインターフェースを選択できます. 55 | デフォルトでは```--gui```が指定されています. 56 | ```UI=""```のようにすると,ウィンドウを出さないで実行します. 57 | 58 | # エラー 59 | 全然実装が進んでいないため、よくエラーが発生します。ここにはエラーの種類のメモをしておきます。 60 | 61 | ``` 62 | not implemented 63 | ``` 64 | 65 | このエラーは、実装されていない動作が要求された時に発生します。このエラーのうち、 66 | 67 | ``` 68 | not implemented: code = 16進数 69 | ``` 70 | 71 | となっているものは、16進数が示す機械語が実装されていない、というエラーです。 72 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ・メモリクラスをちょっとこだわりたい 2 | 仮想メモリ空間の扱いとか、メモリマップドIOとかをやりやすくしたい。 3 | ・ディスプレイのエミュレーション 4 | リニアアクセスモードを実装したい(QEMUで未実装だった) 5 | ->モード別にVRAMのアドレスを動的に変えられるようにする 6 | あと、どうせならバンクアクセスもあったほうがいい(これは実際のイメージの編集する部分だけ変えればよさそう) 7 | -------------------------------------------------------------------------------- /arch/Makefile: -------------------------------------------------------------------------------- 1 | LIBARCH := arch.a 2 | ARCH_LIBS:= x86/x86.a osecpu/osecpu.a 3 | 4 | all: 5 | make $(LIBARCH) 6 | 7 | include ../common.mk 8 | 9 | $(LIBARCH): $(ARCH_LIBS) 10 | rm -f $@ 11 | ar cqT $@ $^ 12 | printf "create $@\naddlib $@\nsave\nend" | ar -M 13 | 14 | clean: _clean 15 | make -C x86 clean 16 | make -C osecpu clean 17 | 18 | x86/x86.a: DUMMY 19 | make -C x86 20 | 21 | osecpu/osecpu.a: DUMMY 22 | make -C osecpu 23 | -------------------------------------------------------------------------------- /arch/arch.h: -------------------------------------------------------------------------------- 1 | #ifndef ARCH_H_ 2 | #define ARCH_H_ 3 | 4 | enum class ARCH{ 5 | x86, 6 | osecpu, 7 | }; 8 | 9 | #include "x86/emulator.h" 10 | #include "x86/instruction.h" 11 | #include "osecpu/emulator.h" 12 | #include "osecpu/instruction.h" 13 | 14 | #endif // ARCH_H_ 15 | -------------------------------------------------------------------------------- /arch/osecpu/Makefile: -------------------------------------------------------------------------------- 1 | LIBOSECPU := osecpu.a 2 | OSECPUOBJS:= emulator.o instruction.o 3 | 4 | $(LIBOSECPU) : $(OSECPUOBJS) 5 | ar rcs $@ $^ 6 | 7 | include ../../common.mk 8 | 9 | clean: _clean 10 | -------------------------------------------------------------------------------- /arch/osecpu/emulator.cc: -------------------------------------------------------------------------------- 1 | #include "emulator.h" 2 | #include "instruction.h" 3 | 4 | namespace osecpu { 5 | 6 | void Emulator::InitInstructions(){ 7 | // throw "osecpu::Emulator::InitInstructions() is not implemented"; 8 | insn = new osecpu::Instruction(this); 9 | } 10 | 11 | void Emulator::InitRegisters(){ 12 | throw "osecpu::Emulator::InitRegisters() is not implemented"; 13 | } 14 | 15 | void Emulator::Dump(){ 16 | throw "osecpu::Emulator::Dump() is not implemented."; 17 | } 18 | 19 | }; 20 | -------------------------------------------------------------------------------- /arch/osecpu/emulator.h: -------------------------------------------------------------------------------- 1 | #ifndef OSECPU_EMULATOR_H_ 2 | #define OSECPU_EMULATOR_H_ 3 | 4 | #include "../../emulator_base.h" 5 | 6 | namespace osecpu { 7 | 8 | class Emulator : public EmulatorBase { 9 | public: 10 | void InitInstructions(); 11 | void InitRegisters(); 12 | void InitMemory(){} 13 | void InitIO(){} 14 | void Dump(); 15 | }; 16 | 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /arch/osecpu/instruction.cc: -------------------------------------------------------------------------------- 1 | #include "instruction.h" 2 | 3 | #define SETINSN(op,func,insn_flg) {insn[op] = (insnfunc_t)&osecpu::Instruction::func; insn_flgs[op] = insn_flg;} 4 | 5 | namespace osecpu { 6 | 7 | void Instruction::Init(){ 8 | throw "osecpu::Instruction::Init() is not implemented."; 9 | ClearInsn(0xff); 10 | opcode = 0x00; 11 | 12 | SETINSN(0x00, nop, 0); 13 | } 14 | 15 | void Instruction::Fetch(){ 16 | throw "osecpu::Instruction::Fetch() is not implemented."; 17 | } 18 | 19 | void Instruction::Decode(){ 20 | throw "osecpu::Instruction::Decode() is not implemented."; 21 | } 22 | 23 | void Instruction::Exec(){ 24 | throw "osecpu::Instruction::Exec() is not implemented."; 25 | } 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /arch/osecpu/instruction.h: -------------------------------------------------------------------------------- 1 | #ifndef OSECPU_INSTRUCTION_H_ 2 | #define OSECPU_INSTRUCTION_H_ 3 | 4 | #include "../../insn_base.h" 5 | #include "emulator.h" 6 | 7 | namespace osecpu { 8 | 9 | class Instruction : public InstructionBase { 10 | public: 11 | Instruction(Emulator *e) {} 12 | void Init(); 13 | 14 | void Fetch(); 15 | void Decode(); 16 | void Exec(); 17 | 18 | void SkipSignature(){ // 0x05 19 | // if(memory[pc+1]==0xE2 && memory[pc+2]) pc+=3; 20 | } 21 | 22 | uint8_t opcode; 23 | uint8_t insn_flgs[0xff]; 24 | 25 | void not_impl_insn(){ throw "osecpu: not implemented insn."; } 26 | 27 | void nop(){ puts("osecpu: nop"); } 28 | }; 29 | 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /arch/x86/Makefile: -------------------------------------------------------------------------------- 1 | LIBX86 := x86.a 2 | 3 | X86OBJS = emulator.o register.o insndata.o instruction.o instruction16.o instruction32.o 4 | 5 | $(LIBX86) : $(X86OBJS) 6 | ar rcs $@ $^ 7 | 8 | include ../../common.mk 9 | 10 | clean: _clean 11 | -------------------------------------------------------------------------------- /arch/x86/emulator.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "emulator.h" 4 | #include "register.h" 5 | #include "insndata.h" 6 | #include "instruction.h" 7 | #include "instruction16.h" 8 | #include "instruction32.h" 9 | #include "../../device/pic.h" 10 | #include "../../device/keyboard.h" 11 | 12 | using namespace std; 13 | 14 | namespace x86{ 15 | 16 | void Emulator::InitInstructions(){ 17 | // 起動時は16bitリアルモード 18 | idata = new InsnData(this); 19 | insn16 = new Instruction16(this, idata); 20 | insn32 = new Instruction32(this, idata); 21 | insn16->Init(); 22 | insn32->Init(); 23 | insn = insn16; 24 | mode = 16; 25 | } 26 | 27 | // vol3_i 9.1 28 | void Emulator::InitRegisters(){ 29 | pc.SetName("EIP"); 30 | eflags.SetName("EFLAGS"); 31 | 32 | reg = std::vector(REG_COUNT); 33 | const char* reg_name[REG_COUNT] = { 34 | "EAX", "ECX", "EDX", "EBX", "ESP", "EBP", "ESI", "EDI", 35 | }; 36 | for(size_t i=0;i(SREG_COUNT); 41 | const char* sreg_name[SREG_COUNT] = { 42 | "ES", "CS", "SS", "DS", "FS", "GS", 43 | }; 44 | for(size_t i=0;isreg = &sreg[3]; 48 | 49 | GDTR.SetName("GDTR"); 50 | IDTR.SetName("IDTR"); 51 | TR.SetName(" TR"); 52 | LDTR.SetName("LDTR"); 53 | GDTR.SetSize(sizeof(uint64_t)*3/4); 54 | IDTR.SetSize(sizeof(uint64_t)*3/4); 55 | 56 | LDTR.selector = 0x00; 57 | GDTR.base = IDTR.base = TR.base = LDTR.base = 0x00; 58 | GDTR.limit = IDTR.limit = TR.limit = LDTR.limit = 0xffff; 59 | 60 | CR0.SetName("CR0"); 61 | CR0.reg32 = 0x60000010; 62 | 63 | // all_regへの登録 64 | all_reg.push_back(&pc); 65 | all_reg.push_back(&eflags); 66 | for(size_t i=0;iendian = ENDIAN::LITTLE; 79 | } 80 | 81 | void Emulator::InitIO(){ 82 | io = new IO(); 83 | auto pic = new Device::PIC(); 84 | io->port[0x20] = io->port[0x21] = io->port[0xa0] = io->port[0xa1] = pic; 85 | 86 | auto keyboard = new Device::Keyboard(); 87 | io->port[0x60] = io->port[0x64] = keyboard; 88 | } 89 | 90 | void Emulator::ChangeMode16(){ 91 | mode = 16; 92 | } 93 | void Emulator::ChangeMode32(){ 94 | mode = 32; 95 | } 96 | 97 | void Emulator::RunStep(){ 98 | bool is_mode32 = IsMode32(); 99 | bool is_real = IsReal(); 100 | 101 | bool is_32; 102 | 103 | idata->sreg = &DS; // デフォルトのセグメントレジスタ 104 | 105 | if(is_real) // リアルモード 106 | is_32 = is_mode32; 107 | else // プロテクトモード 108 | is_32 = GetDesc(CS).D_B; // TODO: ディスクリプタ・キャッシュから取ってくる 109 | 110 | static bool break_flg = false; 111 | 112 | if(break_flg) getchar(); 113 | 114 | std::string func; 115 | switch(L2P(CS, EIP) - 0x280000){ 116 | case 0x35c: 117 | func = "putfont8"; break; 118 | case 0x3e2: 119 | func = "putfont8_asc"; break; 120 | case 0x48e: 121 | func = "sprintf"; break; 122 | case 0x4de: 123 | func = "strtoul0"; break; 124 | case 0x5d9: 125 | func = "vsprintf"; break; 126 | case 0x5d9 + (0x3e - 0x28): 127 | func = "vsprintf.L7"; 128 | break; 129 | case 0x5d9 + (0x209 - 0x28): 130 | func = "vsprintf.L11"; 131 | break; 132 | case 0x5d9 + (0x146 - 0x28): 133 | func = "vsprintf.L30"; 134 | break; 135 | case 0x5d9 + (0x120 - 0x28): 136 | func = "vsprintf.L79"; 137 | break; 138 | } 139 | if(!func.empty()) std::cout<Fetch(); 143 | 144 | idata->is_op32 = is_32 ^ idata->chsiz_op; 145 | idata->is_addr32 = is_32 ^ idata->chsiz_addr; 146 | 147 | if(idata->is_op32){ 148 | insn32->Decode(); 149 | insn32->Exec(); 150 | }else{ 151 | insn16->Decode(); 152 | insn16->Exec(); 153 | } 154 | 155 | DOUT(std::endl); 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /arch/x86/emulator.h: -------------------------------------------------------------------------------- 1 | #ifndef X86_EMULATOR_H_ 2 | #define X86_EMULATOR_H_ 3 | 4 | #include "../../emulator_base.h" 5 | #include "register.h" 6 | 7 | // 32bit registers 8 | #define EFLAGS emu->eflags 9 | #define EIP emu->pc.reg32 10 | #define EAX emu->reg[0].reg32 11 | #define ECX emu->reg[1].reg32 12 | #define EDX emu->reg[2].reg32 13 | #define EBX emu->reg[3].reg32 14 | #define ESP emu->reg[4].reg32 15 | #define EBP emu->reg[5].reg32 16 | #define ESI emu->reg[6].reg32 17 | #define EDI emu->reg[7].reg32 18 | 19 | // 16bit registers 20 | #define IP emu->pc.reg16 21 | #define AX emu->reg[0].reg16 22 | #define CX emu->reg[1].reg16 23 | #define DX emu->reg[2].reg16 24 | #define BX emu->reg[3].reg16 25 | #define SP emu->reg[4].reg16 26 | #define BP emu->reg[5].reg16 27 | #define SI emu->reg[6].reg16 28 | #define DI emu->reg[7].reg16 29 | 30 | // 8bit registers 31 | #define AL emu->reg[0].low8 32 | #define CL emu->reg[1].low8 33 | #define DL emu->reg[2].low8 34 | #define BL emu->reg[3].low8 35 | #define AH emu->reg[0].high8 36 | #define CH emu->reg[1].high8 37 | #define DH emu->reg[2].high8 38 | #define BH emu->reg[3].high8 39 | 40 | #define GET_REG8_NAME(num) (num<0x4 ? (emu->reg[num].GetName()) : (emu->reg[num-0x4].GetName())) 41 | #define GET_REG8(num) (num<0x4 ? (emu->reg[num].low8) : (emu->reg[num-0x4].high8)) 42 | #define SET_REG8(num, val) (num<0x4 ? (emu->reg[num].low8=val) : (emu->reg[num-0x4].high8=val)) 43 | 44 | // segment registers 45 | #define ES emu->sreg[0] 46 | #define CS emu->sreg[1] 47 | #define SS emu->sreg[2] 48 | #define DS emu->sreg[3] 49 | #define FS emu->sreg[4] 50 | #define GS emu->sreg[5] 51 | 52 | #define GET_CRN(num) (num==0x00 ? (emu->CR0.reg32) : (throw "GET_CRN: crn not found.")) 53 | #define SET_CRN(num, val) (num==0x00 ? (emu->CR0.reg32=val): (throw "SET_CRN: crn not found.")) 54 | 55 | // memory access(physical address) 56 | #define GET_MEM8(addr) (emu->memory->GetData8(addr)) 57 | #define GET_MEM16(addr) (emu->memory->GetData16(addr)) 58 | #define GET_MEM32(addr) (emu->memory->GetData32(addr)) 59 | 60 | #define SET_MEM8(addr, val) (emu->memory->SetData8(addr, static_cast(val)) ) 61 | #define SET_MEM16(addr, val) (emu->memory->SetData16(addr, static_cast(val))) 62 | #define SET_MEM32(addr, val) (emu->memory->SetData32(addr, static_cast(val))) 63 | 64 | // memory access with segmentation 65 | #define GET_SEG_MEM8(sreg, addr) (GET_MEM8(emu->L2P(sreg, addr)) ) 66 | #define GET_SEG_MEM16(sreg, addr) (GET_MEM16(emu->L2P(sreg, addr))) 67 | #define GET_SEG_MEM32(sreg, addr) (GET_MEM32(emu->L2P(sreg, addr))) 68 | 69 | #define SET_SEG_MEM8(sreg, addr, val) (SET_MEM8(emu->L2P(sreg, addr), val)) 70 | #define SET_SEG_MEM16(sreg, addr, val) (SET_MEM16(emu->L2P(sreg, addr), val)) 71 | #define SET_SEG_MEM32(sreg, addr, val) (SET_MEM32(emu->L2P(sreg, addr), val)) 72 | 73 | // memory access(code segment) 74 | #define GET_CODE8(offset) (GET_SEG_MEM8(CS, offset)) 75 | #define GET_CODE16(offset) (GET_SEG_MEM16(CS, offset)) 76 | #define GET_CODE32(offset) (GET_SEG_MEM32(CS, offset)) 77 | 78 | // memory access(data segment) 79 | #define GET_DATA8(addr) (GET_SEG_MEM8(sreg, addr)) 80 | #define GET_DATA16(addr) (GET_SEG_MEM16(sreg, addr)) 81 | #define GET_DATA32(addr) (GET_SEG_MEM32(sreg, addr)) 82 | 83 | #define SET_DATA8(addr, val) (SET_SEG_MEM8(sreg, addr, val)) 84 | #define SET_DATA16(addr, val) (SET_SEG_MEM16(sreg, addr, val)) 85 | #define SET_DATA32(addr, val) (SET_SEG_MEM32(sreg, addr, val)) 86 | 87 | namespace x86 { 88 | 89 | class InsnData; 90 | class Instruction; 91 | 92 | const size_t REG_COUNT = 8; 93 | const size_t SREG_COUNT= 6; 94 | 95 | class Emulator : public EmulatorBase { 96 | public: 97 | void InitInstructions(); 98 | void InitRegisters(); 99 | void InitMemory(); 100 | void InitIO(); 101 | protected: 102 | size_t mode; 103 | x86::Emulator *emu = this; 104 | x86::InsnData *idata; 105 | x86::Instruction *insn16, *insn32; 106 | InstructionBase *insn_cache; 107 | public: 108 | x86::Register32 pc; 109 | x86::Eflags eflags; 110 | std::vector reg; 111 | std::vector sreg; 112 | x86::MemManRegister GDTR, IDTR, TR, LDTR; 113 | x86::CR0_t CR0; 114 | 115 | bool IsMode16(){ return (mode == 16); } 116 | bool IsMode32(){ return (mode == 32); } 117 | 118 | void ChangeMode16(); 119 | void ChangeMode32(); 120 | void ChangeMode(){ (IsMode16() ? ChangeMode32() : ChangeMode16()); } 121 | 122 | inline bool IsReal(){ return (!CR0.PE); } 123 | inline bool IsProtected(){ return (CR0.PE); } 124 | 125 | void RunStep(); 126 | void Run(bool halt_exit){ 127 | while(!finish_flg && !(halt_exit && halt_flg)){ 128 | if(!halt_flg) 129 | RunStep(); 130 | } 131 | } 132 | 133 | struct Descriptor { 134 | union { 135 | uint32_t low32; 136 | struct { 137 | uint16_t limit_low; 138 | uint16_t base_low; 139 | }; 140 | }; 141 | 142 | union { 143 | uint32_t high32; 144 | struct { 145 | uint8_t base_mid; 146 | uint8_t type : 4; 147 | bool S : 1; // ディスクリプタ・タイプ(0:システム, 1:コードorデータ) 148 | uint8_t DPL : 2; // 特権レベル 149 | bool P : 1; // セグメント存在 150 | uint8_t limit_high : 4; 151 | bool AVL : 1; // システム・ソフトウェアが使用出来る 152 | bool : 1; // 虚無 153 | bool D_B : 1; // Dビット(0:16bitセグメント, 1:32bitセグメント) 154 | bool G : 1; // グラニュラリティ 155 | uint8_t base_high : 8; 156 | }; 157 | }; 158 | 159 | uint32_t GetLimit(){ 160 | // uint8_t high = limit_high; 161 | // DOUT(std::endl<<"llow=0x"<(high)<TI) throw "LDT is not implemented"; 211 | 212 | if(sreg->index*8 >= GDTR.limit) throw "out of GDTR"; 213 | desc.low32 = GET_MEM32(GDTR.base+(sreg->index*8)); 214 | desc.high32= GET_MEM32(GDTR.base+(sreg->index*8)+4); 215 | return desc; 216 | } 217 | inline Descriptor GetDesc(const SRegister &sreg){ return GetDesc(&sreg); } 218 | 219 | // logical addr to physical addr 220 | inline uint32_t L2P(const x86::SRegister* sreg, const uint32_t &addr){ 221 | if(!IsProtected()){ // real mode 222 | return (sreg->reg16 * 16) + addr; 223 | } 224 | 225 | // protect mode 226 | // DOUT("L2P: "<GetName()<<"="<GetDataByString()<TI) throw "TI=1, LDT is not implemented."; 230 | 231 | // DOUT(GDTR.GetName()<<": "<index == 0x00){ 234 | if(EFLAGS.IF){ 235 | std::cerr<<"#GP: null selector"<index*8 >= GDTR.limit) throw "out of GDTR"; 245 | desc.low32 = GET_MEM32(GDTR.base+(sreg->index*8)); 246 | desc.high32= GET_MEM32(GDTR.base+(sreg->index*8)+4); 247 | /* 248 | DOUT("desc: " << std::hex 249 | << std::setw(8) << desc.low32 250 | << ", 0x" 251 | << std::setw(8) << desc.high32 252 | << std::endl 253 | << "\t" 254 | << desc.GetDataByString() << std::endl); 255 | */ 256 | 257 | if(addr >= desc.GetLimit()*(desc.G ? 1024 : 1)){ 258 | debug::out_flg = true; 259 | DOUT("logical addr=0x"<(GetCode8(index)); } 273 | inline uint16_t GetCode16(int index) { return GET_SEG_MEM16(CS, EIP + index); } 274 | inline int16_t GetSignCode16(int index) { return static_cast(GetCode16(index)); } 275 | inline uint32_t GetCode32(int index) { return GET_SEG_MEM32(CS, EIP + index); } 276 | inline int32_t GetSignCode32(int index) { return static_cast(GetCode32(index)); } 277 | 278 | inline void push8(uint8_t val){ 279 | ESP--; 280 | SET_SEG_MEM8(SS, ESP, val); 281 | DOUT("push8: addr=0x"< 5 | #include 6 | #include "emulator.h" 7 | 8 | #define MOD modrm.mod 9 | #define RM modrm.rm 10 | 11 | namespace x86 { 12 | 13 | class InsnData { 14 | private: 15 | x86::Emulator *emu; 16 | public: 17 | struct ModRM { 18 | uint8_t rm : 3; 19 | uint8_t reg : 3; 20 | uint8_t mod : 2; 21 | }; 22 | 23 | struct SIB { 24 | uint8_t base : 3; 25 | uint8_t index : 3; 26 | uint8_t scale : 2; 27 | }; 28 | 29 | uint8_t prefix; 30 | uint8_t opcode; 31 | uint8_t subopcode; 32 | 33 | union { 34 | uint8_t _modrm; 35 | struct ModRM modrm; 36 | }; 37 | 38 | union { 39 | uint8_t _sib; 40 | struct SIB sib; 41 | }; 42 | 43 | union { 44 | int8_t disp8; 45 | int16_t disp16; 46 | int32_t disp32; 47 | }; 48 | 49 | union { 50 | int8_t imm8; 51 | int16_t imm16; 52 | int32_t imm32; 53 | }; 54 | 55 | uint16_t ptr16; 56 | 57 | uint32_t moffs; 58 | 59 | bool chsiz_op; // オペランドサイズ変更 60 | bool chsiz_addr; // アドレスサイズ変更 61 | 62 | bool is_op32; // オペランドサイズが32bitかどうか 63 | bool is_addr32; // アドレスサイズが32bitかどうか 64 | 65 | SRegister *sreg = &DS; 66 | public: 67 | InsnData(x86::Emulator *e); 68 | 69 | inline void ParseModRM16(){ 70 | DOUT("ModRM16: "); 71 | switch(MOD){ 72 | case 0b00: 73 | if(RM == 0b110) 74 | goto get_disp16; 75 | else 76 | break; 77 | case 0b01: 78 | goto get_disp8; 79 | case 0b10: 80 | goto get_disp16; 81 | case 0b11: 82 | break; 83 | get_disp8: 84 | disp8 = static_cast(emu->GetCode8(0)); 85 | EIP++; 86 | DOUT("disp8=0x"<(disp8)); 87 | break; 88 | get_disp16: 89 | disp16 = static_cast(emu->GetCode32(0)); 90 | EIP+=2; 91 | DOUT("disp16=0x"<GetCode8(0); 101 | EIP++; 102 | DOUT("SIB: scale=0x"<(sib.scale) 104 | << ", index=0x" 105 | << static_cast(sib.index) 106 | << ", base=0x" 107 | << static_cast(sib.base) 108 | << std::endl); 109 | } 110 | 111 | switch(MOD){ 112 | case 0b00: 113 | if(RM == 0b101) 114 | goto get_disp32; 115 | DOUT("reg"<(emu->GetCode8(0)); 125 | EIP++; 126 | DOUT("disp8: 0x"<(disp8)); 127 | break; 128 | get_disp32: 129 | disp32 = emu->GetSignCode32(0); 130 | EIP+=4; 131 | DOUT("disp32: 0x"<(disp8); 157 | break; 158 | case 0b10: 159 | addr = static_cast(disp16); 160 | break; 161 | } 162 | 163 | switch(RM){ 164 | case 0b000: 165 | case 0b001: 166 | case 0b111: 167 | addr += static_cast(BX); 168 | break; 169 | case 0b010: 170 | case 0b011: 171 | case 0b110: 172 | addr += static_cast(BP); 173 | //std::cerr<(SI); 181 | else 182 | addr += static_cast(DI); 183 | } 184 | 185 | return addr; 186 | } 187 | 188 | inline uint32_t CalcSibAddr(){ 189 | uint32_t addr = 0x00; 190 | 191 | if(sib.base == 0b101){ // [*] 192 | if(MOD == 0b00) addr += disp32; 193 | else{ 194 | sreg = &SS; 195 | addr += EBP; 196 | } 197 | }else{ 198 | auto& base_r32 = emu->reg[sib.base].reg32; 199 | if(sib.base == 0b100) sreg = &SS; // base_r32 = ESP 200 | addr += base_r32; 201 | } 202 | 203 | if(sib.index != 0b100){ 204 | auto& index_r32 = emu->reg[sib.index].reg32; 205 | if(sib.index == 0b101) sreg = &SS; // index_r32 = EBP 206 | addr += index_r32 * (1 << sib.scale); // scaled index 207 | } 208 | 209 | return addr; 210 | /* 211 | uint32_t base = 0x00, index; 212 | if(sib.base == 0b100) 213 | sreg = &SS; 214 | if(sib.base == 0b101){ 215 | // throw "not implemented: SIB.base=0b101"; 216 | std::cout<reg[sib.base].reg32; 222 | 223 | if(sib.index == 0b100) 224 | index = 0x00; // none 225 | else 226 | index = emu->reg[sib.index].reg32; 227 | 228 | addr += base + (index * (1<reg[RM].reg32; 244 | } 245 | case 0b01: 246 | if(RM == 0b100) // SIB 247 | return CalcSibAddr() + disp8; 248 | else{ 249 | if(RM == 0b101) sreg = &SS; // EBP 250 | return emu->reg[RM].reg32 + disp8; 251 | } 252 | case 0b10: 253 | if(RM == 0b100) // SIB 254 | return CalcSibAddr() + disp32; 255 | else{ 256 | if(RM == 0b101) sreg = &SS; // EBP 257 | return emu->reg[RM].reg32 + disp32; 258 | } 259 | case 0b11: 260 | break; 261 | } 262 | std::stringstream ss; 263 | ss << "not implemented ModRM: Mod="<(MOD) 264 | << ", R/M="<(RM); 265 | throw ss.str(); 266 | } 267 | 268 | // get register 269 | inline uint8_t GetR8(){ 270 | return GET_REG8(modrm.reg); 271 | } 272 | inline uint16_t GetR16(){ 273 | return emu->reg[modrm.reg].reg16; 274 | } 275 | inline uint32_t GetR32(){ 276 | return emu->reg[modrm.reg].reg32; 277 | } 278 | 279 | // set register 280 | inline void SetR8(uint8_t val){ 281 | SET_REG8(modrm.reg, val); 282 | } 283 | inline void SetR16(uint16_t val){ 284 | emu->reg[modrm.reg].reg16 = val; 285 | } 286 | inline void SetR32(uint32_t val){ 287 | emu->reg[modrm.reg].reg32 = val; 288 | } 289 | 290 | // get rm 291 | inline uint8_t GetRM8(){ 292 | if(MOD == 3) 293 | return GET_REG8(RM); 294 | auto addr = CalcMemAddr(); 295 | // DOUT("GetRM8: addr=0x"<reg[RM].reg16; 301 | auto addr = CalcMemAddr(); 302 | // DOUT("GetRM16: addr=0x"<reg[RM]; 308 | // DOUT("GetRM32: reg:"<reg[RM].GetName() 321 | <<" = 0x"<(val)<(val)<reg[RM].reg16 = val; 332 | DOUT("SetRM16: "<reg[RM].GetName()<<" = 0x"<reg[RM].reg32 = val; 343 | DOUT("SetRM32: reg="<reg[RM].GetName()<<" val="< 2 | #include "instruction.h" 3 | #include "emulator.h" 4 | 5 | #define SETINSN(op,func,insn_flg) {insn[op] = (insnfunc_t)&x86::Instruction::func; insn_name[op] = #func; insn_flgs[op] = insn_flg;} 6 | 7 | namespace x86 { 8 | 9 | void Instruction::Init(){ 10 | // default insn 11 | ClearInsn(256); 12 | idata->opcode = 0x90; 13 | 14 | // SETINSN(0x00, add_rm8_r8, Flag::ModRM); 15 | SETINSN(0x0f, code_0f, Flag::None); // とりあえずNoneにしておく 16 | SETINSN(0x24, and_al_imm8, Flag::Imm8); 17 | SETINSN(0x3c, cmp_al_imm8, Flag::Imm8); 18 | SETINSN(0x70, jo_rel8, Flag::Imm8); 19 | SETINSN(0x71, jno_rel8, Flag::Imm8); 20 | SETINSN(0x72, jb_rel8, Flag::Imm8); // = jc,jnae 21 | SETINSN(0x73, jae_rel8, Flag::Imm8); // = jnb,jnc 22 | SETINSN(0x74, je_rel8, Flag::Imm8); // = jz 23 | SETINSN(0x75, jne_rel8, Flag::Imm8); // = jnz 24 | SETINSN(0x76, jbe_rel8, Flag::Imm8); // = jna 25 | SETINSN(0x77, ja_rel8, Flag::Imm8); // = jnbe 26 | SETINSN(0x78, js_rel8, Flag::Imm8); 27 | SETINSN(0x79, jns_rel8, Flag::Imm8); 28 | SETINSN(0x7a, jp_rel8, Flag::Imm8); // = jpe 29 | SETINSN(0x7b, jpo_rel8, Flag::Imm8); 30 | SETINSN(0x7c, jl_rel8, Flag::Imm8); // = jnge 31 | SETINSN(0x7d, jge_rel8, Flag::Imm8); // = jnl 32 | SETINSN(0x7e, jle_rel8, Flag::Imm8); // = jng 33 | SETINSN(0x7f, jg_rel8, Flag::Imm8); // = jnle 34 | SETINSN(0x80, code_80, Flag::ModRM | Flag::Imm8); 35 | SETINSN(0x84, test_rm8_r8, Flag::ModRM); 36 | SETINSN(0x88, mov_rm8_r8, Flag::ModRM); 37 | SETINSN(0x8a, mov_r8_rm8, Flag::ModRM); 38 | SETINSN(0x8e, mov_sreg_rm16, Flag::ModRM); 39 | SETINSN(0x90, nop, Flag::None); 40 | SETINSN(0xa2, mov_moffs8_al, Flag::Moffs); 41 | for(auto i=0;i<8;i++) 42 | SETINSN(0xb0+i, mov_r8_imm8, Flag::Imm8); 43 | SETINSN(0xc0, code_c0, Flag::ModRM | Flag::Imm8); 44 | SETINSN(0xc6, mov_rm8_imm8, Flag::ModRM | Flag::Imm8); 45 | SETINSN(0xcd, int_imm8, Flag::Imm8); 46 | // SETINSN(0xe9, near_jump, 0); // TODO: 32bitだったので32bitの方に移す 47 | SETINSN(0xe4, in_al_imm8, Flag::Imm8); 48 | SETINSN(0xe6, out_imm8_al, Flag::Imm8); 49 | SETINSN(0xeb, short_jump, Flag::Imm8); 50 | SETINSN(0xee, out_dx_al, Flag::None); 51 | SETINSN(0xf4, hlt, Flag::None); 52 | SETINSN(0xfa, cli, Flag::None); 53 | } 54 | 55 | void Instruction::Fetch(){ 56 | // parse prefix 57 | // bochs/cpu/fetchdecode.cc fetchDecode32 58 | // is_32 = BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b; 59 | idata->chsiz_op = idata->chsiz_addr = false; 60 | 61 | for(;;){ 62 | idata->opcode = emu->GetCode8(0); 63 | switch(idata->opcode){ 64 | case 0xf0: 65 | case 0xf2: 66 | case 0xf3: 67 | case 0x26: 68 | case 0x2e: 69 | case 0x36: 70 | case 0x3e: 71 | case 0x64: 72 | case 0x65: 73 | goto not_impl; 74 | case 0x66: // op size 75 | DOUT("0x66: operand size prefix"<chsiz_op = true; 77 | goto next; 78 | case 0x67: // addr size 79 | DOUT("0x67: address size prefix"<chsiz_addr = true; 81 | goto next; 82 | next: 83 | idata->prefix = idata->opcode; 84 | EIP++; 85 | continue; 86 | not_impl: 87 | { 88 | std::stringstream ss; 89 | ss << "not implemented prefix:" 90 | << std::hex << std::showbase 91 | << static_cast(idata->prefix) 92 | << std::endl; 93 | throw ss.str(); 94 | } 95 | default: 96 | idata->prefix = 0x00; 97 | goto no_prefix; 98 | } 99 | } 100 | 101 | no_prefix: 102 | EIP++; 103 | /* 104 | if(idata->opcode == 0x0f){ 105 | auto flgs = insn_flgs[idata->opcode]; 106 | idata->subopcode = emu->GetCode8(0); 107 | switch(idata->subopcode){ 108 | case 0x01: 109 | case 0x20: 110 | case 0x22: 111 | case 0xb6: 112 | flgs |= Flag::ModRM; 113 | std::cout<(idata->subopcode); 120 | throw ss.str(); 121 | break; 122 | } 123 | 124 | insn_flgs[idata->opcode] = flgs; 125 | if(insn_flgs[idata->opcode] & Flag::ModRM) DOUT("modrm"<(idata->opcode) 136 | << ": " << insn_name[idata->opcode] 137 | << "\t" 138 | ); 139 | 140 | if(idata->opcode == 0x0f){ 141 | auto flgs = insn_flgs[idata->opcode]; 142 | idata->subopcode = emu->GetCode8(0); 143 | switch(idata->subopcode){ 144 | case 0x01: 145 | case 0x20: 146 | case 0x22: 147 | flgs = Flag::ModRM; 148 | break; 149 | // Jcc rel16/rel32 150 | case 0x80: case 0x81: case 0x82: case 0x83: 151 | case 0x84: case 0x85: case 0x86: case 0x87: 152 | case 0x88: case 0x89: case 0x8a: case 0x8b: 153 | case 0x8c: case 0x8d: case 0x8e: case 0x8f: 154 | flgs = (idata->is_op32 ? Flag::Imm32 : Flag::Imm16); 155 | break; 156 | case 0xaf: 157 | case 0xbf: 158 | case 0xb6: 159 | case 0xbe: 160 | flgs = Flag::ModRM; 161 | break; 162 | default: 163 | std::stringstream ss; 164 | ss << "not implemented 0x0f: subop=0x" 165 | << std::hex 166 | << static_cast(idata->subopcode); 167 | throw ss.str(); 168 | break; 169 | } 170 | 171 | insn_flgs[idata->opcode] = flgs; 172 | EIP++; 173 | } 174 | 175 | const auto flgs = insn_flgs[idata->opcode]; 176 | 177 | //if ModR/M 178 | if(flgs & Flag::ModRM){ 179 | idata->_modrm = emu->GetCode8(0); 180 | DOUT("ModRM=0x" << std::hex 181 | << static_cast(idata->_modrm) 182 | << "(Mod=0x" 183 | << static_cast(idata->MOD) 184 | << " REG=0x" 185 | << static_cast(idata->modrm.reg) 186 | << " RM=0x" 187 | << static_cast(idata->RM) 188 | << ") "); 189 | EIP++; 190 | if(idata->is_addr32) 191 | idata->ParseModRM32(); 192 | else 193 | idata->ParseModRM16(); 194 | } 195 | 196 | // imm 197 | if(flgs & Flag::Imm8){ 198 | uint8_t data = emu->GetCode8(0); 199 | idata->imm8 = static_cast(data); 200 | EIP++; 201 | DOUT(" imm8=0x"<(data)); 202 | } 203 | if(flgs & Flag::Imm16){ 204 | idata->imm16 = emu->GetSignCode16(0); 205 | EIP+=2; 206 | DOUT(" imm16=0x"<imm16); 207 | } 208 | if(flgs & Flag::Imm32){ 209 | idata->imm32 = emu->GetSignCode32(0); 210 | EIP+=4; 211 | DOUT(" imm32=0x"<imm32); 212 | } 213 | 214 | if(flgs & Flag::Ptr16){ 215 | idata->ptr16 = emu->GetCode16(0); 216 | EIP+=2; 217 | DOUT(" ptr16=0x"<ptr16); 218 | } 219 | 220 | if(flgs & Flag::Moffs){ 221 | if(!idata->is_addr32){ 222 | idata->moffs = static_cast(emu->GetCode16(0)); 223 | EIP+=2; 224 | }else{ 225 | idata->moffs = emu->GetCode32(0); 226 | EIP+=4; 227 | } 228 | } 229 | 230 | } 231 | 232 | void Instruction::Exec(){ 233 | insnfunc_t func = insn[idata->opcode]; 234 | (this->*func)(); 235 | } 236 | 237 | void Instruction::not_impl_insn(){ 238 | std::stringstream ss; 239 | ss << "x86: not implemented insn : 0x" 240 | << std::setw(2) << std::setfill('0') << std::hex 241 | << static_cast(idata->opcode); 242 | throw ss.str(); 243 | } 244 | 245 | }; 246 | -------------------------------------------------------------------------------- /arch/x86/instruction.h: -------------------------------------------------------------------------------- 1 | #ifndef X86_INSTRUCTION_H_ 2 | #define X86_INSTRUCTION_H_ 3 | 4 | #include 5 | #include "../../insn_base.h" 6 | #include "emulator.h" 7 | #include "insndata.h" 8 | 9 | namespace x86 { 10 | 11 | class Instruction : public InstructionBase { 12 | public: 13 | Instruction(x86::Emulator *e, x86::InsnData *i) : emu(e), idata(i) { insn_name.resize(256); } 14 | ~Instruction(){} 15 | virtual void Init(); 16 | void Fetch(); 17 | void Decode(); 18 | void Exec(); 19 | protected: 20 | x86::Emulator *emu; 21 | x86::InsnData *idata; 22 | struct Flag { 23 | static const uint8_t None = 0b000000; 24 | static const uint8_t ModRM = 0b000001; 25 | static const uint8_t Imm8 = 0b000010; 26 | static const uint8_t Imm16 = 0b000100; 27 | static const uint8_t Imm32 = 0b001000; 28 | static const uint8_t Moffs = 0b010000; 29 | static const uint8_t Ptr16 = 0b100000; 30 | }; 31 | uint8_t insn_flgs[256]; 32 | 33 | void not_impl_insn(); 34 | 35 | void code_0f(){ 36 | DOUT(std::endl<<"subop=0x"<(idata->subopcode)); 37 | switch(idata->subopcode){ 38 | case 0x01: code_0f01(); break; 39 | case 0x20: mov_r32_crn(); break; 40 | case 0x22: mov_crn_r32(); break; 41 | 42 | // Jcc 43 | #define SET_JCC(subop, opname) \ 44 | case subop: (idata->is_op32 ? opname ## _rel32() : opname ## _rel16()); break; 45 | 46 | SET_JCC(0x80, jo); 47 | SET_JCC(0x81, jno); 48 | SET_JCC(0x82, jb); // = jc,jnae 49 | SET_JCC(0x83, jae); // = jnb,jnc 50 | SET_JCC(0x84, je); // = jz 51 | SET_JCC(0x85, jne); // = jnz 52 | SET_JCC(0x86, jbe); // = jna 53 | SET_JCC(0x87, ja); // = jnbe 54 | SET_JCC(0x88, js); 55 | SET_JCC(0x89, jns); 56 | SET_JCC(0x8a, jp); // = jpe 57 | SET_JCC(0x8b, jpo); 58 | SET_JCC(0x8c, jl); // = jnge 59 | SET_JCC(0x8d, jge); // = jnl 60 | SET_JCC(0x8e, jle); // = jng 61 | SET_JCC(0x8f, jg); // = jnle 62 | 63 | case 0xaf: (idata->is_op32 ? imul_r32_rm32() : imul_r16_rm16()); break; 64 | case 0xb6: (idata->is_op32 ? movzx_r32_rm8() : movzx_r16_rm8()); break; 65 | case 0xbe: (idata->is_op32 ? movsx_r32_rm8() : movsx_r16_rm8()); break; 66 | case 0xbf: movsx_r32_rm16(); break; 67 | default: 68 | throw "not implemented: 0x0f subop"; 69 | } 70 | } 71 | void code_0f01(){ 72 | DOUT(" /"<(idata->modrm.reg)); 73 | switch(idata->modrm.reg){ 74 | case 2: lgdt(); break; 75 | default: 76 | std::stringstream ss; 77 | ss << "not implemented: 0x0f01 /" 78 | << static_cast(idata->modrm.reg); 79 | throw ss.str(); 80 | break; 81 | } 82 | } 83 | void lgdt(){ 84 | uint32_t addr = idata->CalcMemAddr(); 85 | // GDTR.limit = SRC[0:15]; 86 | uint16_t limit; 87 | uint32_t base; 88 | if(!idata->is_op32){ 89 | uint16_t addr16 = static_cast(addr); 90 | addr = addr16; 91 | limit = emu->memory->GetData16(addr16); 92 | // GDTR.base = SRC[16:47] & 0xffffff; 93 | base = emu->memory->GetData32(addr16+2) & 0xffffff; 94 | }else{ 95 | limit = emu->memory->GetData16(addr); 96 | // GDTR.base = SRC[16:47]; 97 | base = emu->memory->GetData32(addr+2); 98 | } 99 | emu->GDTR.limit = limit; 100 | emu->GDTR.base = base; 101 | 102 | DOUT(std::endl<<"LGDT: GDTR <- [0x"<reg[idata->RM]; 106 | auto n = idata->modrm.reg; 107 | uint32_t crn = GET_CRN(n); 108 | r32.reg32 = crn; 109 | DOUT(std::endl<<__func__<<": "<(n)<<"(0x"<reg[idata->RM]; 113 | auto n = idata->modrm.reg; 114 | SET_CRN(n, r32.reg32); 115 | DOUT(std::endl<<__func__<<": CR"<(n)<<" <- "<CR0.PE) 117 | DOUT(std::endl<<"Protect Enable"); 118 | if(emu->CR0.PG) 119 | throw "not implemented: paging"; 120 | } 121 | 122 | // Jcc: Jump if Condition Is Met 123 | // j*_rel32 124 | // j*_rel16 125 | 126 | void imul_r32_rm32(){ 127 | auto& reg = emu->reg[idata->modrm.reg]; 128 | int32_t s_r32 = reg.reg32; 129 | int32_t s_rm32 = idata->GetRM32(); 130 | int64_t temp = s_r32 * s_rm32; 131 | reg.reg32 = temp; 132 | DOUT(__func__ << ": " 133 | << reg.GetName() << " <- " 134 | << reg.GetName() << "(0x" << std::hex << s_r32 << ")" 135 | << " * 0x" << s_rm32 136 | << " = 0x" << temp 137 | << std::endl); 138 | if(temp != reg.reg32){ 139 | if(EFLAGS.CF) EFLAGS.OF = 1; 140 | else EFLAGS.OF = 0; 141 | } 142 | // throw __func__; 143 | } 144 | void imul_r16_rm16(){ 145 | throw __func__; 146 | } 147 | void movzx_r32_rm8(){ 148 | auto& reg = emu->reg[idata->modrm.reg]; 149 | auto rm8 = idata->GetRM8(); 150 | DOUT(std::endl<<__func__<<": "<(rm8)<<")"<reg[idata->modrm.reg]; 158 | int8_t s_rm8 = idata->GetRM8(); 159 | int32_t set = static_cast(s_rm8); 160 | DOUT(__func__<<": "<(s_rm8)<<") = 0x"<reg[idata->modrm.reg]; 168 | int16_t s_rm16 = idata->GetRM16(); 169 | int32_t set = static_cast(s_rm16); 170 | DOUT(__func__<<": "<imm8; 177 | EFLAGS.UpdateAnd(al, idata->imm8, al&idata->imm8); 178 | } 179 | 180 | void cmp_al_imm8(){ 181 | uint8_t al = AL; 182 | EFLAGS.Cmp(al, idata->imm8); 183 | } 184 | 185 | // Jump if Condition Is Met 186 | #define DEF_JCC_REL8(flag, is_flag) \ 187 | void j ## flag ## _rel8(){ \ 188 | if(is_flag) EIP += idata->imm8; \ 189 | } 190 | #define DEF_JCC_REL16(flag, is_flag) \ 191 | void j ## flag ## _rel16(){ \ 192 | if(is_flag) EIP += idata->imm16; \ 193 | } 194 | #define DEF_JCC_REL32(flag, is_flag) \ 195 | void j ## flag ## _rel32(){ \ 196 | if(is_flag) EIP += idata->imm32; \ 197 | } 198 | 199 | #define DEF_JCC(flag, is_flag) \ 200 | DEF_JCC_REL8(flag, is_flag); \ 201 | DEF_JCC_REL16(flag, is_flag); \ 202 | DEF_JCC_REL32(flag, is_flag); 203 | 204 | DEF_JCC(o, EFLAGS.OF); 205 | DEF_JCC(no, !EFLAGS.OF); 206 | DEF_JCC(b, EFLAGS.CF); // jb =jc =jnae 207 | DEF_JCC(ae, !EFLAGS.CF); // jae=jnb=jnc 208 | DEF_JCC(e, EFLAGS.ZF); // je =jz 209 | DEF_JCC(ne, !EFLAGS.ZF); // jne=jnz 210 | DEF_JCC(be, EFLAGS.CF || EFLAGS.ZF); // jbe=jna 211 | DEF_JCC(a, !EFLAGS.CF && !EFLAGS.ZF); // ja =jnbe 212 | DEF_JCC(s, EFLAGS.SF); 213 | DEF_JCC(ns, !EFLAGS.SF); 214 | DEF_JCC(p, EFLAGS.PF); // jp =jpe 215 | DEF_JCC(po, !EFLAGS.PF); 216 | DEF_JCC(l, EFLAGS.SF != EFLAGS.OF); // jl =jnge 217 | DEF_JCC(ge, EFLAGS.SF == EFLAGS.OF); // jge=jnl 218 | DEF_JCC(le, EFLAGS.ZF || (EFLAGS.SF != EFLAGS.OF)); // jle=jng 219 | DEF_JCC(g, !EFLAGS.ZF && (EFLAGS.SF == EFLAGS.OF)); // jg = jnle 220 | 221 | void code_80(){ 222 | DOUT(" REG="<(idata->modrm.reg)<<" "); 223 | switch(idata->modrm.reg){ 224 | case 0: add_rm8_imm8(); break; 225 | case 4: and_rm8_imm8(); break; 226 | case 7: cmp_rm8_imm8(); break; 227 | default: 228 | { 229 | std::stringstream ss; 230 | ss << "not implemented: 0x80 /"<(idata->modrm.reg); 231 | throw ss.str(); 232 | } 233 | } 234 | } 235 | void add_rm8_imm8(){ 236 | auto rm8 = idata->GetRM8(); 237 | uint16_t tmp = rm8 + idata->imm8; 238 | idata->SetRM8(static_cast(tmp)); 239 | EFLAGS.UpdateAdd(rm8, idata->imm8, tmp); 240 | } 241 | void and_rm8_imm8(){ 242 | auto rm8 = idata->GetRM8(); 243 | uint16_t tmp = rm8 & idata->imm8; 244 | idata->SetRM8(static_cast(tmp)); 245 | EFLAGS.UpdateAnd(rm8, idata->imm8, tmp); 246 | } 247 | void cmp_rm8_imm8(){ 248 | EFLAGS.Cmp(idata->GetRM8(), idata->imm8); 249 | } 250 | 251 | void test_rm8_r8(){ 252 | uint8_t rm8 = idata->GetRM8(); 253 | uint8_t r8 = GET_REG8(idata->modrm.reg); 254 | EFLAGS.UpdateTest(rm8, r8); 255 | } 256 | 257 | void mov_rm8_r8(){ 258 | uint8_t reg8 = GET_REG8(idata->modrm.reg); 259 | DOUT(__func__<<": "<modrm.reg)<<"=0x"<SetRM8(reg8); 261 | } 262 | 263 | void mov_r8_rm8(){ 264 | auto rm8 = idata->GetRM8(); 265 | SET_REG8(idata->modrm.reg, rm8); 266 | DOUT(std::endl<<"\t"<modrm.reg)<<"=0x"<(rm8)); 267 | } 268 | 269 | void mov_sreg_rm16(){ 270 | auto rm16 = idata->GetRM16(); 271 | auto& sreg = emu->sreg[idata->modrm.reg]; 272 | sreg = rm16; 273 | DOUT(std::endl<<"\t"<memory->SetData8(idata->moffs, AL); 280 | DOUT("[0x"<moffs<<"] = AL("<(AL)<<")"<GetCode32(1); 286 | EIP += (diff + 4); 287 | } 288 | */ 289 | void mov_r8_imm8(){ 290 | uint8_t reg8 = idata->opcode - 0xb0; 291 | SET_REG8(reg8, idata->imm8); 292 | } 293 | 294 | void code_c0(){ 295 | switch(idata->modrm.reg){ 296 | case 5: shr_rm8_imm8(); break; 297 | default: 298 | std::stringstream ss; 299 | ss << "not implemented: 0xc0 /" 300 | << std::dec << static_cast(idata->modrm.reg); 301 | throw ss.str(); 302 | } 303 | } 304 | void shr_rm8_imm8(){ 305 | uint8_t rm8 = idata->GetRM8(); 306 | uint64_t result = rm8 >> idata->imm8; 307 | idata->SetRM8(result); 308 | EFLAGS.UpdateShr(rm8, idata->imm8, result); 309 | } 310 | 311 | void mov_rm8_imm8(){ 312 | idata->SetRM8(idata->imm8); 313 | } 314 | 315 | void int_imm8(){ 316 | DOUT(std::endl<<"\tint "<(idata->imm8)); 317 | emu->bios->Function(static_cast(idata->imm8)); 318 | } 319 | 320 | void in_al_imm8(){ 321 | uint8_t port = idata->imm8; 322 | AL = emu->io->in8(port); 323 | } 324 | 325 | void out_imm8_al(){ 326 | uint8_t port = idata->imm8; 327 | emu->io->out8(port, AL); 328 | } 329 | 330 | void short_jump(){ 331 | IP += static_cast(idata->imm8); 332 | } 333 | 334 | void out_dx_al(){ 335 | DOUT(__func__<<": port[0x"<(AL)<io->out8(DX, AL); 338 | } 339 | 340 | void hlt(){ 341 | std::cout<<"hlt"<halt_flg = true; 343 | } 344 | 345 | void cli(){ 346 | EFLAGS.IF = 0; 347 | } 348 | }; 349 | 350 | }; 351 | 352 | #endif 353 | -------------------------------------------------------------------------------- /arch/x86/instruction16.cc: -------------------------------------------------------------------------------- 1 | #include "instruction16.h" 2 | 3 | #define SETINSN(op,func,insn_flg) {insn[op] = (insnfunc_t)&x86::Instruction16::func; insn_name[op] = #func; insn_flgs[op] = insn_flg;} 4 | 5 | namespace x86 { 6 | 7 | void Instruction16::Init(){ 8 | Instruction::Init(); 9 | 10 | SETINSN(0x05, add_ax_imm16, Flag::Imm16); 11 | SETINSN(0x6a, push_imm8, Flag::Imm8); 12 | SETINSN(0x83, code_83, Flag::ModRM | Flag::Imm8); 13 | SETINSN(0x8c, mov_rm16_sreg, Flag::ModRM); 14 | for(auto i=0;i<8;i++) 15 | SETINSN(0xb8+i, mov_r16_imm16, Flag::Imm16); 16 | SETINSN(0xc1, code_c1, Flag::ModRM | Flag::Imm8); 17 | SETINSN(0xc3, ret, Flag::None); 18 | SETINSN(0xc7, mov_rm16_imm16, Flag::ModRM | Flag::Imm16); 19 | SETINSN(0xe8, call_rel16, Flag::Imm16); 20 | SETINSN(0xe9, jmp_rel16, Flag::Imm16); 21 | } 22 | 23 | }; 24 | -------------------------------------------------------------------------------- /arch/x86/instruction16.h: -------------------------------------------------------------------------------- 1 | #ifndef X86_INSTRUCTION16_H_ 2 | #define X86_INSTRUCTION16_H_ 3 | 4 | #include "instruction.h" 5 | 6 | namespace x86 { 7 | 8 | class Instruction16 : public x86::Instruction { 9 | public: 10 | Instruction16(x86::Emulator *e, InsnData *i) : x86::Instruction(e, i) {} 11 | void Init(); 12 | 13 | void add_ax_imm16(){ 14 | uint16_t old = AX; 15 | AX = AX + idata->imm16; 16 | EFLAGS.UpdateAdd(old, idata->imm16, AX); 17 | } 18 | 19 | void push_imm8(){ 20 | uint16_t tmp16 = idata->imm8; 21 | emu->push16(tmp16); 22 | } 23 | 24 | void add_rm16_imm8(){ 25 | DOUT("\n\t"<<__func__<<" "); 26 | uint16_t rm16 = idata->GetRM16(); 27 | uint16_t result = rm16 + idata->imm8; 28 | idata->SetRM16(result); 29 | EFLAGS.UpdateAdd(rm16, idata->imm8, result); 30 | } 31 | void cmp_rm16_imm8(){ 32 | uint16_t rm16 = idata->GetRM16(); 33 | EFLAGS.Cmp(rm16, idata->imm8); 34 | } 35 | void code_83(){ 36 | DOUT(" REG="<(idata->modrm.reg)<<" "); 37 | switch(idata->modrm.reg){ 38 | case 0: add_rm16_imm8(); break; 39 | case 7: cmp_rm16_imm8(); break; 40 | default: 41 | { 42 | std::stringstream ss; 43 | ss << "not implemented: 0x83 /"<(idata->modrm.reg); 44 | throw ss.str(); 45 | } 46 | } 47 | } 48 | 49 | void mov_rm16_sreg(){ 50 | uint16_t sreg = emu->sreg[idata->modrm.reg].reg16; 51 | idata->SetRM16(sreg); 52 | } 53 | 54 | void mov_r16_imm16(){ 55 | uint8_t num = idata->opcode & ((1<<3)-1); 56 | auto& reg = emu->reg[num]; 57 | reg = idata->imm16; 58 | DOUT(std::endl<<"\t"<imm16); 59 | } 60 | 61 | void code_c1(){ 62 | switch(idata->modrm.reg){ 63 | case 4: sal_rm16_imm8(); break; 64 | default: 65 | std::stringstream ss; 66 | ss << "not implemented: 0xc1 /" << static_cast(idata->modrm.reg); 67 | throw ss.str(); 68 | } 69 | } 70 | void sal_rm16_imm8(){ 71 | uint16_t rm16 = idata->GetRM16(); 72 | uint32_t result = rm16 << idata->imm8; 73 | EFLAGS.UpdateSal(rm16, idata->imm8, result); 74 | idata->SetRM16(result); 75 | } 76 | 77 | void ret(){ 78 | IP = emu->pop16(); 79 | debug::out_flg = true; 80 | } 81 | 82 | void mov_rm16_imm16(){ 83 | idata->SetRM16(idata->imm16); 84 | } 85 | 86 | void call_rel16(){ 87 | std::cout<<"ESI=0x"<push16(IP); 90 | IP += idata->imm16; 91 | } 92 | 93 | void jmp_rel16(){ 94 | EIP += idata->imm16; 95 | } 96 | }; 97 | 98 | }; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /arch/x86/instruction32.cc: -------------------------------------------------------------------------------- 1 | #include "instruction32.h" 2 | 3 | #define SETINSN(op,func,flg) {insn[op] = (insnfunc_t)&x86::Instruction32::func; insn_flgs[op] = flg;} 4 | 5 | namespace x86 { 6 | 7 | void Instruction32::Init(){ 8 | Instruction::Init(); 9 | 10 | SETINSN(0x01, add_rm32_r32, Flag::ModRM); 11 | SETINSN(0x03, add_r32_rm32, Flag::ModRM); 12 | SETINSN(0x05, add_eax_imm32, Flag::Imm32); 13 | SETINSN(0x25, and_eax_imm32, Flag::Imm32); 14 | SETINSN(0x29, sub_rm32_r32, Flag::ModRM); 15 | SETINSN(0x31, xor_rm32_r32, Flag::ModRM); 16 | SETINSN(0x39, cmp_rm32_r32, Flag::ModRM); 17 | SETINSN(0x3b, cmp_r32_rm32, Flag::ModRM); 18 | for(int i=0;i<8;i++){ 19 | SETINSN(0x40+i, inc_r32, Flag::None); 20 | SETINSN(0x48+i, dec_r32, Flag::None); 21 | SETINSN(0x50+i, push_r32, Flag::None); 22 | SETINSN(0x58+i, pop_r32, Flag::None); 23 | } 24 | SETINSN(0x68, push_imm32, Flag::Imm32); 25 | SETINSN(0x69, imul_r32_rm32_imm32, Flag::ModRM | Flag::Imm32); // = imul_r32_imm32 26 | SETINSN(0x6a, push_imm8, Flag::Imm8); 27 | SETINSN(0x81, code_81, Flag::ModRM | Flag::Imm32); 28 | SETINSN(0x83, code_83, Flag::ModRM | Flag::Imm8); 29 | SETINSN(0x85, test_rm32_r32, Flag::ModRM); 30 | SETINSN(0x89, mov_rm32_r32, Flag::ModRM); 31 | SETINSN(0x8B, mov_r32_rm32, Flag::ModRM); 32 | SETINSN(0x8d, lea_r32_m, Flag::ModRM); 33 | SETINSN(0x9c, pushfd, Flag::None); 34 | SETINSN(0x9d, popfd, Flag::None); 35 | for(int i=0;i<8;i++) 36 | SETINSN(0xB8+i, mov_r32_imm32, Flag::Imm32); 37 | SETINSN(0xC1, code_c1, Flag::ModRM | Flag::Imm8); 38 | SETINSN(0xc3, ret32, Flag::None); 39 | SETINSN(0xC7, mov_rm32_imm32, Flag::ModRM | Flag::Imm32); 40 | SETINSN(0xc9, leave32, Flag::None); 41 | SETINSN(0xE8, call_rel32, Flag::Imm32); 42 | SETINSN(0xe9, jmp_rel32, Flag::Imm32); // near jump 43 | SETINSN(0xea, jmp_ptr16_32, Flag::Ptr16 | Flag::Imm32); // far jump 44 | SETINSN(0xf7, code_f7, Flag::ModRM); 45 | SETINSN(0xff, code_ff, Flag::ModRM); 46 | } 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /arch/x86/instruction32.h: -------------------------------------------------------------------------------- 1 | #ifndef X86_INSTRUCTION32_H_ 2 | #define X86_INSTRUCTION32_H_ 3 | #include 4 | #include "instruction.h" 5 | 6 | namespace x86 { 7 | 8 | class Instruction32 : public x86::Instruction { 9 | public: 10 | Instruction32(x86::Emulator *e, InsnData *i) : Instruction(e, i) {} 11 | void Init(); 12 | private: 13 | void add_rm32_r32(){ 14 | auto rm32 = idata->GetRM32(); 15 | auto& reg = emu->reg[idata->modrm.reg]; 16 | uint32_t r32 = reg.reg32; 17 | uint64_t set = rm32 + r32; 18 | idata->SetRM32(set); 19 | EFLAGS.UpdateAdd(rm32, r32, set); 20 | } 21 | 22 | void add_r32_rm32(){ 23 | auto& reg = emu->reg[idata->modrm.reg]; 24 | auto rm32 = idata->GetRM32(); 25 | uint64_t result = reg.reg32 + rm32; 26 | DOUT(reg.GetName()<<" <- "<imm32); 33 | uint64_t result = EAX + idata->imm32; 34 | EFLAGS.UpdateAdd(EAX, idata->imm32, result); 35 | EAX = result; 36 | } 37 | 38 | void and_eax_imm32(){ 39 | DOUT(std::endl<<"EAX <- EAX(0x"<imm32); 40 | uint64_t result = EAX & idata->imm32; 41 | DOUT(" = 0x"<imm32, result); 43 | EAX = result; 44 | } 45 | 46 | void sub_rm32_r32(){ 47 | uint32_t rm32 = idata->GetRM32(); 48 | auto& r = emu->reg[idata->modrm.reg]; 49 | auto r32 = r.reg32; 50 | uint32_t result = rm32 - r32; 51 | idata->SetRM32(result); 52 | EFLAGS.UpdateSub(rm32, r32, result); 53 | } 54 | 55 | void xor_rm32_r32(){ 56 | uint32_t rm32 = idata->GetRM32(); 57 | auto& r = emu->reg[idata->modrm.reg]; 58 | uint32_t result = rm32 ^ r.reg32; 59 | idata->SetRM32(result); 60 | EFLAGS.UpdateXor(); 61 | } 62 | 63 | void cmp_rm32_r32(){ 64 | uint32_t rm32 = idata->GetRM32(); 65 | auto& reg = emu->reg[idata->modrm.reg]; 66 | uint32_t r32 = reg.reg32; 67 | DOUT(__func__<<": rm32=0x"<reg[idata->modrm.reg]; 74 | uint32_t r32 = reg.reg32; 75 | uint32_t rm32 = idata->GetRM32(); 76 | 77 | EFLAGS.Cmp(r32, rm32); 78 | } 79 | void inc_r32(){ 80 | uint8_t r = idata->opcode - 0x40; 81 | emu->reg[r].reg32++; 82 | } 83 | 84 | void dec_r32(){ 85 | uint8_t r = idata->opcode - 0x48; 86 | emu->reg[r].reg32--; 87 | } 88 | 89 | void push_r32(){ 90 | emu->push32(emu->reg[idata->opcode-0x50].reg32); 91 | } 92 | 93 | void pop_r32(){ 94 | emu->reg[idata->opcode - 0x58].reg32 = emu->pop32(); 95 | } 96 | 97 | void push_imm32(){ 98 | emu->push32(idata->imm32); 99 | } 100 | 101 | void imul_r32_rm32_imm32(){ 102 | auto& reg = emu->reg[idata->modrm.reg]; 103 | int32_t s_rm32 = idata->GetRM32(); 104 | int64_t temp = static_cast(s_rm32) * static_cast(idata->imm32); 105 | DOUT(std::endl<imm32<<" = 0x"<(temp); 107 | if(temp != reg.reg32) // temp != DEST 108 | EFLAGS.CF = EFLAGS.OF = 1; 109 | else 110 | EFLAGS.CF = EFLAGS.OF = 0; 111 | } 112 | 113 | void push_imm8(){ 114 | uint32_t tmp32 = idata->imm8; 115 | emu->push32(tmp32); 116 | } 117 | 118 | void code_81(){ 119 | switch(idata->modrm.reg){ 120 | case 5: sub_rm32_imm32(); break; 121 | case 7: cmp_rm32_imm32(); break; 122 | default: 123 | std::stringstream ss; 124 | ss << "not implemented: 0x81 /" << static_cast(idata->modrm.reg); 125 | throw ss.str(); 126 | } 127 | } 128 | void sub_rm32_imm32(){ 129 | uint32_t rm32 = idata->GetRM32(); 130 | uint64_t set = rm32 - idata->imm32; 131 | DOUT(std::endl<<__func__<<": RM32=0x"<imm32<<", set=0x"<SetRM32(set); 134 | EFLAGS.UpdateSub(rm32, idata->imm32, set); 135 | } 136 | void cmp_rm32_imm32(){ 137 | auto rm32 = idata->GetRM32(); 138 | EFLAGS.Cmp(rm32, idata->imm32); 139 | } 140 | 141 | void code_83(){ 142 | switch(idata->modrm.reg){ 143 | case 0: add_rm32_imm8(); break; 144 | case 1: or_rm32_imm8(); break; 145 | case 4: and_rm32_imm8(); break; 146 | case 5: sub_rm32_imm8(); break; 147 | case 7: cmp_rm32_imm8(); break; 148 | default: 149 | std::stringstream ss; 150 | ss<<"not implemented: 83 /"<modrm.reg; 151 | throw ss.str(); 152 | } 153 | } 154 | void add_rm32_imm8(){ 155 | uint32_t rm32 = idata->GetRM32(); 156 | uint64_t set = rm32 + static_cast(idata->imm8); 157 | idata->SetRM32(set); 158 | EFLAGS.UpdateAdd(rm32, idata->imm8, set); 159 | } 160 | void or_rm32_imm8(){ 161 | uint32_t rm32 = idata->GetRM32(); 162 | uint64_t set = rm32 | static_cast(idata->imm8); 163 | idata->SetRM32(set); 164 | EFLAGS.UpdateOr(rm32, idata->imm8, set); 165 | } 166 | void and_rm32_imm8(){ 167 | uint32_t rm32 = idata->GetRM32(); 168 | uint64_t set = rm32 & static_cast(idata->imm8); 169 | idata->SetRM32(set); 170 | EFLAGS.UpdateAnd(rm32, idata->imm8, set); 171 | } 172 | void sub_rm32_imm8(){ 173 | uint32_t rm32 = idata->GetRM32(); 174 | int64_t set = rm32 - static_cast(idata->imm8); 175 | idata->SetRM32(static_cast(set)); 176 | EFLAGS.UpdateSub(rm32, idata->imm8, set); 177 | } 178 | void cmp_rm32_imm8(){ 179 | uint32_t rm32 = idata->GetRM32(); 180 | int8_t imm8 = idata->imm8; 181 | EFLAGS.Cmp(rm32, imm8); 182 | } 183 | 184 | void test_rm32_r32(){ 185 | uint32_t rm32 = idata->GetRM32(); 186 | auto& reg = emu->reg[idata->modrm.reg]; 187 | EFLAGS.UpdateTest(rm32, reg.reg32); 188 | } 189 | 190 | void mov_rm32_r32(){ 191 | idata->SetRM32(emu->reg[idata->modrm.reg].reg32); 192 | } 193 | void mov_r32_rm32(){ 194 | auto& reg = emu->reg[idata->modrm.reg]; 195 | DOUT(__func__<<": "<GetRM32()<GetRM32(); 197 | } 198 | 199 | void lea_r32_m(){ 200 | auto& reg = emu->reg[idata->modrm.reg]; 201 | auto m = idata->CalcMemAddr(); 202 | reg.reg32 = m; 203 | DOUT("lea: r32:"<push32(EFLAGS.reg32); 208 | } 209 | 210 | void popfd(){ 211 | EFLAGS.reg32 = emu->pop32(); 212 | } 213 | 214 | void mov_r32_imm32(){ 215 | auto& reg = emu->reg[idata->opcode - 0xb8]; 216 | DOUT(__func__<<": "<imm32); 217 | reg.reg32 = idata->imm32; 218 | // emu->reg[idata->opcode - 0xB8].reg32 = idata->imm32; 219 | } 220 | 221 | void code_c1(){ 222 | switch(idata->modrm.reg){ 223 | case 4: sal_rm32_imm8(); break; // = shl_rm32_imm8 224 | case 5: shr_rm32_imm8(); break; 225 | default: 226 | std::stringstream ss; 227 | ss << "not implemented: 0xc1 /"<(idata->modrm.reg); 228 | throw ss.str(); 229 | } 230 | } 231 | void sal_rm32_imm8(){ 232 | int32_t s_rm32 = idata->GetRM32(); 233 | int64_t result = s_rm32 << idata->imm8; 234 | EFLAGS.UpdateSal(s_rm32, idata->imm8, result); 235 | idata->SetRM32(result); 236 | } 237 | void shr_rm32_imm8(){ 238 | uint32_t rm32 = idata->GetRM32(); 239 | uint64_t result = rm32 >> idata->imm8; 240 | idata->SetRM32(result); 241 | EFLAGS.UpdateShr(rm32, idata->imm8, result); 242 | } 243 | 244 | void ret32(){ 245 | EIP = emu->pop32(); 246 | } 247 | void mov_rm32_imm32(){ 248 | DOUT("mov_rm32_imm32: val="<imm32<SetRM32(idata->imm32); 250 | } 251 | 252 | void leave32(){ 253 | ESP = EBP; // if StackAddressSize = 32 254 | EBP = emu->pop32(); 255 | } 256 | 257 | void call_rel32(){ 258 | emu->push32(EIP); 259 | EIP += idata->imm32; 260 | } 261 | 262 | void jmp_rel32(){ 263 | EIP += idata->imm32; 264 | } 265 | 266 | void jmp_ptr16_32(){ 267 | emu->far_jmp(idata->ptr16, idata->imm32); 268 | } 269 | 270 | void code_f7(){ 271 | switch(idata->modrm.reg){ 272 | case 2: not_rm32(); break; 273 | case 6: div_rm32(); break; 274 | default: 275 | throw "not implemented: 0xf7 /"+std::to_string((int)idata->modrm.reg); 276 | } 277 | } 278 | void not_rm32(){ 279 | uint32_t rm32 = idata->GetRM32(); 280 | idata->SetRM32(~rm32); 281 | } 282 | void div_rm32(){ 283 | uint32_t rm32 = idata->GetRM32(); 284 | uint64_t val; // EDX:EAX 285 | val = EDX; 286 | val = val << 32; 287 | val = val | EAX; 288 | if(rm32 == 0) throw __func__+std::string(": divided by zero"); 289 | EAX = val/rm32; 290 | EDX = val%rm32; 291 | } 292 | 293 | void code_ff(){ 294 | switch(idata->modrm.reg){ 295 | case 0: inc_rm32(); break; 296 | case 6: push_rm32(); break; 297 | default: 298 | throw "not implemented: 0xff /"+std::to_string((int)idata->modrm.reg); 299 | } 300 | } 301 | void inc_rm32(){ 302 | idata->SetRM32(idata->GetRM32() + 1); 303 | } 304 | void push_rm32(){ 305 | auto rm32 = idata->GetRM32(); 306 | emu->push32(rm32); 307 | } 308 | }; 309 | 310 | }; 311 | 312 | #endif 313 | -------------------------------------------------------------------------------- /arch/x86/register.cc: -------------------------------------------------------------------------------- 1 | #include "register.h" 2 | -------------------------------------------------------------------------------- /arch/x86/register.h: -------------------------------------------------------------------------------- 1 | #ifndef X86_REGISTER_H_ 2 | #define X86_REGISTER_H_ 3 | 4 | #include 5 | #include 6 | #include "../../register_base.h" 7 | 8 | namespace x86 { 9 | 10 | class Register32 : public ::RegisterBase { 11 | public: 12 | Register32() : ::RegisterBase(sizeof(uint32_t)), reg32(0x00) {} 13 | explicit Register32(uint32_t val) : ::RegisterBase(sizeof(uint32_t)), reg32(val) {} 14 | union { 15 | uint32_t reg32; 16 | struct { 17 | union { 18 | uint16_t reg16; 19 | uint16_t low16; 20 | struct { 21 | union { 22 | uint8_t reg8; 23 | uint8_t low8; 24 | }; 25 | uint8_t high8; 26 | }; 27 | }; 28 | uint16_t high16; 29 | }; 30 | }; 31 | 32 | // inline operator uint32_t () { return reg32; } 33 | // inline operator uint16_t () { return reg16; } 34 | // inline operator uint8_t () { return reg8; } 35 | 36 | inline Register32& operator=(const uint32_t val){ reg32 = val; return *this; } 37 | 38 | const std::string GetDataByString() const { 39 | std::stringstream ss; 40 | ss << "0x" 41 | << std::hex << std::setw(8) << std::setfill('0') 42 | << static_cast(reg32); 43 | return ss.str(); 44 | } 45 | }; 46 | 47 | class SRegister : public ::RegisterBase { 48 | public: 49 | SRegister() : ::RegisterBase(sizeof(uint16_t)), reg16(0x00) {} 50 | union { 51 | uint16_t reg16; 52 | struct { // segment selector 53 | uint8_t RPL : 2; // required priviledge level 54 | bool TI : 1; // table indicator 55 | uint16_t index : 13; 56 | }; 57 | }; 58 | 59 | inline SRegister& operator=(const uint16_t val){ reg16 = val; return *this; } 60 | 61 | const std::string GetDataByString() const { 62 | std::stringstream ss; 63 | ss << "0x" 64 | << std::hex << std::setfill('0') 65 | << std::setw(4) << reg16 66 | << " = (" 67 | << "RPL=0x" << static_cast(RPL) 68 | << ", TI=0x" << TI << ":" << (TI ? "LDT" : "GDT") 69 | << ", index=0x" << std::setw(4) << index 70 | << ")"; 71 | return ss.str(); 72 | } 73 | }; 74 | 75 | // EFLAGS 76 | class Eflags : public ::RegisterBase { 77 | public: 78 | union { 79 | struct { 80 | bool CF : 1; 81 | bool : 1; 82 | bool PF : 1; 83 | bool : 1; 84 | bool AF : 1; 85 | bool : 1; 86 | bool ZF : 1; 87 | bool SF : 1; 88 | bool TF : 1; 89 | bool IF : 1; 90 | bool DF : 1; 91 | bool OF : 1; 92 | bool IOPL1 : 1; 93 | bool IOPL2 : 1; 94 | bool NT : 1; 95 | bool : 1; 96 | bool RF : 1; 97 | bool VM : 1; 98 | bool AC : 1; 99 | bool VIF: 1; 100 | bool VIP: 1; 101 | bool ID : 1; 102 | }; 103 | uint32_t reg32; 104 | }; 105 | public: 106 | Eflags() : RegisterBase(sizeof(uint32_t)) {} 107 | 108 | inline bool IsCarry() { return CF; } 109 | inline bool IsParity() { return PF; } 110 | inline bool IsZero() { return ZF; } 111 | inline bool IsSign() { return SF; } 112 | inline bool IsOverflow() { return OF; } 113 | inline bool IsInterrupt() { return IF; } 114 | inline bool IsDirection() { return DF; } 115 | 116 | inline void SetCarry(bool carry) { CF = carry; } 117 | inline void SetParity(bool parity) { PF = parity; } 118 | inline void SetZero(bool zero) { ZF = zero; } 119 | inline void SetSign(bool sign) { SF = sign; } 120 | inline void SetOverflow(bool of) { OF = of; } 121 | inline void SetInterrupt(bool intr) { IF = intr; } 122 | inline void SetDirection(bool dir) { DF = dir; } 123 | 124 | template 125 | inline void UpdateSub(T v1, uint32_t v2, uint64_t result){ 126 | auto size = sizeof(T)*8; // bit数 127 | bool sign1 = v1 >> (size-1); 128 | bool sign2 = v2 >> (size-1); 129 | bool signr = (result >> (size -1)) & 1; // (res >> 31) & 1; 130 | 131 | SetCarry(result >> size); 132 | SetZero(result == 0); 133 | SetSign(signr); 134 | SetOverflow(sign1 != sign2 && sign1 != signr); 135 | } 136 | 137 | template 138 | inline void Cmp(T v1, uint32_t v2){ 139 | uint64_t result = static_cast(v1) - static_cast(v2); 140 | UpdateSub(v1, v2, result); 141 | } 142 | 143 | template 144 | inline void UpdateAdd(T v1, uint32_t v2, uint64_t result){ 145 | UpdateSub(v1, v2, result); 146 | } 147 | 148 | template 149 | inline void UpdateAnd(T v1, uint32_t v2, uint64_t result){ 150 | auto size = sizeof(T)*8; // bit数 151 | bool signr = (result >> (size-1)) & 1; 152 | 153 | SetCarry(0); 154 | SetZero(result == 0); 155 | SetSign(signr); 156 | SetOverflow(0); 157 | } 158 | 159 | template 160 | inline void UpdateOr(T v1, uint32_t v2, uint64_t result){ 161 | auto size = sizeof(T)*8; 162 | bool signr = (result >> (size-1)) & 1; 163 | 164 | SetCarry(0); 165 | SetZero(result == 0); 166 | SetSign(signr); 167 | SetOverflow(0); 168 | } 169 | 170 | template 171 | inline void UpdateShr(T v1, uint8_t v2, uint64_t result){ 172 | if(v2 == 0) return; 173 | 174 | auto size = sizeof(T)*8; 175 | bool signr = (result >> (size-1)) & 1; 176 | 177 | SetCarry((v1 >> (v2-1)) & 1); 178 | SetZero(result == 0); 179 | SetSign(signr); 180 | 181 | // OFは1bitシフトのときのみ影響を受ける 182 | if(v2 == 1) 183 | SetOverflow((v1>>(size-1)) & 1); 184 | } 185 | 186 | template 187 | inline void UpdateSal(T dest, uint8_t count, uint64_t result){ 188 | if(count == 0) return; 189 | 190 | auto size = sizeof(T)*8; 191 | bool signr = (result >> (size-1)) & 1; 192 | 193 | SetCarry((result>>size) & 1); 194 | SetZero(result == 0); 195 | SetSign(signr); 196 | 197 | // OFは1bitシフトのときのみ影響を受ける 198 | if(count == 1) 199 | SetOverflow(CF != ((result>>(size-1)) & 1)); 200 | } 201 | 202 | inline void UpdateXor(){ 203 | CF = OF = 0; 204 | } 205 | 206 | template 207 | inline void UpdateTest(T v1, T v2){ 208 | T temp = v1 & v2; 209 | 210 | auto size = sizeof(T)*8; 211 | bool sign = (temp >> (size-1)) & 1; 212 | 213 | SetSign(sign); 214 | SetZero(temp == 0); 215 | SetCarry(0); 216 | SetOverflow(0); 217 | } 218 | 219 | const uint32_t GetData32() const { 220 | uint32_t ret = 0x00; 221 | ret |= CF; 222 | ret |= PF << 2; 223 | ret |= AF << 4; 224 | ret |= ZF << 6; 225 | ret |= SF << 7; 226 | ret |= TF << 8; 227 | ret |= IF << 9; 228 | ret |= DF << 10; 229 | ret |= OF << 11; 230 | ret |= IOPL1<< 12; 231 | ret |= IOPL2<< 13; 232 | ret |= NT << 14; 233 | ret |= RF << 16; 234 | ret |= VM << 17; 235 | ret |= AC << 18; 236 | ret |= VIF << 19; 237 | ret |= VIP << 20; 238 | ret |= ID << 21; 239 | return ret; 240 | } 241 | 242 | const std::string GetDataByString() const { 243 | std::stringstream ss; 244 | ss << "0x" 245 | << std::hex 246 | << std::setw(8) 247 | << std::setfill('0') 248 | << GetData32(); 249 | return ss.str(); 250 | } 251 | }; 252 | 253 | // memory management register: GDTR, IDTR, TR, LDTR 254 | class MemManRegister : public ::RegisterBase { 255 | public: 256 | MemManRegister() : ::RegisterBase(sizeof(uint64_t)), limit(0x00), base(0x00), selector(0x00) {} 257 | 258 | union { 259 | struct { 260 | uint16_t limit : 16; 261 | uint32_t base : 32; 262 | uint16_t selector : 16; // TR, LDTRのみ 263 | }; 264 | // uint64_t _reg64 : 64; 265 | }; 266 | 267 | const std::string GetDataByString() const { 268 | std::stringstream ss; 269 | 270 | if(GetSize() != sizeof(uint64_t) && selector != 0x00) 271 | throw "selector is not zero"; 272 | 273 | ss << std::hex 274 | << std::setfill('0'); 275 | 276 | if(GetSize()==sizeof(uint64_t)) 277 | ss << "0x" << std::setw(4) << selector; 278 | else 279 | ss << " 0x"; 280 | 281 | ss << std::setw(8) << base 282 | << std::setw(4) << limit; 283 | 284 | ss << " = ("; 285 | 286 | if(GetSize() == sizeof(uint64_t)) 287 | ss << "selector=0x" << std::setw(4) << selector << ", "; 288 | 289 | ss << "base=0x" << std::setw(8) << base 290 | << ", limit=0x" << std::setw(4) << limit 291 | << ")"; 292 | return ss.str(); 293 | } 294 | }; 295 | 296 | // base for CR0~CR4 297 | class CRegister : public ::RegisterBase { 298 | public: 299 | CRegister() : ::RegisterBase(sizeof(uint32_t)) {} 300 | }; 301 | 302 | class CR0_t : public CRegister { 303 | public: 304 | union { 305 | struct { 306 | bool PE : 1; // 保護イネーブル 307 | bool MP : 1; // モニタ・コプロセッサ 308 | bool EM : 1; // エミュレーション 309 | bool TS : 1; // タスクスイッチ 310 | bool ET : 1; // 拡張タイプ 311 | bool NE : 1; // 数値演算エラー 312 | uint16_t : 10; 313 | bool WP : 1; // 書き込み保護 314 | bool : 1; 315 | bool AM : 1; // アラインメント・マスク 316 | uint16_t : 10; 317 | bool NW : 1; // ノット・ライトスルー 318 | bool CD : 1; // キャッシュ・ディスエーブル 319 | bool PG : 1; // ページング 320 | }; 321 | uint32_t reg32; 322 | }; 323 | 324 | const std::string GetDataByString() const { 325 | std::stringstream ss; 326 | ss << "0x" 327 | << std::hex 328 | << std::setfill('0') 329 | << std::setw(8) 330 | << reg32; 331 | return ss.str(); 332 | } 333 | }; 334 | 335 | } 336 | 337 | #endif 338 | -------------------------------------------------------------------------------- /bios/.gitignore: -------------------------------------------------------------------------------- 1 | bios.bin 2 | seabios/ 3 | -------------------------------------------------------------------------------- /bios/Makefile: -------------------------------------------------------------------------------- 1 | COPY := cp 2 | GIT := git 3 | 4 | seabios: 5 | $(GIT) clone https://github.com/qemu/seabios.git 6 | make -C seabios 7 | $(COPY) seabios/out/bios.bin bios.bin 8 | -------------------------------------------------------------------------------- /bios/base.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOS_H_ 2 | #define BIOS_H_ 3 | 4 | #include "../emulator_base.h" 5 | #include "../device/display.h" 6 | 7 | namespace BIOS { 8 | 9 | class Base { 10 | public: 11 | Base(EmulatorBase *e) : emu_base(e) { if(e==nullptr) throw "ぬるぽ"; } 12 | virtual void Boot() = 0; 13 | virtual void Function(size_t num){} // for junk BIOS 14 | virtual void SetDisplay(Device::Display&){} 15 | protected: 16 | EmulatorBase *emu_base; 17 | }; 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /bios/junk_base.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOS_JUNK_BASE_H_ 2 | #define BIOS_JUNK_BASE_H_ 3 | 4 | #include "../emulator_base.h" 5 | 6 | namespace BIOS { 7 | 8 | namespace Junk { 9 | 10 | class Base : public BIOS::Base { 11 | public: 12 | Base(EmulatorBase *e) : BIOS::Base(e) {} 13 | virtual void Boot() = 0; 14 | protected: 15 | EmulatorBase *emu; 16 | }; 17 | 18 | } 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /bios/junk_x86.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOS_JUNK_X86_H_ 2 | #define BIOS_JUNK_X86_H_ 3 | 4 | #include 5 | #include 6 | #include "junk_base.h" 7 | #include "../arch/x86/emulator.h" 8 | #include "../device/floppy.h" 9 | #include "../device/display.h" 10 | 11 | // http://oswiki.osask.jp/?(AT)BIOS 12 | 13 | namespace BIOS { 14 | namespace Junk { 15 | 16 | class x86 : public BIOS::Junk::Base { 17 | public: 18 | x86(::x86::Emulator *e) : BIOS::Junk::Base(e), emu(e), disp(nullptr) {} 19 | 20 | void SetDisplay(Device::Display &disp){ this->disp = &disp; } 21 | void Print(const std::string &str){ 22 | if(this->disp !=nullptr){ 23 | disp->Print(str); 24 | return; 25 | } 26 | DOUT("BIOS: Print: "); 27 | std::cout<disp != nullptr){ 32 | disp->Print(c); 33 | return; 34 | } 35 | DOUT("BIOS: Print: "); 36 | std::cout<dev; 56 | for(size_t i=0;i(dev[i]); 60 | } 61 | return nullptr; 62 | } 63 | 64 | Device::Base* GetBootDevice(){ 65 | auto fd = GetFloppy(); 66 | if(fd != nullptr) return fd; 67 | Print("No bootable device.\n"); 68 | emu->halt_flg = true; 69 | return nullptr; 70 | } 71 | 72 | void LoadIPL(){ 73 | auto d = GetBootDevice(); 74 | if(d == nullptr) return; 75 | if(typeid(*d) == typeid(Device::Floppy)){ 76 | Print("Booting from Floppy...\n"); 77 | Device::Floppy *f = dynamic_cast(d); 78 | f->Load(emu->memory, 0x7c00, 256); 79 | }else{ 80 | Print("unknown bootable device.\n"); 81 | } 82 | } 83 | 84 | void Function(size_t num){ 85 | DOUT("\n\tBIOS function called: num = 0x"<(AH)<ChangeMode(xsize, ysize, txt); 132 | DOUT("VIDEO MODE: "<(AL)); 142 | break; 143 | default: 144 | throw "not implemented: video_func(junk BIOS)"; 145 | break; 146 | } 147 | } 148 | 149 | void disk_func(){ 150 | auto fd = GetFloppy(); 151 | switch(AH){ 152 | case 0x00: // システムのリセット 153 | fd->Reset(); 154 | break; 155 | case 0x02: // 読み込み 156 | //case 0x03: // 書き込み 157 | //case 0x04: // ベリファイ 158 | //case 0x0c: // シーク 159 | { 160 | // CH=シリンダ番号 & 0xff <=シリンダ番号下位8bit 161 | // CL=セクタ番号(0-5bit) | (シリンダ番号 & 0x300) >> 2 162 | // CL:0-5bit=セクタ番号 163 | // CL:6-7bit=シリンダ番号9,10bit目 164 | // 0xff = 0000,1111,1111 165 | // 0x300 = 0011,0000,0000 166 | 167 | // 本当はシリンダ番号の指定は以下のようになるけど, 168 | // フロッピーでは0x00~0x4fだから9,10bit目はいらないのでCHだけでok 169 | //uint16_t cyl = CH | ((CL << 2) & 0x300) 170 | Device::Floppy::Setting set = { 171 | .drive = DL, 172 | .head = (DH==0) ? bool(0) : bool(1), 173 | .cylinder = CH, 174 | .sector = CL // 下位5bit 175 | }; 176 | if(fd->Read(set, emu->memory, (ES.reg16*16)+BX, AL)){ 177 | EFLAGS.CF = 0; 178 | AH = 0; 179 | }else{ 180 | EFLAGS.CF = 1; 181 | AH = 0; // TODO: エラーコードわからん 182 | } 183 | } 184 | break; 185 | //case 0x08: // パラメータ取得 186 | //case 0x09: // パラメータテーブルの初期化(?) 187 | //case 0x10: // ドライブレディーのテスト 188 | //case 0x11: // ドライブの正規化 189 | //case 0x14: // コントローラの診断 190 | //case 0x15: // ディスクタイプ取得 191 | //case 0x16: // FDの交換チェック 192 | //case 0x17: // FDのディスクタイプの設定 193 | //case 0x05: // FDの物理フォーマット 194 | default: 195 | { 196 | std::stringstream ss; 197 | ss << "not implemented: BIOS disk func AH=0x" 198 | <(AH); 199 | throw ss.str(); 200 | } 201 | break; 202 | } 203 | } 204 | 205 | void keyboard_func(){ 206 | switch(AH){ 207 | //case 0x00: // 文字読み出し 208 | //case 0x01: // キーバッファ状態チェック 209 | case 0x02: // キーロック&シフト状態取得 210 | // TODO: temporary impl 211 | DOUT("warning: BIOS keyboard func AH=0x02 is implemented temporary."); 212 | AL = 0x00; 213 | break; 214 | default: 215 | { 216 | std::stringstream ss; 217 | ss << "not implemented: BIOS keyboard func AH=0x" 218 | << std::hex << static_cast(AH); 219 | throw ss.str(); 220 | } 221 | } 222 | } 223 | private: 224 | ::x86::Emulator *emu; 225 | Device::Display *disp; 226 | }; 227 | 228 | } 229 | } 230 | 231 | #endif 232 | -------------------------------------------------------------------------------- /com_mak.txt: -------------------------------------------------------------------------------- 1 | TOLSET := $(DEPTH)tolset/ 2 | Z_TOOLS := $(TOLSET)z_tools/ 3 | BIN2OBJ := $(Z_TOOLS)bin2obj 4 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H_ 2 | #define COMMON_H_ 3 | 4 | #include 5 | #include 6 | 7 | //#define NO_DEBUG 8 | 9 | #include "debug.h" 10 | 11 | const size_t KB = 1024; 12 | const size_t MB = (1024 * KB); 13 | const size_t GB = (1024 * MB); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /common.mk: -------------------------------------------------------------------------------- 1 | GIT_COMMIT_ID := $(shell git log -1 --format='%H') 2 | GIT_COMMIT_DATE:= $(shell git log -1 --format='%ad') 3 | 4 | CC := gcc 5 | CXX := g++ 6 | 7 | INCFLAGS += -I./libsksat 8 | LDFLAGS += 9 | 10 | CFLAGS += $(INCFLAGS) -MD -Wall -g 11 | CXXFLAGS += $(INCFLAGS) -MD -std=c++14 -Wall 12 | CXXFLAGS += -DGIT_COMMIT_ID="\"$(GIT_COMMIT_ID)\"" -DGIT_COMMIT_DATE="\"$(GIT_COMMIT_DATE)\"" 13 | ifeq ($(BUILD_TYPE),Debug) 14 | CXXFLAGS += -DDEBUG -g -O0 15 | else 16 | CXXFLAGS += -DNO_DEBUG -O3 17 | endif 18 | 19 | %.o:%.c $(HEAD) 20 | $(CC) -c -o $@ $< $(CFLAGS) 21 | 22 | %.o:%.cc $(HEADXX) 23 | $(CXX) -c -o $@ $< $(CXXFLAGS) 24 | 25 | DUMMY: 26 | .PHONE: DUMMY 27 | 28 | _clean: DUMMY 29 | rm -f *.o *.a *.d 30 | 31 | -include *.d 32 | -------------------------------------------------------------------------------- /debug.cc: -------------------------------------------------------------------------------- 1 | #include "debug.h" 2 | 3 | bool debug::out_flg = true; 4 | -------------------------------------------------------------------------------- /debug.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_H_ 2 | #define DEBUG_H_ 3 | 4 | namespace debug { 5 | extern bool out_flg; 6 | } 7 | 8 | #ifndef NO_DEBUG 9 | 10 | #include 11 | 12 | #define DEBUG_PUTS(msg) puts(msg); 13 | #define DOUT(stream) {if(debug::out_flg){std::cout< 5 | #include 6 | #include 7 | #include "../common.h" 8 | #include "../memory.h" 9 | 10 | class Memory; 11 | 12 | namespace Device { 13 | 14 | class Base { 15 | public: 16 | Base(const std::string &name) : name(name) {} 17 | // Base() : name("unknown device") {} 18 | 19 | virtual void MemoryMappedProc(Memory *memory, uint32_t addr){} 20 | 21 | const std::string& GetDevName(){ return name; } 22 | 23 | virtual uint8_t in8(const uint16_t &port){ 24 | std::string msg = "in8() is not implemented in "; 25 | msg += name; 26 | throw msg; 27 | } 28 | virtual void out8(const uint16_t &port, const uint8_t &data){ 29 | std::string msg = "out8() is not implemented in "; 30 | msg += name; 31 | throw msg; 32 | } 33 | 34 | // virtual void Init() { InitDevName(); }//InitDevIRQ(); InitDevPort(); } 35 | // virtual void InitDevName() = 0; 36 | // void InitDevIRQ() { irq = std::vector(); } 37 | // void InitDevPort(){ io_port = std::vector(); } 38 | // void AddDevIRQ(int irq){ this->irq.push_back(irq); } 39 | // void AddDevPort(int port){ io_port.push_back(port); } 40 | 41 | protected: 42 | std::string name; 43 | std::vector irq; 44 | std::vector io_port; 45 | }; 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /device/display.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "display.h" 5 | 6 | using namespace Device; 7 | 8 | size_t Display::default_scrnx = 320; 9 | size_t Display::default_scrny = 200; 10 | 11 | #define SET_PALETTE(num, r, g, b) {palette[num*3]=r;palette[num*3+1]=g;palette[num*3+2]=b;} 12 | 13 | Display::Display() : Base("Display"), memory(nullptr), img(nullptr), scrnx(default_scrnx), scrny(default_scrny) { 14 | Init(); 15 | } 16 | 17 | Display::~Display(){ 18 | if(img != nullptr) delete[] img; 19 | } 20 | 21 | void Display::Init(){ 22 | txtmode_flg = true; 23 | font_xsiz = 8; 24 | font_ysiz = 16; 25 | ChangeMode(scrnx, scrny); 26 | SET_PALETTE(0, 0x00, 0x00, 0x00); 27 | SET_PALETTE(15, 0xff, 0xff, 0xff); 28 | } 29 | 30 | void Display::out8(const uint16_t &port, const uint8_t &data){ 31 | static uint16_t old_port = 0x00; 32 | static uint8_t p_num = 0; 33 | static uint8_t col = 0; 34 | 35 | switch(port){ 36 | case 0x03c8: 37 | p_num = data; 38 | std::cout<<"p_num="<(p_num)<(data << 2) 50 | <scrnx = scrnx; 82 | this->scrny = scrny; 83 | this->txtmode_flg = txtmode_flg; 84 | Clear(); 85 | } 86 | 87 | #define POS(x, y) (((y)*scrnx + x)*3) 88 | #define SET_RGB(x, y, r, g, b) { img[POS(x,y)]=r; img[POS(x,y)+1]=g; img[POS(x,y)+2]=b; } 89 | #define FONT_DATA(c,y) (font[c*font_ysiz + y+5]) 90 | #define GET_VRAM(addr) (memory->GetData8(vram_start+addr)) 91 | #define SET_VRAM(addr, val) { memory->SetData8(vram_start+addr, val); } 92 | 93 | void Display::FlushImage(){ 94 | if(memory == nullptr || img == nullptr) throw; 95 | size_t x=0, y=0; 96 | if(txtmode_flg){ 97 | for(size_t addr=0x00; addr<=vram_size; addr++){ 98 | char c = GET_VRAM(addr); // 文字 99 | 100 | switch(c){ 101 | case '\n': 102 | case EOF: 103 | case '\0': 104 | break; 105 | default: 106 | PutFont(x, y, c); 107 | break; 108 | } 109 | 110 | x += font_xsiz; 111 | if(x>scrnx){ 112 | x = 0; 113 | y += font_ysiz; 114 | } 115 | if(y>scrny) break; 116 | 117 | PutFont(print_x, print_y, '_'); 118 | } 119 | }else{ 120 | for(size_t addr=0x00; addr=scrnx){ 129 | x = 0; 130 | y++; 131 | } 132 | } 133 | } 134 | } 135 | 136 | void Display::Clear(){ 137 | for(size_t y=0;y scrnx){ 177 | print_x = 0; 178 | print_y += font_ysiz; 179 | } 180 | if(print_y > scrny) print_y = 0; 181 | } 182 | 183 | void Display::Print(const std::string &str){ 184 | for(size_t i=0;imemory = mem; 21 | vram_start = addr; 22 | vram_size = size; 23 | } 24 | 25 | void MemoryMappedProc(Memory *memory, uint32_t addr){ throw "display: MemoryMappedProc"; } 26 | 27 | void ChangeMode(size_t scrnx, size_t scrny, bool txtmode_flg); 28 | void ChangeMode(size_t scrnx, size_t scrny){ ChangeMode(scrnx, scrny, txtmode_flg); } 29 | 30 | unsigned char* GetImage(){ return img; } 31 | void FlushImage(); 32 | 33 | void Clear(); 34 | 35 | void PutFont(size_t x, size_t y, char c, uint8_t r, uint8_t g, uint8_t b); 36 | void PutFont(size_t x, size_t y, char c){ PutFont(x, y, c, 0xff, 0xff, 0xff); } 37 | 38 | void Print(char c); 39 | void Print(const std::string &str); 40 | 41 | void TestDraw(); 42 | 43 | size_t GetSizeX() const { return scrnx; } 44 | size_t GetSizeY() const { return scrny; } 45 | 46 | static size_t default_scrnx, default_scrny; 47 | private: 48 | // unsigned char vram[0xffff]; // とりあえず0xa0000 ~ 0affff だけ考える 49 | Memory* memory; 50 | uint32_t vram_start, vram_size; 51 | 52 | bool txtmode_flg; 53 | 54 | /* 55 | class VideoDAConverter { 56 | public: 57 | void set_palette(const uint8_t &num){} 58 | 59 | enum class Mode { 60 | read, 61 | write, 62 | }; 63 | Mode mode; 64 | private: 65 | uint8_t palette[0xff * 3]; // パレット 66 | }; 67 | 68 | VideoDAConverter converter; 69 | */ 70 | unsigned char palette[0xff * 3]; // パレット 71 | unsigned char *img; // ウィンドウに実際に渡すイメージ 72 | size_t scrnx, scrny; // 縦、横サイズ 73 | 74 | // text mode 75 | std::vector font; 76 | size_t font_xsiz, font_ysiz; 77 | size_t print_x=0, print_y=0; 78 | }; 79 | 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /device/floppy.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "floppy.h" 4 | 5 | using namespace Device; 6 | 7 | void Floppy::Open(const std::string &fname){ 8 | std::stringstream ss; 9 | fs.open(fname, std::ios::in | std::ios::out |std::ios::binary); 10 | if(fs.fail()){ 11 | ss << "Floppy: cannot open file \'" 12 | < 79){ 34 | DOUT("Floppy: cylinder error: "<(set.cylinder)< 18){ 38 | DOUT("Floppy: sector error: "<(set.sector)<GetRaw()[addr], size); 69 | } 70 | -------------------------------------------------------------------------------- /device/floppy.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_FLOPPY_H_ 2 | #define DEVICE_FLOPPY_H_ 3 | 4 | #include 5 | 6 | #include "device.h" 7 | #include "../memory.h" 8 | 9 | // http://softwaretechnique.jp/OS_Development/kernel_development11.html 10 | 11 | namespace Device { 12 | 13 | class Floppy : public Device::Base { 14 | public: 15 | Floppy() : Base("Floppy") {} 16 | Floppy(const std::string fname) : Base("Floppy"), fname(fname) { Open(fname); } 17 | ~Floppy(){} 18 | 19 | void InitDevName(){ name = "floppy"; } 20 | 21 | void Open(const std::string &fname); 22 | void Open(){ Open(fname); } 23 | 24 | struct Setting { 25 | uint8_t drive; 26 | bool head; // 0(表), 1(裏) 27 | uint16_t cylinder; // 0〜79 28 | uint8_t sector : 5; // 1〜18 29 | }; 30 | 31 | void Reset(){ 32 | Setting set = { 33 | .drive = 0, 34 | .head = 0, 35 | .cylinder = 0, 36 | .sector = 1 37 | }; 38 | Seek(set); 39 | } 40 | bool Seek(const Setting &set); 41 | bool Read(Memory *mem, uint32_t addr, uint8_t sector_num); 42 | bool Read(const Setting &set, Memory *mem, uint32_t addr, uint8_t sector_num){ 43 | if(!Seek(set)) return false; 44 | if(!Read(mem, addr, sector_num)) return false; 45 | return true; 46 | } 47 | 48 | void SetFile(const char *fname){ 49 | throw "not implemented: SetFile"; 50 | /* struct stat st; 51 | if(stat(fname, &st) != 0) 52 | throw "No such floppy file"; 53 | if(fp != nullptr) 54 | throw "already opend"; 55 | fp = fopen(fname, "rb"); 56 | if(fp == nullptr) 57 | throw "could not open image file."; 58 | */ 59 | } 60 | 61 | void Load(Memory *mem, uint32_t addr, uint32_t size); 62 | // throw "not implemented: Load"; 63 | // mem->LoadBinary(fp, addr, size); 64 | // } 65 | private: 66 | std::string fname; 67 | std::fstream fs; 68 | Setting set; 69 | }; 70 | 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /device/keyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_KEYBOARD_H_ 2 | #define DEVICE_KEYBOARD_H_ 3 | 4 | #include "device.h" 5 | 6 | namespace Device { 7 | 8 | class Keyboard : public Device::Base { 9 | public: 10 | Keyboard() : Base("Keyboard") {} 11 | 12 | uint8_t in8(const uint16_t &port){ 13 | DOUT(std::endl<<"Keyboard::in8 port="<(port) 15 | <<", data=0x"<(data)); 16 | } 17 | private: 18 | // registers 19 | uint8_t imr; 20 | uint8_t icw1, icw2, icw3, icw4; 21 | }; 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /docs/demo/emu.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sksat/emu/909411730c2af56d01321792a7e20020fc440511/docs/demo/emu.data -------------------------------------------------------------------------------- /docs/demo/emu.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Emscripten-Generated Code 7 | 48 | 49 | 50 |
51 |
emscripten
52 |
Downloading...
53 |
54 | 55 |
56 |
57 | 58 |
59 |
60 |
61 | Resize canvas 62 | Lock/hide mouse pointer 63 |     64 | 66 |
67 | 68 |
69 | 70 |
71 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /docs/demo/emu.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sksat/emu/909411730c2af56d01321792a7e20020fc440511/docs/demo/emu.wasm -------------------------------------------------------------------------------- /docs/format.md: -------------------------------------------------------------------------------- 1 | # [命令フォーマット](https://www.intel.co.jp/content/dam/www/public/ijkk/jp/ja/documents/developer/IA32_Arh_Dev_Man_Vol2A_i.pdf) 2 | 3 | | prefix | opecode | ModR/M | SIB | disp | imm | 4 | 5 | disp,imm: 0,1,2,4バイト 6 | 7 | ## prefix 8 | 9 | ### group1 10 | - 0xf0 11 | - 0xf2 12 | - 0xf3 13 | 14 | ### group2 15 | セグメント・オーバーライド・プリフィックス 16 | - 0x2e: CS 17 | - 0x36: SS 18 | - 0x3e: DS 19 | - 0x26: ES 20 | - 0x64: FS 21 | - 0x65: GS 22 | - 0x2e: 分岐が成立しない(Jcc命令に対してのみ使用) 23 | 24 | ### group3 25 | - 0x66 26 | 27 | ### group4 28 | - 0x67 29 | 30 | ## opecode 31 | 32 | ## ModR/M 33 | | Mod | reg/op | R/M | 34 | 35 | Mod: 2bit 36 | reg/op: 3bit 37 | R/M: 3bit 38 | 39 | ## SIB 40 | | scale | index | base | 41 | 42 | scale: 2bit 43 | index: 3bit 44 | base: 3bit 45 | -------------------------------------------------------------------------------- /docs/memo.md: -------------------------------------------------------------------------------- 1 | # レジスタ 2 | - 汎用データレジスタ 3 | - セグメント・レジスタ 4 | - EFLAGS 5 | 6 | ## 汎用データ・レジスタ 7 | 8 | * Vol2A 3.1.1.1 9 | | 番号 | 8bit | 16bit | 32bit | 10 | |------|------|-------|-------| 11 | |0|AL|AX|EAX| 12 | |1|CL|CX|ECX| 13 | |2|DL|DX|EDX| 14 | |3|BL|BX|EBX| 15 | |4|AH|SP|ESP| 16 | |5|CH|BP|EBP| 17 | |6|DH|SI|ESI| 18 | |7|BH|DI|EDI| 19 | 20 | ## セグメント・レジスタ 21 | 22 | 23 | # 特権レベル(IA32 Arch Dev Vol1 p169) 24 | Level 0 OS Kernel 25 | Level 1 OS Service (ex: device driver) 26 | Level 2 OS Service (ex: device driver) 27 | Level 3 Application 28 | 29 | # 割り込み/例外(Vol1 p174) 30 | ベクタ mnemonic 説明 原因 31 | 0 #DE 除算エラー DIV,IDIV命令 32 | 1 #DB debug 任意のコード・データの参照 33 | 2 NMI マスク不可能な外部割り込み 34 | 3 #BP break point INT 3 35 | 4 #OF over flow INTO 36 | 5 #BR BOUND範囲外 BOUND 37 | 6 #UD 未定義opcode UD2・予約オペコード 38 | 7 #NM デバイス使用不能 浮動小数点命令・WAIT/FWAIT 39 | 8 #DF ダブルフォルト 例外,NMI,INTRを生成できる任意の命令 40 | 9 #MF 予約 浮動小数点命令 (386以降) 41 | 10 #TS 無効TSS タスクスイッチ,TSSアクセス 42 | 11 #NP セグメント不在 セグメントレジスタ/システムセグメントレジスタのアクセス 43 | 12 #SS Stack Segment Fault スタック操作・SSレジスタのロード 44 | 13 #GP 一般保護 任意のメモリ参照,その他の保護チェック 45 | 14 #PF ページフォルト 任意のメモリ参照 46 | 15 予約 47 | 16 #MF 浮動小数点エラー 浮動小数点命令,WAIT/FWAIT 48 | 17 #AC アラインメントチェック メモリ内の任意のデータ参照 (486で導入) 49 | 18 #MC マシンチェック エラーコード、ソースがモデルに依存 (Pentiumで導入,PRファミリで拡張) 50 | 19 #XF SIMD浮動小数点例外 SIMD浮動小数点命令 (PentiumⅡ で導入) 51 | 20~31 予約 52 | 32~255 マスク可能割り込み INTRピンによる外部割り込み,INT n命令 53 | 54 | 55 | # Jcc -- Jump If Condition Is Met 56 | 70 jo 57 | 71 jno 58 | 72 jb,jc,jnae 59 | 73 jae,jnb,jnc 60 | 74 je,jz 61 | 75 jne,jnz 62 | 76 jbe,jna 63 | 77 ja,jnbe 64 | 78 js 65 | 79 jns 66 | 7a jp,jpe 67 | 7b jpo 68 | 7c jl,jnge 69 | 7d jge,jnl 70 | 7e jle,jng 71 | 7f jg,jnle 72 | e3 jcxz,jecxz(16,32bit) 73 | -------------------------------------------------------------------------------- /emulator.cc: -------------------------------------------------------------------------------- 1 | #include "emulator.h" 2 | 3 | 4 | -------------------------------------------------------------------------------- /emulator.h: -------------------------------------------------------------------------------- 1 | #ifndef EMULATOR_H_ 2 | #define EMULATOR_H_ 3 | 4 | #include "common.h" 5 | #include "arch/arch.h" 6 | #include "insn_base.h" 7 | #include "emulator_base.h" 8 | #include "memory.h" 9 | #include "device/floppy.h" 10 | #include "bios/base.h" 11 | #include "bios/junk_x86.h" 12 | 13 | #define DEFAULT_MEMORY_SIZE 1 // MB 14 | 15 | class EmulatorCtrl { 16 | public: 17 | struct Setting { 18 | ARCH arch; 19 | size_t memsize; //MB 20 | bool junk_bios; 21 | bool gui; 22 | bool fullscreen; 23 | }; 24 | 25 | EmulatorCtrl(){ 26 | set = { 27 | .arch = ARCH::x86, 28 | .memsize = DEFAULT_MEMORY_SIZE, 29 | .junk_bios = false, 30 | .gui = true, 31 | .fullscreen = false 32 | }; 33 | } 34 | 35 | void Init(){ 36 | Init(this->set); 37 | } 38 | 39 | void Init(const EmulatorCtrl::Setting &set){ 40 | SetArch(set.arch); 41 | this->set = set; 42 | } 43 | 44 | void SetArch(const ARCH &arch){ 45 | this->set.arch = arch; 46 | switch(arch){ 47 | case ARCH::x86: 48 | emu = std::make_unique(); 49 | break; 50 | case ARCH::osecpu: 51 | emu = std::make_unique(); 52 | break; 53 | default: 54 | // unkown arch 55 | throw "error: Emulator: unkown arch"; 56 | } 57 | emu->Init(); 58 | } 59 | 60 | EmulatorBase* GetRaw(){ return emu.get(); } 61 | 62 | private: 63 | EmulatorCtrl::Setting set; 64 | std::unique_ptr emu; 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /emulator_base.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "emulator_base.h" 3 | 4 | EmulatorBase::EmulatorBase(){ 5 | memory = new Memory(); 6 | } 7 | 8 | EmulatorBase::~EmulatorBase(){ 9 | delete insn; 10 | delete memory; 11 | delete io; 12 | delete bios; 13 | } 14 | 15 | void EmulatorBase::Init(){ 16 | finish_flg = false; 17 | InitInstructions(); 18 | InitRegisters(); 19 | InitMemory(); 20 | InitIO(); 21 | } 22 | 23 | void EmulatorBase::SetBios(BIOS::Base *bios){ 24 | if(bios == nullptr) throw "BIOS"; 25 | this->bios = bios; 26 | } 27 | 28 | void EmulatorBase::ConnectDevice(Device::Base &dev){ 29 | this->dev.push_back(&dev); 30 | } 31 | 32 | void EmulatorBase::Dump(){ 33 | DumpRegisters(); 34 | DumpMemory(); 35 | } 36 | 37 | void EmulatorBase::DumpRegisters(){ 38 | std::cout 39 | << std::endl 40 | << "---- dump registers ----" 41 | << std::endl; 42 | for(size_t i=0;iGetName() 47 | << "\t: " 48 | // << "0x" 49 | // << std::showbase // <- if 0, dosen't work 50 | // << std::hex 51 | // << std::setw(4) 52 | // << std::setfill('0') 53 | // << all_reg[i].reg32 54 | << all_reg[i]->GetDataByString() 55 | << std::endl; 56 | } 57 | std::cout 58 | << "------------------------" 59 | << std::endl; 60 | } 61 | 62 | void EmulatorBase::DumpMemory(){ 63 | memory->Dump("memdump.bin", 0, memory->size); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /emulator_base.h: -------------------------------------------------------------------------------- 1 | #ifndef EMULATOR_BASE_H_ 2 | #define EMULATOR_BASE_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "insn_base.h" 8 | #include "register_base.h" 9 | #include "memory.h" 10 | #include "io.h" 11 | #include "device/device.h" 12 | #include "bios/base.h" 13 | 14 | class EmulatorBase { 15 | public: 16 | EmulatorBase(); 17 | virtual ~EmulatorBase(); // 継承前提のクラスのデストラクタはvirtual 18 | void Init(); 19 | void SetBios(BIOS::Base *bios); 20 | virtual void InitInstructions() = 0; 21 | virtual void InitRegisters() = 0; 22 | virtual void InitMemory() = 0; 23 | virtual void InitIO() = 0; 24 | 25 | virtual void ConnectDevice(Device::Base &dev); 26 | 27 | virtual void Run(bool halt_exit){ 28 | while(!finish_flg && !(halt_exit && halt_flg)){ 29 | if(halt_flg) continue; 30 | insn->Fetch(); 31 | insn->Decode(); 32 | insn->Exec(); 33 | } 34 | } 35 | 36 | virtual void Dump(); 37 | virtual void DumpRegisters(); 38 | virtual void DumpMemory(); 39 | 40 | bool halt_flg = false; 41 | bool finish_flg = false; 42 | 43 | InstructionBase *insn; 44 | std::vector all_reg; 45 | std::vector dev; 46 | Memory *memory; 47 | IO *io; 48 | BIOS::Base *bios; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /font/.gitignore: -------------------------------------------------------------------------------- 1 | makefont 2 | -------------------------------------------------------------------------------- /font/Makefile: -------------------------------------------------------------------------------- 1 | DEPTH := ../../../ 2 | include ../com_mak.txt 3 | 4 | MAKEFONT := makefont 5 | MAKEFONT_OBJS := makefont.o 6 | FONT_OBJ := font.o 7 | 8 | %.bin : %.txt $(MAKEFONT) 9 | ./$(MAKEFONT) $< $@ 10 | 11 | default: 12 | make $(FONT_OBJ) 13 | make hankaku.bin 14 | 15 | clean: 16 | rm -f *.o *.bin $(MAKEFONT) 17 | 18 | $(MAKEFONT):$(MAKEFONT_OBJS) 19 | $(CC) $^ -o $@ 20 | -------------------------------------------------------------------------------- /font/font.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "font.h" 3 | 4 | Font::Font(const char *fname){ 5 | num = 0; 6 | data = std::vector(); 7 | LoadFile(fname); 8 | } 9 | 10 | Font::~Font(){ 11 | 12 | } 13 | 14 | bool Font::LoadFile(const char *fname){ 15 | FILE *fp; 16 | fp = fopen(fname, "rb"); 17 | if(fp == NULL) 18 | throw "can't open font file!"; 19 | 20 | fscanf(fp, "%d", &xsize); 21 | fscanf(fp, "%d", &ysize); 22 | 23 | printf("font size: %dx%d\n", xsize, ysize); 24 | 25 | size_t size = (xsize * ysize)/8; 26 | 27 | char *tmp; 28 | tmp = new char[size]; 29 | data.reserve(size*256); 30 | 31 | do { 32 | if(fread(tmp, size, 1, fp) < 1) break; 33 | if(data.size() < size*num) data.reserve(size*num); 34 | for(size_t i=0;i<(size);i++){ 35 | data[num*(size) + i] = tmp[i]; 36 | } 37 | num++; 38 | } while(!feof(fp)); 39 | 40 | fclose(fp); 41 | return true; 42 | } 43 | -------------------------------------------------------------------------------- /font/font.h: -------------------------------------------------------------------------------- 1 | #ifndef FONT_H_ 2 | #define FONT_H_ 3 | 4 | #include 5 | #include "../common.h" 6 | 7 | class Font { 8 | public: 9 | Font(const char *fname); 10 | ~Font(); 11 | 12 | int GetNum(){ return num; } 13 | 14 | bool LoadFile(const char *fname); 15 | 16 | inline char operator[](int i){ 17 | return data[i]; 18 | } 19 | private: 20 | int xsize, ysize, num; 21 | std::vector data; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /font/hankaku.txt: -------------------------------------------------------------------------------- 1 | 8 2 | 16 3 | OSASKの半角フォントを流用 4 | 5 | char 0x00 6 | ........ 7 | ........ 8 | ........ 9 | ........ 10 | ........ 11 | ........ 12 | ........ 13 | ........ 14 | ........ 15 | ........ 16 | ........ 17 | ........ 18 | ........ 19 | ........ 20 | ........ 21 | ........ 22 | 23 | char 0x01 24 | ........ 25 | ........ 26 | ..***... 27 | .*...*.. 28 | *.....*. 29 | *.*.*.*. 30 | *.*.*.*. 31 | *.....*. 32 | *.....*. 33 | *.*.*.*. 34 | *..*..*. 35 | .*...*.. 36 | ..***... 37 | ........ 38 | ........ 39 | ........ 40 | 41 | char 0x02 42 | ........ 43 | ........ 44 | ..***... 45 | .*****.. 46 | *******. 47 | **.*.**. 48 | **.*.**. 49 | *******. 50 | *******. 51 | **.*.**. 52 | ***.***. 53 | .*****.. 54 | ..***... 55 | ........ 56 | ........ 57 | ........ 58 | 59 | char 0x03 60 | ........ 61 | ........ 62 | ........ 63 | ........ 64 | .**.**.. 65 | *******. 66 | *******. 67 | *******. 68 | .*****.. 69 | ..***... 70 | ...*.... 71 | ........ 72 | ........ 73 | ........ 74 | ........ 75 | ........ 76 | 77 | char 0x04 78 | ........ 79 | ........ 80 | ........ 81 | ........ 82 | ...*.... 83 | ..***... 84 | .*****.. 85 | *******. 86 | .*****.. 87 | ..***... 88 | ...*.... 89 | ........ 90 | ........ 91 | ........ 92 | ........ 93 | ........ 94 | 95 | char 0x05 96 | ........ 97 | ........ 98 | ........ 99 | ........ 100 | ...*.... 101 | ..***... 102 | .*.*.*.. 103 | *******. 104 | .*.*.*.. 105 | ...*.... 106 | ..***... 107 | ........ 108 | ........ 109 | ........ 110 | ........ 111 | ........ 112 | 113 | char 0x06 114 | ........ 115 | ........ 116 | ........ 117 | ........ 118 | ...*.... 119 | ..***... 120 | .*****.. 121 | *******. 122 | **.*.**. 123 | ...*.... 124 | ..***... 125 | ........ 126 | ........ 127 | ........ 128 | ........ 129 | ........ 130 | 131 | char 0x07 132 | ........ 133 | ........ 134 | ........ 135 | ........ 136 | ........ 137 | ........ 138 | ...**... 139 | ..****.. 140 | ..****.. 141 | ...**... 142 | ........ 143 | ........ 144 | ........ 145 | ........ 146 | ........ 147 | ........ 148 | 149 | char 0x08 150 | ******** 151 | ******** 152 | ******** 153 | ******** 154 | ******** 155 | ******** 156 | ***..*** 157 | **....** 158 | **....** 159 | ***..*** 160 | ******** 161 | ******** 162 | ******** 163 | ******** 164 | ******** 165 | ******** 166 | 167 | char 0x09 168 | ........ 169 | ........ 170 | ........ 171 | ........ 172 | ........ 173 | ..****.. 174 | .**..**. 175 | .*....*. 176 | .*....*. 177 | .**..**. 178 | ..****.. 179 | ........ 180 | ........ 181 | ........ 182 | ........ 183 | ........ 184 | 185 | char 0x0a 186 | ******** 187 | ******** 188 | ******** 189 | ******** 190 | ******** 191 | **....** 192 | *..**..* 193 | *.****.* 194 | *.****.* 195 | *..**..* 196 | **....** 197 | ******** 198 | ******** 199 | ******** 200 | ******** 201 | ******** 202 | 203 | char 0x0b 204 | ........ 205 | ...*.... 206 | ..***... 207 | .*.*.*.. 208 | *..*..*. 209 | ...*.... 210 | ...*.... 211 | ..***... 212 | .*...*.. 213 | *.....*. 214 | *.....*. 215 | *.....*. 216 | .*...*.. 217 | ..***... 218 | ........ 219 | ........ 220 | 221 | char 0x0c 222 | ........ 223 | ..***... 224 | .*...*.. 225 | *.....*. 226 | *.....*. 227 | *.....*. 228 | .*...*.. 229 | ..***... 230 | ...*.... 231 | ...*.... 232 | *******. 233 | ...*.... 234 | ...*.... 235 | ...*.... 236 | ........ 237 | ........ 238 | 239 | char 0x0d 240 | ........ 241 | ........ 242 | ....**.. 243 | ....***. 244 | ....*.** 245 | ....*.** 246 | ....*.*. 247 | ....*... 248 | ....*... 249 | ...**... 250 | .****... 251 | *****... 252 | .***.... 253 | ........ 254 | ........ 255 | ........ 256 | 257 | char 0x0e 258 | ........ 259 | ........ 260 | ...***** 261 | ...***** 262 | ...*...* 263 | ...*...* 264 | ...*...* 265 | ...*...* 266 | ...*...* 267 | ...*...* 268 | .***.*** 269 | ******** 270 | .**..**. 271 | ........ 272 | ........ 273 | ........ 274 | 275 | char 0x0f 276 | ........ 277 | ........ 278 | ........ 279 | ........ 280 | ...*.... 281 | .*.*.*.. 282 | ..***... 283 | ..*.*... 284 | ..***... 285 | .*.*.*.. 286 | ...*.... 287 | ........ 288 | ........ 289 | ........ 290 | ........ 291 | ........ 292 | 293 | char 0x10 294 | ........ 295 | *....... 296 | **...... 297 | ***..... 298 | ****.... 299 | *****... 300 | ******.. 301 | *******. 302 | ******.. 303 | *****... 304 | ****.... 305 | ***..... 306 | **...... 307 | *....... 308 | ........ 309 | ........ 310 | 311 | char 0x11 312 | ........ 313 | ......*. 314 | .....**. 315 | ....***. 316 | ...****. 317 | ..*****. 318 | .******. 319 | *******. 320 | .******. 321 | ..*****. 322 | ...****. 323 | ....***. 324 | .....**. 325 | ......*. 326 | ........ 327 | ........ 328 | 329 | char 0x12 330 | ........ 331 | ........ 332 | ...*.... 333 | ..***... 334 | .*.*.*.. 335 | *..*..*. 336 | ...*.... 337 | ...*.... 338 | ...*.... 339 | *..*..*. 340 | .*.*.*.. 341 | ..***... 342 | ...*.... 343 | ........ 344 | ........ 345 | ........ 346 | 347 | char 0x13 348 | ........ 349 | ........ 350 | .*...*.. 351 | .*...*.. 352 | .*...*.. 353 | .*...*.. 354 | .*...*.. 355 | .*...*.. 356 | .*...*.. 357 | .*...*.. 358 | ........ 359 | ........ 360 | .*...*.. 361 | .*...*.. 362 | ........ 363 | ........ 364 | 365 | char 0x14 366 | ........ 367 | ..*****. 368 | .*..*.*. 369 | *...*.*. 370 | *...*.*. 371 | *...*.*. 372 | *...*.*. 373 | .*..*.*. 374 | ..***.*. 375 | ....*.*. 376 | ....*.*. 377 | ....*.*. 378 | ....*.*. 379 | ....*.*. 380 | ........ 381 | ........ 382 | 383 | char 0x15 384 | .*****.. 385 | *.....*. 386 | .*...... 387 | ..*..... 388 | ..***... 389 | .*...*.. 390 | *.....*. 391 | *.....*. 392 | *.....*. 393 | .*...*.. 394 | ..***... 395 | ....*... 396 | .....*.. 397 | *.....*. 398 | .*****.. 399 | ........ 400 | 401 | char 0x16 402 | ........ 403 | ........ 404 | ........ 405 | ........ 406 | ........ 407 | ........ 408 | ........ 409 | ........ 410 | ........ 411 | ........ 412 | ........ 413 | *******. 414 | *******. 415 | *******. 416 | ........ 417 | ........ 418 | 419 | char 0x17 420 | ........ 421 | ........ 422 | ...*.... 423 | ..***... 424 | .*.*.*.. 425 | *..*..*. 426 | ...*.... 427 | ...*.... 428 | ...*.... 429 | *..*..*. 430 | .*.*.*.. 431 | ..***... 432 | ...*.... 433 | .*****.. 434 | ........ 435 | ........ 436 | 437 | char 0x18 438 | ........ 439 | ...*.... 440 | ..***... 441 | .*.*.*.. 442 | *..*..*. 443 | ...*.... 444 | ...*.... 445 | ...*.... 446 | ...*.... 447 | ...*.... 448 | ...*.... 449 | ...*.... 450 | ...*.... 451 | ...*.... 452 | ........ 453 | ........ 454 | 455 | char 0x19 456 | ........ 457 | ...*.... 458 | ...*.... 459 | ...*.... 460 | ...*.... 461 | ...*.... 462 | ...*.... 463 | ...*.... 464 | ...*.... 465 | ...*.... 466 | *..*..*. 467 | .*.*.*.. 468 | ..***... 469 | ...*.... 470 | ........ 471 | ........ 472 | 473 | char 0x1a 474 | ........ 475 | ........ 476 | ........ 477 | ........ 478 | ...*.... 479 | ....*... 480 | .....*.. 481 | *******. 482 | .....*.. 483 | ....*... 484 | ...*.... 485 | ........ 486 | ........ 487 | ........ 488 | ........ 489 | ........ 490 | 491 | char 0x1b 492 | ........ 493 | ........ 494 | ........ 495 | ........ 496 | ...*.... 497 | ..*..... 498 | .*...... 499 | *******. 500 | .*...... 501 | ..*..... 502 | ...*.... 503 | ........ 504 | ........ 505 | ........ 506 | ........ 507 | ........ 508 | 509 | char 0x1c 510 | ........ 511 | ........ 512 | ........ 513 | ........ 514 | ........ 515 | ........ 516 | ........ 517 | ........ 518 | ........ 519 | ........ 520 | ........ 521 | *....... 522 | *....... 523 | *******. 524 | ........ 525 | ........ 526 | 527 | char 0x1d 528 | ........ 529 | ........ 530 | ........ 531 | ........ 532 | ........ 533 | ..*.*... 534 | .*...*.. 535 | *******. 536 | .*...*.. 537 | ..*.*... 538 | ........ 539 | ........ 540 | ........ 541 | ........ 542 | ........ 543 | ........ 544 | 545 | char 0x1e 546 | ........ 547 | ........ 548 | ........ 549 | ........ 550 | ...*.... 551 | ...*.... 552 | ..***... 553 | ..***... 554 | .*****.. 555 | .*****.. 556 | *******. 557 | *******. 558 | ........ 559 | ........ 560 | ........ 561 | ........ 562 | 563 | char 0x1f 564 | ........ 565 | ........ 566 | ........ 567 | ........ 568 | *******. 569 | *******. 570 | .*****.. 571 | .*****.. 572 | ..***... 573 | ..***... 574 | ...*.... 575 | ...*.... 576 | ........ 577 | ........ 578 | ........ 579 | ........ 580 | 581 | char 0x20 582 | ........ 583 | ........ 584 | ........ 585 | ........ 586 | ........ 587 | ........ 588 | ........ 589 | ........ 590 | ........ 591 | ........ 592 | ........ 593 | ........ 594 | ........ 595 | ........ 596 | ........ 597 | ........ 598 | 599 | char 0x21 600 | ........ 601 | ...*.... 602 | ...*.... 603 | ...*.... 604 | ...*.... 605 | ...*.... 606 | ...*.... 607 | ...*.... 608 | ...*.... 609 | ...*.... 610 | ........ 611 | ........ 612 | ...*.... 613 | ...*.... 614 | ........ 615 | ........ 616 | 617 | char 0x22 618 | ..*.*... 619 | ..*.*... 620 | ..*.*... 621 | ........ 622 | ........ 623 | ........ 624 | ........ 625 | ........ 626 | ........ 627 | ........ 628 | ........ 629 | ........ 630 | ........ 631 | ........ 632 | ........ 633 | ........ 634 | 635 | char 0x23 636 | ........ 637 | .*...*.. 638 | .*...*.. 639 | .*...*.. 640 | *******. 641 | .*...*.. 642 | .*...*.. 643 | .*...*.. 644 | .*...*.. 645 | .*...*.. 646 | *******. 647 | .*...*.. 648 | .*...*.. 649 | .*...*.. 650 | ........ 651 | ........ 652 | 653 | char 0x24 654 | ...*.... 655 | ..***.*. 656 | .*.*.**. 657 | *..*..*. 658 | *..*..*. 659 | *..*.... 660 | .*.*.... 661 | ..***... 662 | ...*.*.. 663 | ...*..*. 664 | *..*..*. 665 | *..*..*. 666 | **.*.*.. 667 | *.***... 668 | ...*.... 669 | ...*.... 670 | 671 | char 0x25 672 | .**...*. 673 | *..*..*. 674 | *..*.*.. 675 | *..*.*.. 676 | .**.*... 677 | ....*... 678 | ...*.... 679 | ...*.... 680 | ..*..... 681 | ..*.**.. 682 | .*.*..*. 683 | .*.*..*. 684 | *..*..*. 685 | *...**.. 686 | ........ 687 | ........ 688 | 689 | char 0x26 690 | ........ 691 | .***.... 692 | *...*... 693 | *...*... 694 | *...*... 695 | *..*.... 696 | .**..... 697 | .*...*** 698 | *.*...*. 699 | *..*..*. 700 | *...*.*. 701 | *....*.. 702 | .*...**. 703 | ..***..* 704 | ........ 705 | ........ 706 | 707 | char 0x27 708 | .....*.. 709 | ....*... 710 | ...*.... 711 | ........ 712 | ........ 713 | ........ 714 | ........ 715 | ........ 716 | ........ 717 | ........ 718 | ........ 719 | ........ 720 | ........ 721 | ........ 722 | ........ 723 | ........ 724 | 725 | char 0x28 726 | ......*. 727 | .....*.. 728 | ....*... 729 | ....*... 730 | ...*.... 731 | ...*.... 732 | ...*.... 733 | ...*.... 734 | ...*.... 735 | ...*.... 736 | ...*.... 737 | ....*... 738 | ....*... 739 | .....*.. 740 | ......*. 741 | ........ 742 | 743 | char 0x29 744 | *....... 745 | .*...... 746 | ..*..... 747 | ..*..... 748 | ...*.... 749 | ...*.... 750 | ...*.... 751 | ...*.... 752 | ...*.... 753 | ...*.... 754 | ...*.... 755 | ..*..... 756 | ..*..... 757 | .*...... 758 | *....... 759 | ........ 760 | 761 | char 0x2a 762 | ........ 763 | ........ 764 | ........ 765 | ........ 766 | ........ 767 | ...*.... 768 | *..*..*. 769 | .*.*.*.. 770 | ..***... 771 | .*.*.*.. 772 | *..*..*. 773 | ...*.... 774 | ........ 775 | ........ 776 | ........ 777 | ........ 778 | 779 | char 0x2b 780 | ........ 781 | ........ 782 | ........ 783 | ........ 784 | ........ 785 | ...*.... 786 | ...*.... 787 | ...*.... 788 | *******. 789 | ...*.... 790 | ...*.... 791 | ...*.... 792 | ........ 793 | ........ 794 | ........ 795 | ........ 796 | 797 | char 0x2c 798 | ........ 799 | ........ 800 | ........ 801 | ........ 802 | ........ 803 | ........ 804 | ........ 805 | ........ 806 | ........ 807 | ........ 808 | ........ 809 | ...**... 810 | ...**... 811 | ....*... 812 | ....*... 813 | ...*.... 814 | 815 | char 0x2d 816 | ........ 817 | ........ 818 | ........ 819 | ........ 820 | ........ 821 | ........ 822 | ........ 823 | ........ 824 | *******. 825 | ........ 826 | ........ 827 | ........ 828 | ........ 829 | ........ 830 | ........ 831 | ........ 832 | 833 | char 0x2e 834 | ........ 835 | ........ 836 | ........ 837 | ........ 838 | ........ 839 | ........ 840 | ........ 841 | ........ 842 | ........ 843 | ........ 844 | ........ 845 | ........ 846 | ...**... 847 | ...**... 848 | ........ 849 | ........ 850 | 851 | char 0x2f 852 | ......*. 853 | ......*. 854 | .....*.. 855 | .....*.. 856 | ....*... 857 | ....*... 858 | ....*... 859 | ...*.... 860 | ...*.... 861 | ..*..... 862 | ..*..... 863 | .*...... 864 | .*...... 865 | .*...... 866 | *....... 867 | *....... 868 | 869 | char 0x30 870 | ........ 871 | ...**... 872 | ..*..*.. 873 | ..*..*.. 874 | .*....*. 875 | .*....*. 876 | .*....*. 877 | .*....*. 878 | .*....*. 879 | .*....*. 880 | .*....*. 881 | ..*..*.. 882 | ..*..*.. 883 | ...**... 884 | ........ 885 | ........ 886 | 887 | char 0x31 888 | ........ 889 | ....*... 890 | ...**... 891 | ..*.*... 892 | ....*... 893 | ....*... 894 | ....*... 895 | ....*... 896 | ....*... 897 | ....*... 898 | ....*... 899 | ....*... 900 | ....*... 901 | ..*****. 902 | ........ 903 | ........ 904 | 905 | char 0x32 906 | ........ 907 | ...**... 908 | ..*..*.. 909 | .*....*. 910 | .*....*. 911 | ......*. 912 | .....*.. 913 | ....*... 914 | ...*.... 915 | ..*..... 916 | ..*..... 917 | .*...... 918 | .*...... 919 | .******. 920 | ........ 921 | ........ 922 | 923 | char 0x33 924 | ........ 925 | ...**... 926 | ..*..*.. 927 | .*....*. 928 | ......*. 929 | ......*. 930 | .....*.. 931 | ...**... 932 | .....*.. 933 | ......*. 934 | ......*. 935 | .*....*. 936 | ..*..*.. 937 | ...**... 938 | ........ 939 | ........ 940 | 941 | char 0x34 942 | ........ 943 | ....**.. 944 | ....**.. 945 | ....**.. 946 | ...*.*.. 947 | ...*.*.. 948 | ...*.*.. 949 | ..*..*.. 950 | ..*..*.. 951 | .*...*.. 952 | .******. 953 | .....*.. 954 | .....*.. 955 | ...****. 956 | ........ 957 | ........ 958 | 959 | char 0x35 960 | ........ 961 | .*****.. 962 | .*...... 963 | .*...... 964 | .*...... 965 | .*.**... 966 | .**..*.. 967 | ......*. 968 | ......*. 969 | ......*. 970 | ......*. 971 | .*....*. 972 | ..*..*.. 973 | ...**... 974 | ........ 975 | ........ 976 | 977 | char 0x36 978 | ........ 979 | ...**... 980 | ..*..*.. 981 | .*....*. 982 | .*...... 983 | .*.**... 984 | .**..*.. 985 | .*....*. 986 | .*....*. 987 | .*....*. 988 | .*....*. 989 | .*....*. 990 | ..*..*.. 991 | ...**... 992 | ........ 993 | ........ 994 | 995 | char 0x37 996 | ........ 997 | .******. 998 | .*....*. 999 | .*....*. 1000 | .....*.. 1001 | .....*.. 1002 | ....*... 1003 | ....*... 1004 | ....*... 1005 | ...*.... 1006 | ...*.... 1007 | ...*.... 1008 | ...*.... 1009 | ..***... 1010 | ........ 1011 | ........ 1012 | 1013 | char 0x38 1014 | ........ 1015 | ...**... 1016 | ..*..*.. 1017 | .*....*. 1018 | .*....*. 1019 | .*....*. 1020 | ..*..*.. 1021 | ...**... 1022 | ..*..*.. 1023 | .*....*. 1024 | .*....*. 1025 | .*....*. 1026 | ..*..*.. 1027 | ...**... 1028 | ........ 1029 | ........ 1030 | 1031 | char 0x39 1032 | ........ 1033 | ...**... 1034 | ..*..*.. 1035 | .*....*. 1036 | .*....*. 1037 | .*....*. 1038 | .*....*. 1039 | .*....*. 1040 | ..*..**. 1041 | ...**.*. 1042 | ......*. 1043 | .*....*. 1044 | ..*..*.. 1045 | ...**... 1046 | ........ 1047 | ........ 1048 | 1049 | char 0x3a 1050 | ........ 1051 | ........ 1052 | ........ 1053 | ........ 1054 | ........ 1055 | ...**... 1056 | ...**... 1057 | ........ 1058 | ........ 1059 | ........ 1060 | ........ 1061 | ........ 1062 | ...**... 1063 | ...**... 1064 | ........ 1065 | ........ 1066 | 1067 | char 0x3b 1068 | ........ 1069 | ........ 1070 | ........ 1071 | ........ 1072 | ........ 1073 | ...**... 1074 | ...**... 1075 | ........ 1076 | ........ 1077 | ........ 1078 | ........ 1079 | ...**... 1080 | ...**... 1081 | ....*... 1082 | ....*... 1083 | ...*.... 1084 | 1085 | char 0x3c 1086 | ........ 1087 | ......*. 1088 | .....*.. 1089 | ....*... 1090 | ...*.... 1091 | ..*..... 1092 | .*...... 1093 | *....... 1094 | *....... 1095 | .*...... 1096 | ..*..... 1097 | ...*.... 1098 | ....*... 1099 | .....*.. 1100 | ......*. 1101 | ........ 1102 | 1103 | char 0x3d 1104 | ........ 1105 | ........ 1106 | ........ 1107 | ........ 1108 | ........ 1109 | ........ 1110 | *******. 1111 | ........ 1112 | ........ 1113 | *******. 1114 | ........ 1115 | ........ 1116 | ........ 1117 | ........ 1118 | ........ 1119 | ........ 1120 | 1121 | char 0x3e 1122 | ........ 1123 | *....... 1124 | .*...... 1125 | ..*..... 1126 | ...*.... 1127 | ....*... 1128 | .....*.. 1129 | ......*. 1130 | ......*. 1131 | .....*.. 1132 | ....*... 1133 | ...*.... 1134 | ..*..... 1135 | .*...... 1136 | *....... 1137 | ........ 1138 | 1139 | char 0x3f 1140 | ........ 1141 | ..***... 1142 | .*...*.. 1143 | *.....*. 1144 | *.....*. 1145 | *.....*. 1146 | .....*.. 1147 | ....*... 1148 | ...*.... 1149 | ...*.... 1150 | ........ 1151 | ........ 1152 | ...**... 1153 | ...**... 1154 | ........ 1155 | ........ 1156 | 1157 | char 0x40 1158 | ........ 1159 | ..***... 1160 | .*...*.. 1161 | *.....*. 1162 | *..**.*. 1163 | *.*.*.*. 1164 | *.*.*.*. 1165 | *.*.*.*. 1166 | *.*.*.*. 1167 | *.*.*.*. 1168 | *..***.. 1169 | *....... 1170 | .*...**. 1171 | ..***... 1172 | ........ 1173 | ........ 1174 | 1175 | char 0x41 1176 | ........ 1177 | ...**... 1178 | ...**... 1179 | ...**... 1180 | ...**... 1181 | ..*..*.. 1182 | ..*..*.. 1183 | ..*..*.. 1184 | ..*..*.. 1185 | .******. 1186 | .*....*. 1187 | .*....*. 1188 | .*....*. 1189 | ***..*** 1190 | ........ 1191 | ........ 1192 | 1193 | char 0x42 1194 | ........ 1195 | ****.... 1196 | .*..*... 1197 | .*...*.. 1198 | .*...*.. 1199 | .*...*.. 1200 | .*..*... 1201 | .****... 1202 | .*...*.. 1203 | .*....*. 1204 | .*....*. 1205 | .*....*. 1206 | .*...*.. 1207 | *****... 1208 | ........ 1209 | ........ 1210 | 1211 | char 0x43 1212 | ........ 1213 | ..***.*. 1214 | .*...**. 1215 | .*....*. 1216 | *.....*. 1217 | *....... 1218 | *....... 1219 | *....... 1220 | *....... 1221 | *....... 1222 | *.....*. 1223 | .*....*. 1224 | .*...*.. 1225 | ..***... 1226 | ........ 1227 | ........ 1228 | 1229 | char 0x44 1230 | ........ 1231 | *****... 1232 | .*...*.. 1233 | .*...*.. 1234 | .*....*. 1235 | .*....*. 1236 | .*....*. 1237 | .*....*. 1238 | .*....*. 1239 | .*....*. 1240 | .*....*. 1241 | .*...*.. 1242 | .*...*.. 1243 | *****... 1244 | ........ 1245 | ........ 1246 | 1247 | char 0x45 1248 | ........ 1249 | *******. 1250 | .*....*. 1251 | .*....*. 1252 | .*...... 1253 | .*...... 1254 | .*...*.. 1255 | .*****.. 1256 | .*...*.. 1257 | .*...... 1258 | .*...... 1259 | .*....*. 1260 | .*....*. 1261 | *******. 1262 | ........ 1263 | ........ 1264 | 1265 | char 0x46 1266 | ........ 1267 | *******. 1268 | .*....*. 1269 | .*....*. 1270 | .*...... 1271 | .*...... 1272 | .*...*.. 1273 | .*****.. 1274 | .*...*.. 1275 | .*...*.. 1276 | .*...... 1277 | .*...... 1278 | .*...... 1279 | ****.... 1280 | ........ 1281 | ........ 1282 | 1283 | char 0x47 1284 | ........ 1285 | ..***.*. 1286 | .*...**. 1287 | .*....*. 1288 | *.....*. 1289 | *....... 1290 | *....... 1291 | *..****. 1292 | *.....*. 1293 | *.....*. 1294 | *.....*. 1295 | .*....*. 1296 | .*...**. 1297 | ..***... 1298 | ........ 1299 | ........ 1300 | 1301 | char 0x48 1302 | ........ 1303 | ***..*** 1304 | .*....*. 1305 | .*....*. 1306 | .*....*. 1307 | .*....*. 1308 | .*....*. 1309 | .******. 1310 | .*....*. 1311 | .*....*. 1312 | .*....*. 1313 | .*....*. 1314 | .*....*. 1315 | ***..*** 1316 | ........ 1317 | ........ 1318 | 1319 | char 0x49 1320 | ........ 1321 | .*****.. 1322 | ...*.... 1323 | ...*.... 1324 | ...*.... 1325 | ...*.... 1326 | ...*.... 1327 | ...*.... 1328 | ...*.... 1329 | ...*.... 1330 | ...*.... 1331 | ...*.... 1332 | ...*.... 1333 | .*****.. 1334 | ........ 1335 | ........ 1336 | 1337 | char 0x4a 1338 | ........ 1339 | ...***** 1340 | .....*.. 1341 | .....*.. 1342 | .....*.. 1343 | .....*.. 1344 | .....*.. 1345 | .....*.. 1346 | .....*.. 1347 | .....*.. 1348 | .....*.. 1349 | .....*.. 1350 | *....*.. 1351 | .*..*... 1352 | ..**.... 1353 | ........ 1354 | 1355 | char 0x4b 1356 | ........ 1357 | ***..*** 1358 | .*....*. 1359 | .*...*.. 1360 | .*..*... 1361 | .*.*.... 1362 | .*.*.... 1363 | .**..... 1364 | .*.*.... 1365 | .*.*.... 1366 | .*..*... 1367 | .*...*.. 1368 | .*....*. 1369 | ***..*** 1370 | ........ 1371 | ........ 1372 | 1373 | char 0x4c 1374 | ........ 1375 | ****.... 1376 | .*...... 1377 | .*...... 1378 | .*...... 1379 | .*...... 1380 | .*...... 1381 | .*...... 1382 | .*...... 1383 | .*...... 1384 | .*...... 1385 | .*....*. 1386 | .*....*. 1387 | *******. 1388 | ........ 1389 | ........ 1390 | 1391 | char 0x4d 1392 | ........ 1393 | **....** 1394 | .*....*. 1395 | .**..**. 1396 | .**..**. 1397 | .**..**. 1398 | .*.**.*. 1399 | .*.**.*. 1400 | .*.**.*. 1401 | .*....*. 1402 | .*....*. 1403 | .*....*. 1404 | .*....*. 1405 | ***..*** 1406 | ........ 1407 | ........ 1408 | 1409 | char 0x4e 1410 | ........ 1411 | **...*** 1412 | .*....*. 1413 | .**...*. 1414 | .**...*. 1415 | .*.*..*. 1416 | .*.*..*. 1417 | .*.*..*. 1418 | .*..*.*. 1419 | .*..*.*. 1420 | .*..*.*. 1421 | .*...**. 1422 | .*...**. 1423 | ***...*. 1424 | ........ 1425 | ........ 1426 | 1427 | char 0x4f 1428 | ........ 1429 | ..***... 1430 | .*...*.. 1431 | *.....*. 1432 | *.....*. 1433 | *.....*. 1434 | *.....*. 1435 | *.....*. 1436 | *.....*. 1437 | *.....*. 1438 | *.....*. 1439 | *.....*. 1440 | .*...*.. 1441 | ..***... 1442 | ........ 1443 | ........ 1444 | 1445 | char 0x50 1446 | ........ 1447 | *****... 1448 | .*...*.. 1449 | .*....*. 1450 | .*....*. 1451 | .*....*. 1452 | .*...*.. 1453 | .****... 1454 | .*...... 1455 | .*...... 1456 | .*...... 1457 | .*...... 1458 | .*...... 1459 | ****.... 1460 | ........ 1461 | ........ 1462 | 1463 | char 0x51 1464 | ........ 1465 | ..***... 1466 | .*...*.. 1467 | *.....*. 1468 | *.....*. 1469 | *.....*. 1470 | *.....*. 1471 | *.....*. 1472 | *.....*. 1473 | *.....*. 1474 | *..*..*. 1475 | *...*.*. 1476 | .*...*.. 1477 | ..***.*. 1478 | ........ 1479 | ........ 1480 | 1481 | char 0x52 1482 | ........ 1483 | ******.. 1484 | .*....*. 1485 | .*....*. 1486 | .*....*. 1487 | .*....*. 1488 | .*****.. 1489 | .*...*.. 1490 | .*....*. 1491 | .*....*. 1492 | .*....*. 1493 | .*....*. 1494 | .*....*. 1495 | ***..*** 1496 | ........ 1497 | ........ 1498 | 1499 | char 0x53 1500 | ........ 1501 | ..***.*. 1502 | .*...**. 1503 | *.....*. 1504 | *.....*. 1505 | *....... 1506 | .*...... 1507 | ..***... 1508 | .....*.. 1509 | ......*. 1510 | *.....*. 1511 | *.....*. 1512 | **...*.. 1513 | *.***... 1514 | ........ 1515 | ........ 1516 | 1517 | char 0x54 1518 | ........ 1519 | *******. 1520 | *..*..*. 1521 | *..*..*. 1522 | ...*.... 1523 | ...*.... 1524 | ...*.... 1525 | ...*.... 1526 | ...*.... 1527 | ...*.... 1528 | ...*.... 1529 | ...*.... 1530 | ...*.... 1531 | .*****.. 1532 | ........ 1533 | ........ 1534 | 1535 | char 0x55 1536 | ........ 1537 | ***..*** 1538 | .*....*. 1539 | .*....*. 1540 | .*....*. 1541 | .*....*. 1542 | .*....*. 1543 | .*....*. 1544 | .*....*. 1545 | .*....*. 1546 | .*....*. 1547 | .*....*. 1548 | ..*..*.. 1549 | ..****.. 1550 | ........ 1551 | ........ 1552 | 1553 | char 0x56 1554 | ........ 1555 | ***..*** 1556 | .*....*. 1557 | .*....*. 1558 | .*....*. 1559 | .*....*. 1560 | ..*..*.. 1561 | ..*..*.. 1562 | ..*..*.. 1563 | ..*..*.. 1564 | ...**... 1565 | ...**... 1566 | ...**... 1567 | ...**... 1568 | ........ 1569 | ........ 1570 | 1571 | char 0x57 1572 | ........ 1573 | ***..*** 1574 | .*....*. 1575 | .*....*. 1576 | .*....*. 1577 | .*.**.*. 1578 | .*.**.*. 1579 | .*.**.*. 1580 | .*.**.*. 1581 | ..*..*.. 1582 | ..*..*.. 1583 | ..*..*.. 1584 | ..*..*.. 1585 | ..*..*.. 1586 | ........ 1587 | ........ 1588 | 1589 | char 0x58 1590 | ........ 1591 | ***..*** 1592 | .*....*. 1593 | .*....*. 1594 | ..*..*.. 1595 | ..*..*.. 1596 | ..*..*.. 1597 | ...**... 1598 | ..*..*.. 1599 | ..*..*.. 1600 | ..*..*.. 1601 | .*....*. 1602 | .*....*. 1603 | ***..*** 1604 | ........ 1605 | ........ 1606 | 1607 | char 0x59 1608 | ........ 1609 | ***.***. 1610 | .*...*.. 1611 | .*...*.. 1612 | .*...*.. 1613 | ..*.*... 1614 | ..*.*... 1615 | ..*.*... 1616 | ...*.... 1617 | ...*.... 1618 | ...*.... 1619 | ...*.... 1620 | ...*.... 1621 | .*****.. 1622 | ........ 1623 | ........ 1624 | 1625 | char 0x5a 1626 | ........ 1627 | *******. 1628 | *....*.. 1629 | *....*.. 1630 | ....*... 1631 | ....*... 1632 | ...*.... 1633 | ...*.... 1634 | ..*..... 1635 | ..*..... 1636 | .*...... 1637 | .*....*. 1638 | *.....*. 1639 | *******. 1640 | ........ 1641 | ........ 1642 | 1643 | char 0x5b 1644 | ........ 1645 | ..*****. 1646 | ..*..... 1647 | ..*..... 1648 | ..*..... 1649 | ..*..... 1650 | ..*..... 1651 | ..*..... 1652 | ..*..... 1653 | ..*..... 1654 | ..*..... 1655 | ..*..... 1656 | ..*..... 1657 | ..*..... 1658 | ..*****. 1659 | ........ 1660 | 1661 | char 0x5c 1662 | *....... 1663 | *....... 1664 | .*...... 1665 | .*...... 1666 | ..*..... 1667 | ..*..... 1668 | ..*..... 1669 | ...*.... 1670 | ...*.... 1671 | ....*... 1672 | ....*... 1673 | .....*.. 1674 | .....*.. 1675 | .....*.. 1676 | ......*. 1677 | ......*. 1678 | 1679 | char 0x5d 1680 | ........ 1681 | .*****.. 1682 | .....*.. 1683 | .....*.. 1684 | .....*.. 1685 | .....*.. 1686 | .....*.. 1687 | .....*.. 1688 | .....*.. 1689 | .....*.. 1690 | .....*.. 1691 | .....*.. 1692 | .....*.. 1693 | .....*.. 1694 | .*****.. 1695 | ........ 1696 | 1697 | char 0x5e 1698 | ........ 1699 | ...*.... 1700 | ..*.*... 1701 | .*...*.. 1702 | *.....*. 1703 | ........ 1704 | ........ 1705 | ........ 1706 | ........ 1707 | ........ 1708 | ........ 1709 | ........ 1710 | ........ 1711 | ........ 1712 | ........ 1713 | ........ 1714 | 1715 | char 0x5f 1716 | ........ 1717 | ........ 1718 | ........ 1719 | ........ 1720 | ........ 1721 | ........ 1722 | ........ 1723 | ........ 1724 | ........ 1725 | ........ 1726 | ........ 1727 | ........ 1728 | ........ 1729 | ........ 1730 | *******. 1731 | ........ 1732 | 1733 | char 0x60 1734 | ...*.... 1735 | ....*... 1736 | .....*.. 1737 | ........ 1738 | ........ 1739 | ........ 1740 | ........ 1741 | ........ 1742 | ........ 1743 | ........ 1744 | ........ 1745 | ........ 1746 | ........ 1747 | ........ 1748 | ........ 1749 | ........ 1750 | 1751 | char 0x61 1752 | ........ 1753 | ........ 1754 | ........ 1755 | ........ 1756 | ........ 1757 | .***.... 1758 | ....*... 1759 | .....*.. 1760 | ..****.. 1761 | .*...*.. 1762 | *....*.. 1763 | *....*.. 1764 | *...**.. 1765 | .***.**. 1766 | ........ 1767 | ........ 1768 | 1769 | char 0x62 1770 | **...... 1771 | .*...... 1772 | .*...... 1773 | .*...... 1774 | .*...... 1775 | .*.**... 1776 | .**..*.. 1777 | .*....*. 1778 | .*....*. 1779 | .*....*. 1780 | .*....*. 1781 | .*....*. 1782 | .**..*.. 1783 | .*.**... 1784 | ........ 1785 | ........ 1786 | 1787 | char 0x63 1788 | ........ 1789 | ........ 1790 | ........ 1791 | ........ 1792 | ........ 1793 | ..**.... 1794 | .*..**.. 1795 | *....*.. 1796 | *....*.. 1797 | *....... 1798 | *....... 1799 | *.....*. 1800 | .*...*.. 1801 | ..***... 1802 | ........ 1803 | ........ 1804 | 1805 | char 0x64 1806 | ....**.. 1807 | .....*.. 1808 | .....*.. 1809 | .....*.. 1810 | .....*.. 1811 | ..**.*.. 1812 | .*..**.. 1813 | *....*.. 1814 | *....*.. 1815 | *....*.. 1816 | *....*.. 1817 | *....*.. 1818 | .*..**.. 1819 | ..**.**. 1820 | ........ 1821 | ........ 1822 | 1823 | char 0x65 1824 | ........ 1825 | ........ 1826 | ........ 1827 | ........ 1828 | ........ 1829 | ..***... 1830 | .*...*.. 1831 | *.....*. 1832 | *.....*. 1833 | ******.. 1834 | *....... 1835 | *.....*. 1836 | .*....*. 1837 | ..****.. 1838 | ........ 1839 | ........ 1840 | 1841 | char 0x66 1842 | ....***. 1843 | ...*.... 1844 | ...*.... 1845 | ...*.... 1846 | ...*.... 1847 | .*****.. 1848 | ...*.... 1849 | ...*.... 1850 | ...*.... 1851 | ...*.... 1852 | ...*.... 1853 | ...*.... 1854 | ...*.... 1855 | .*****.. 1856 | ........ 1857 | ........ 1858 | 1859 | char 0x67 1860 | ........ 1861 | ........ 1862 | ........ 1863 | ........ 1864 | ........ 1865 | ..**.**. 1866 | .*..**.. 1867 | *....*.. 1868 | *....*.. 1869 | *....*.. 1870 | *....*.. 1871 | .*..**.. 1872 | ..**.*.. 1873 | .....*.. 1874 | .....*.. 1875 | .****... 1876 | 1877 | char 0x68 1878 | **...... 1879 | .*...... 1880 | .*...... 1881 | .*...... 1882 | .*...... 1883 | .*.**... 1884 | .**..*.. 1885 | .*....*. 1886 | .*....*. 1887 | .*....*. 1888 | .*....*. 1889 | .*....*. 1890 | .*....*. 1891 | ***...** 1892 | ........ 1893 | ........ 1894 | 1895 | char 0x69 1896 | ........ 1897 | ...*.... 1898 | ...*.... 1899 | ........ 1900 | ........ 1901 | ..**.... 1902 | ...*.... 1903 | ...*.... 1904 | ...*.... 1905 | ...*.... 1906 | ...*.... 1907 | ...*.... 1908 | ...*.... 1909 | ..***... 1910 | ........ 1911 | ........ 1912 | 1913 | char 0x6a 1914 | ........ 1915 | .....*.. 1916 | .....*.. 1917 | ........ 1918 | ........ 1919 | ....**.. 1920 | .....*.. 1921 | .....*.. 1922 | .....*.. 1923 | .....*.. 1924 | .....*.. 1925 | .....*.. 1926 | .....*.. 1927 | ....*... 1928 | ....*... 1929 | ..**.... 1930 | 1931 | char 0x6b 1932 | **...... 1933 | .*...... 1934 | .*...... 1935 | .*...... 1936 | .*...... 1937 | .*..***. 1938 | .*...*.. 1939 | .*..*... 1940 | .*.*.... 1941 | .**..... 1942 | .*.*.... 1943 | .*..*... 1944 | .*...*.. 1945 | ***..**. 1946 | ........ 1947 | ........ 1948 | 1949 | char 0x6c 1950 | ..**.... 1951 | ...*.... 1952 | ...*.... 1953 | ...*.... 1954 | ...*.... 1955 | ...*.... 1956 | ...*.... 1957 | ...*.... 1958 | ...*.... 1959 | ...*.... 1960 | ...*.... 1961 | ...*.... 1962 | ...*.... 1963 | ..***... 1964 | ........ 1965 | ........ 1966 | 1967 | char 0x6d 1968 | ........ 1969 | ........ 1970 | ........ 1971 | ........ 1972 | ........ 1973 | ****.**. 1974 | .*..*..* 1975 | .*..*..* 1976 | .*..*..* 1977 | .*..*..* 1978 | .*..*..* 1979 | .*..*..* 1980 | .*..*..* 1981 | **.**.** 1982 | ........ 1983 | ........ 1984 | 1985 | char 0x6e 1986 | ........ 1987 | ........ 1988 | ........ 1989 | ........ 1990 | ........ 1991 | **.**... 1992 | .**..*.. 1993 | .*....*. 1994 | .*....*. 1995 | .*....*. 1996 | .*....*. 1997 | .*....*. 1998 | .*....*. 1999 | ***...** 2000 | ........ 2001 | ........ 2002 | 2003 | char 0x6f 2004 | ........ 2005 | ........ 2006 | ........ 2007 | ........ 2008 | ........ 2009 | ..***... 2010 | .*...*.. 2011 | *.....*. 2012 | *.....*. 2013 | *.....*. 2014 | *.....*. 2015 | *.....*. 2016 | .*...*.. 2017 | ..***... 2018 | ........ 2019 | ........ 2020 | 2021 | char 0x70 2022 | ........ 2023 | ........ 2024 | ........ 2025 | ........ 2026 | ........ 2027 | **.**... 2028 | .**..*.. 2029 | .*....*. 2030 | .*....*. 2031 | .*....*. 2032 | .*....*. 2033 | .*....*. 2034 | .**..*.. 2035 | .*.**... 2036 | .*...... 2037 | ***..... 2038 | 2039 | char 0x71 2040 | ........ 2041 | ........ 2042 | ........ 2043 | ........ 2044 | ........ 2045 | ..**.*.. 2046 | .*..**.. 2047 | *....*.. 2048 | *....*.. 2049 | *....*.. 2050 | *....*.. 2051 | *....*.. 2052 | .*..**.. 2053 | ..**.*.. 2054 | .....*.. 2055 | ....***. 2056 | 2057 | char 0x72 2058 | ........ 2059 | ........ 2060 | ........ 2061 | ........ 2062 | ........ 2063 | **.***.. 2064 | .**...*. 2065 | .*....*. 2066 | .*...... 2067 | .*...... 2068 | .*...... 2069 | .*...... 2070 | .*...... 2071 | ***..... 2072 | ........ 2073 | ........ 2074 | 2075 | char 0x73 2076 | ........ 2077 | ........ 2078 | ........ 2079 | ........ 2080 | ........ 2081 | .****.*. 2082 | *....**. 2083 | *.....*. 2084 | **...... 2085 | ..***... 2086 | .....**. 2087 | *.....*. 2088 | **....*. 2089 | *.****.. 2090 | ........ 2091 | ........ 2092 | 2093 | char 0x74 2094 | ........ 2095 | ........ 2096 | ...*.... 2097 | ...*.... 2098 | ...*.... 2099 | .*****.. 2100 | ...*.... 2101 | ...*.... 2102 | ...*.... 2103 | ...*.... 2104 | ...*.... 2105 | ...*.... 2106 | ...*.... 2107 | ....***. 2108 | ........ 2109 | ........ 2110 | 2111 | char 0x75 2112 | ........ 2113 | ........ 2114 | ........ 2115 | ........ 2116 | ........ 2117 | **...**. 2118 | .*....*. 2119 | .*....*. 2120 | .*....*. 2121 | .*....*. 2122 | .*....*. 2123 | .*....*. 2124 | .*...**. 2125 | ..***.** 2126 | ........ 2127 | ........ 2128 | 2129 | char 0x76 2130 | ........ 2131 | ........ 2132 | ........ 2133 | ........ 2134 | ........ 2135 | ***..*** 2136 | .*....*. 2137 | .*....*. 2138 | .*....*. 2139 | ..*..*.. 2140 | ..*..*.. 2141 | ..*..*.. 2142 | ...**... 2143 | ...**... 2144 | ........ 2145 | ........ 2146 | 2147 | char 0x77 2148 | ........ 2149 | ........ 2150 | ........ 2151 | ........ 2152 | ........ 2153 | ***..*** 2154 | .*....*. 2155 | .*....*. 2156 | .*.**.*. 2157 | .*.**.*. 2158 | .*.**.*. 2159 | ..*..*.. 2160 | ..*..*.. 2161 | ..*..*.. 2162 | ........ 2163 | ........ 2164 | 2165 | char 0x78 2166 | ........ 2167 | ........ 2168 | ........ 2169 | ........ 2170 | ........ 2171 | **...**. 2172 | .*...*.. 2173 | ..*.*... 2174 | ..*.*... 2175 | ...*.... 2176 | ..*.*... 2177 | ..*.*... 2178 | .*...*.. 2179 | **...**. 2180 | ........ 2181 | ........ 2182 | 2183 | char 0x79 2184 | ........ 2185 | ........ 2186 | ........ 2187 | ........ 2188 | ........ 2189 | ***..*** 2190 | .*....*. 2191 | .*....*. 2192 | ..*..*.. 2193 | ..*..*.. 2194 | ..*..*.. 2195 | ...**... 2196 | ...**... 2197 | ...*.... 2198 | ...*.... 2199 | .**..... 2200 | 2201 | char 0x7a 2202 | ........ 2203 | ........ 2204 | ........ 2205 | ........ 2206 | ........ 2207 | *******. 2208 | *.....*. 2209 | *....*.. 2210 | ....*... 2211 | ...*.... 2212 | ..*..... 2213 | .*....*. 2214 | *.....*. 2215 | *******. 2216 | ........ 2217 | ........ 2218 | 2219 | char 0x7b 2220 | ........ 2221 | .....**. 2222 | ....*... 2223 | ...*.... 2224 | ...*.... 2225 | ...*.... 2226 | ...*.... 2227 | .**..... 2228 | ...*.... 2229 | ...*.... 2230 | ...*.... 2231 | ...*.... 2232 | ....*... 2233 | .....**. 2234 | ........ 2235 | ........ 2236 | 2237 | char 0x7c 2238 | ...*.... 2239 | ...*.... 2240 | ...*.... 2241 | ...*.... 2242 | ...*.... 2243 | ...*.... 2244 | ...*.... 2245 | ...*.... 2246 | ...*.... 2247 | ...*.... 2248 | ...*.... 2249 | ...*.... 2250 | ...*.... 2251 | ...*.... 2252 | ...*.... 2253 | ...*.... 2254 | 2255 | char 0x7d 2256 | ........ 2257 | .**..... 2258 | ...*.... 2259 | ....*... 2260 | ....*... 2261 | ....*... 2262 | ....*... 2263 | .....**. 2264 | ....*... 2265 | ....*... 2266 | ....*... 2267 | ....*... 2268 | ...*.... 2269 | .**..... 2270 | ........ 2271 | ........ 2272 | 2273 | char 0x7e 2274 | ........ 2275 | .***..*. 2276 | *...**.. 2277 | ........ 2278 | ........ 2279 | ........ 2280 | ........ 2281 | ........ 2282 | ........ 2283 | ........ 2284 | ........ 2285 | ........ 2286 | ........ 2287 | ........ 2288 | ........ 2289 | ........ 2290 | 2291 | char 0x7f 2292 | ........ 2293 | ........ 2294 | ........ 2295 | ........ 2296 | ...*.... 2297 | ..*.*... 2298 | .*...*.. 2299 | *.....*. 2300 | *******. 2301 | *.....*. 2302 | *******. 2303 | ........ 2304 | ........ 2305 | ........ 2306 | ........ 2307 | ........ 2308 | 2309 | char 0x80 2310 | ........ 2311 | ..***... 2312 | .*...*.. 2313 | *.....*. 2314 | *....... 2315 | *....... 2316 | *....... 2317 | *....... 2318 | *....... 2319 | *....... 2320 | *....... 2321 | *.....*. 2322 | .*...*.. 2323 | ..***... 2324 | ...*.... 2325 | ..*..... 2326 | 2327 | char 0x81 2328 | ........ 2329 | ........ 2330 | ..*..*.. 2331 | ..*..*.. 2332 | ........ 2333 | *.....*. 2334 | *.....*. 2335 | *.....*. 2336 | *.....*. 2337 | *.....*. 2338 | *.....*. 2339 | *.....*. 2340 | .*....*. 2341 | ..*****. 2342 | ........ 2343 | ........ 2344 | 2345 | char 0x82 2346 | ....**.. 2347 | ....*... 2348 | ...*.... 2349 | ........ 2350 | ........ 2351 | ..***... 2352 | .*...*.. 2353 | *.....*. 2354 | *.....*. 2355 | *******. 2356 | *....... 2357 | *.....*. 2358 | .*...*.. 2359 | ..***... 2360 | ........ 2361 | ........ 2362 | 2363 | char 0x83 2364 | ........ 2365 | ...*.... 2366 | ..*.*... 2367 | .*...*.. 2368 | ........ 2369 | .****... 2370 | .....*.. 2371 | .....*.. 2372 | ..****.. 2373 | .*...*.. 2374 | *....*.. 2375 | *....*.. 2376 | .*...*.. 2377 | ..*****. 2378 | ........ 2379 | ........ 2380 | 2381 | char 0x84 2382 | ........ 2383 | ........ 2384 | ..*..*.. 2385 | ..*..*.. 2386 | ........ 2387 | .****... 2388 | .....*.. 2389 | .....*.. 2390 | ..****.. 2391 | .*...*.. 2392 | *....*.. 2393 | *....*.. 2394 | .*...*.. 2395 | ..*****. 2396 | ........ 2397 | ........ 2398 | 2399 | char 0x85 2400 | ...*.... 2401 | ....*... 2402 | .....*.. 2403 | ........ 2404 | ........ 2405 | .****... 2406 | .....*.. 2407 | .....*.. 2408 | ..****.. 2409 | .*...*.. 2410 | *....*.. 2411 | *....*.. 2412 | .*...*.. 2413 | ..*****. 2414 | ........ 2415 | ........ 2416 | 2417 | char 0x86 2418 | ........ 2419 | ...**... 2420 | ..*..*.. 2421 | ...**... 2422 | ........ 2423 | .****... 2424 | .....*.. 2425 | .....*.. 2426 | ..****.. 2427 | .*...*.. 2428 | *....*.. 2429 | *....*.. 2430 | .*...*.. 2431 | ..*****. 2432 | ........ 2433 | ........ 2434 | 2435 | char 0x87 2436 | ........ 2437 | ........ 2438 | ........ 2439 | ........ 2440 | ........ 2441 | ..****.. 2442 | .*....*. 2443 | *....... 2444 | *....... 2445 | *....... 2446 | *....... 2447 | *....... 2448 | .*....*. 2449 | ..****.. 2450 | ....*... 2451 | ...*.... 2452 | 2453 | char 0x88 2454 | ........ 2455 | ...*.... 2456 | ..*.*... 2457 | .*...*.. 2458 | ........ 2459 | ..***... 2460 | .*...*.. 2461 | *.....*. 2462 | *.....*. 2463 | *******. 2464 | *....... 2465 | *.....*. 2466 | .*...*.. 2467 | ..***... 2468 | ........ 2469 | ........ 2470 | 2471 | char 0x89 2472 | ........ 2473 | ........ 2474 | ..*..*.. 2475 | ..*..*.. 2476 | ........ 2477 | ..***... 2478 | .*...*.. 2479 | *.....*. 2480 | *.....*. 2481 | *******. 2482 | *....... 2483 | *.....*. 2484 | .*...*.. 2485 | ..***... 2486 | ........ 2487 | ........ 2488 | 2489 | char 0x8a 2490 | ...*.... 2491 | ....*... 2492 | .....*.. 2493 | ........ 2494 | ........ 2495 | ..***... 2496 | .*...*.. 2497 | *.....*. 2498 | *.....*. 2499 | *******. 2500 | *....... 2501 | *.....*. 2502 | .*...*.. 2503 | ..***... 2504 | ........ 2505 | ........ 2506 | 2507 | char 0x8b 2508 | ........ 2509 | ........ 2510 | ..*..*.. 2511 | ..*..*.. 2512 | ........ 2513 | ...*.... 2514 | ...*.... 2515 | ...*.... 2516 | ...*.... 2517 | ...*.... 2518 | ...*.... 2519 | ...*.... 2520 | ...*.... 2521 | ...*.... 2522 | ........ 2523 | ........ 2524 | 2525 | char 0x8c 2526 | ........ 2527 | ...*.... 2528 | ..*.*... 2529 | .*...*.. 2530 | ........ 2531 | ...*.... 2532 | ...*.... 2533 | ...*.... 2534 | ...*.... 2535 | ...*.... 2536 | ...*.... 2537 | ...*.... 2538 | ...*.... 2539 | ...*.... 2540 | ........ 2541 | ........ 2542 | 2543 | char 0x8d 2544 | ...*.... 2545 | ....*... 2546 | .....*.. 2547 | ........ 2548 | ........ 2549 | ...*.... 2550 | ...*.... 2551 | ...*.... 2552 | ...*.... 2553 | ...*.... 2554 | ...*.... 2555 | ...*.... 2556 | ...*.... 2557 | ...*.... 2558 | ........ 2559 | ........ 2560 | 2561 | char 0x8e 2562 | ..*..*.. 2563 | ..*..*.. 2564 | ........ 2565 | ..***... 2566 | .*...*.. 2567 | *.....*. 2568 | *.....*. 2569 | *.....*. 2570 | *.....*. 2571 | *******. 2572 | *.....*. 2573 | *.....*. 2574 | *.....*. 2575 | *.....*. 2576 | ........ 2577 | ........ 2578 | 2579 | char 0x8f 2580 | ........ 2581 | ..***... 2582 | .*...*.. 2583 | ..***... 2584 | .*...*.. 2585 | *.....*. 2586 | *.....*. 2587 | *.....*. 2588 | *.....*. 2589 | *******. 2590 | *.....*. 2591 | *.....*. 2592 | *.....*. 2593 | *.....*. 2594 | ........ 2595 | ........ 2596 | 2597 | char 0x90 2598 | ....**.. 2599 | ....*... 2600 | ...*.... 2601 | *******. 2602 | *....... 2603 | *....... 2604 | *....... 2605 | *....... 2606 | *****... 2607 | *....... 2608 | *....... 2609 | *....... 2610 | *....... 2611 | *******. 2612 | ........ 2613 | ........ 2614 | 2615 | char 0x91 2616 | ........ 2617 | ........ 2618 | ........ 2619 | ........ 2620 | ........ 2621 | .**..... 2622 | ...***.. 2623 | ...*..*. 2624 | .***..*. 2625 | *..****. 2626 | *..*.... 2627 | *..*.... 2628 | *..*..*. 2629 | .**.**.. 2630 | ........ 2631 | ........ 2632 | 2633 | char 0x92 2634 | ....**.. 2635 | ...*.... 2636 | ..*..... 2637 | ..*.*... 2638 | ..*.*... 2639 | ..*.*... 2640 | *******. 2641 | ..*.*... 2642 | ..*.*... 2643 | ..*.*... 2644 | ..*.*... 2645 | ..*.*... 2646 | ..*.*... 2647 | ..*.*... 2648 | ........ 2649 | ........ 2650 | 2651 | char 0x93 2652 | ........ 2653 | ...*.... 2654 | ..*.*... 2655 | .*...*.. 2656 | ........ 2657 | ..***... 2658 | .*...*.. 2659 | *.....*. 2660 | *.....*. 2661 | *.....*. 2662 | *.....*. 2663 | *.....*. 2664 | .*...*.. 2665 | ..***... 2666 | ........ 2667 | ........ 2668 | 2669 | char 0x94 2670 | ........ 2671 | ........ 2672 | ..*..*.. 2673 | ..*..*.. 2674 | ........ 2675 | ..***... 2676 | .*...*.. 2677 | *.....*. 2678 | *.....*. 2679 | *.....*. 2680 | *.....*. 2681 | *.....*. 2682 | .*...*.. 2683 | ..***... 2684 | ........ 2685 | ........ 2686 | 2687 | char 0x95 2688 | ...*.... 2689 | ....*... 2690 | .....*.. 2691 | ........ 2692 | ........ 2693 | ..***... 2694 | .*...*.. 2695 | *.....*. 2696 | *.....*. 2697 | *.....*. 2698 | *.....*. 2699 | *.....*. 2700 | .*...*.. 2701 | ..***... 2702 | ........ 2703 | ........ 2704 | 2705 | char 0x96 2706 | ........ 2707 | ...*.... 2708 | ..*.*... 2709 | .*...*.. 2710 | ........ 2711 | *.....*. 2712 | *.....*. 2713 | *.....*. 2714 | *.....*. 2715 | *.....*. 2716 | *.....*. 2717 | *.....*. 2718 | .*....*. 2719 | ..*****. 2720 | ........ 2721 | ........ 2722 | 2723 | char 0x97 2724 | ...*.... 2725 | ....*... 2726 | .....*.. 2727 | ........ 2728 | ........ 2729 | *.....*. 2730 | *.....*. 2731 | *.....*. 2732 | *.....*. 2733 | *.....*. 2734 | *.....*. 2735 | *.....*. 2736 | .*....*. 2737 | ..*****. 2738 | ........ 2739 | ........ 2740 | 2741 | char 0x98 2742 | ........ 2743 | ........ 2744 | ..*..*.. 2745 | ..*..*.. 2746 | ........ 2747 | *.....*. 2748 | *.....*. 2749 | .*...*.. 2750 | .*...*.. 2751 | ..*.*... 2752 | ..*.*... 2753 | ...*.... 2754 | ...*.... 2755 | ..*..... 2756 | ..*..... 2757 | .*...... 2758 | 2759 | char 0x99 2760 | ..*..*.. 2761 | ..*..*.. 2762 | ........ 2763 | ..***... 2764 | .*...*.. 2765 | *.....*. 2766 | *.....*. 2767 | *.....*. 2768 | *.....*. 2769 | *.....*. 2770 | *.....*. 2771 | *.....*. 2772 | .*...*.. 2773 | ..***... 2774 | ........ 2775 | ........ 2776 | 2777 | char 0x9a 2778 | ..*..*.. 2779 | ..*..*.. 2780 | ........ 2781 | *.....*. 2782 | *.....*. 2783 | *.....*. 2784 | *.....*. 2785 | *.....*. 2786 | *.....*. 2787 | *.....*. 2788 | *.....*. 2789 | *.....*. 2790 | .*...*.. 2791 | ..***... 2792 | ........ 2793 | ........ 2794 | 2795 | char 0x9b 2796 | ........ 2797 | ..*.*... 2798 | ..*.*... 2799 | ..*.*... 2800 | ..****.. 2801 | .**.*.*. 2802 | *.*.*... 2803 | *.*.*... 2804 | *.*.*... 2805 | *.*.*... 2806 | *.*.*... 2807 | .**.*.*. 2808 | ..****.. 2809 | ..*.*... 2810 | ..*.*... 2811 | ..*.*... 2812 | 2813 | char 0x9c 2814 | ........ 2815 | ....**.. 2816 | ...*..*. 2817 | ..*..... 2818 | ..*..... 2819 | ..*..... 2820 | ******.. 2821 | ..*..... 2822 | ..*..... 2823 | ..*..... 2824 | .**..... 2825 | *.*..... 2826 | *.**..*. 2827 | .*..**.. 2828 | ........ 2829 | ........ 2830 | 2831 | char 0x9d 2832 | ........ 2833 | *.....*. 2834 | *.....*. 2835 | .*...*.. 2836 | ..*.*... 2837 | ...*.... 2838 | *******. 2839 | ...*.... 2840 | ...*.... 2841 | *******. 2842 | ...*.... 2843 | ...*.... 2844 | ...*.... 2845 | ...*.... 2846 | ........ 2847 | ........ 2848 | 2849 | char 0x9e 2850 | ........ 2851 | ***..... 2852 | *..*.... 2853 | *...*... 2854 | *...*... 2855 | *...*... 2856 | *..*.*.. 2857 | ***..*.. 2858 | *..***** 2859 | *....*.. 2860 | *....*.. 2861 | *....*.. 2862 | *....*.. 2863 | *....*.. 2864 | ........ 2865 | ........ 2866 | 2867 | char 0x9f 2868 | ........ 2869 | ....**.. 2870 | ...*..*. 2871 | ...*.... 2872 | ...*.... 2873 | ...*.... 2874 | *******. 2875 | ...*.... 2876 | ...*.... 2877 | ...*.... 2878 | ...*.... 2879 | ...*.... 2880 | *..*.... 2881 | .**..... 2882 | ........ 2883 | ........ 2884 | 2885 | char 0xa0 2886 | ....**.. 2887 | ....*... 2888 | ...*.... 2889 | ........ 2890 | ........ 2891 | .****... 2892 | .....*.. 2893 | .....*.. 2894 | ..****.. 2895 | .*...*.. 2896 | *....*.. 2897 | *....*.. 2898 | .*...*.. 2899 | ..*****. 2900 | ........ 2901 | ........ 2902 | 2903 | char 0xa1 2904 | ....**.. 2905 | ....*... 2906 | ...*.... 2907 | ........ 2908 | ........ 2909 | ...*.... 2910 | ...*.... 2911 | ...*.... 2912 | ...*.... 2913 | ...*.... 2914 | ...*.... 2915 | ...*.... 2916 | ...*.... 2917 | ...*.... 2918 | ........ 2919 | ........ 2920 | 2921 | char 0xa2 2922 | ....**.. 2923 | ....*... 2924 | ...*.... 2925 | ........ 2926 | ........ 2927 | ..***... 2928 | .*...*.. 2929 | *.....*. 2930 | *.....*. 2931 | *.....*. 2932 | *.....*. 2933 | *.....*. 2934 | .*...*.. 2935 | ..***... 2936 | ........ 2937 | ........ 2938 | 2939 | char 0xa3 2940 | ....**.. 2941 | ....*... 2942 | ...*.... 2943 | ........ 2944 | ........ 2945 | *.....*. 2946 | *.....*. 2947 | *.....*. 2948 | *.....*. 2949 | *.....*. 2950 | *.....*. 2951 | *.....*. 2952 | .*....*. 2953 | ..*****. 2954 | ........ 2955 | ........ 2956 | 2957 | char 0xa4 2958 | ........ 2959 | ...*..*. 2960 | ..*.*.*. 2961 | ..*..*.. 2962 | ........ 2963 | *****... 2964 | *....*.. 2965 | *.....*. 2966 | *.....*. 2967 | *.....*. 2968 | *.....*. 2969 | *.....*. 2970 | *.....*. 2971 | *.....*. 2972 | ........ 2973 | ........ 2974 | 2975 | char 0xa5 2976 | ...*..*. 2977 | ..*.*.*. 2978 | ..*..*.. 2979 | ........ 2980 | *.....*. 2981 | **....*. 2982 | **....*. 2983 | *.*...*. 2984 | *..*..*. 2985 | *..*..*. 2986 | *...*.*. 2987 | *....**. 2988 | *....**. 2989 | *.....*. 2990 | ........ 2991 | ........ 2992 | 2993 | char 0xa6 2994 | ........ 2995 | ........ 2996 | ........ 2997 | .****... 2998 | .....*.. 2999 | .....*.. 3000 | ..****.. 3001 | .*...*.. 3002 | *....*.. 3003 | *....*.. 3004 | .*...*.. 3005 | ..*****. 3006 | ........ 3007 | *******. 3008 | ........ 3009 | ........ 3010 | 3011 | char 0xa7 3012 | ........ 3013 | ........ 3014 | ........ 3015 | ..***... 3016 | .*...*.. 3017 | *.....*. 3018 | *.....*. 3019 | *.....*. 3020 | *.....*. 3021 | *.....*. 3022 | .*...*.. 3023 | ..***... 3024 | ........ 3025 | *******. 3026 | ........ 3027 | ........ 3028 | 3029 | char 0xa8 3030 | ........ 3031 | ...*.... 3032 | ...*.... 3033 | ........ 3034 | ........ 3035 | ...*.... 3036 | ...*.... 3037 | ..*..... 3038 | .*...*.. 3039 | *.....*. 3040 | *.....*. 3041 | *.....*. 3042 | .*...*.. 3043 | ..***... 3044 | ........ 3045 | ........ 3046 | 3047 | char 0xa9 3048 | ........ 3049 | ........ 3050 | ........ 3051 | ........ 3052 | ........ 3053 | ........ 3054 | ........ 3055 | ........ 3056 | ........ 3057 | ........ 3058 | *******. 3059 | *....... 3060 | *....... 3061 | *....... 3062 | ........ 3063 | ........ 3064 | 3065 | char 0xaa 3066 | ........ 3067 | ........ 3068 | ........ 3069 | ........ 3070 | ........ 3071 | ........ 3072 | ........ 3073 | ........ 3074 | ........ 3075 | ........ 3076 | *******. 3077 | ......*. 3078 | ......*. 3079 | ......*. 3080 | ........ 3081 | ........ 3082 | 3083 | char 0xab 3084 | ........ 3085 | ...*.... 3086 | ..**.... 3087 | ...*.... 3088 | ...*.... 3089 | ...*.... 3090 | ........ 3091 | *******. 3092 | ........ 3093 | .****... 3094 | .....*.. 3095 | ..***... 3096 | .*...... 3097 | .*****.. 3098 | ........ 3099 | ........ 3100 | 3101 | char 0xac 3102 | ........ 3103 | ...*.... 3104 | ..**.... 3105 | ...*.... 3106 | ...*.... 3107 | ...*.... 3108 | ........ 3109 | *******. 3110 | ........ 3111 | ...**... 3112 | ..*.*... 3113 | .*..*... 3114 | .*****.. 3115 | ....*... 3116 | ........ 3117 | ........ 3118 | 3119 | char 0xad 3120 | ........ 3121 | ...*.... 3122 | ...*.... 3123 | ........ 3124 | ........ 3125 | ...*.... 3126 | ...*.... 3127 | ...*.... 3128 | ...*.... 3129 | ...*.... 3130 | ...*.... 3131 | ...*.... 3132 | ...*.... 3133 | ...*.... 3134 | ........ 3135 | ........ 3136 | 3137 | char 0xae 3138 | ........ 3139 | ........ 3140 | ........ 3141 | ........ 3142 | ...*..*. 3143 | ..*..*.. 3144 | .*..*... 3145 | *..*.... 3146 | *..*.... 3147 | .*..*... 3148 | ..*..*.. 3149 | ...*..*. 3150 | ........ 3151 | ........ 3152 | ........ 3153 | ........ 3154 | 3155 | char 0xaf 3156 | ........ 3157 | ........ 3158 | ........ 3159 | ........ 3160 | *..*.... 3161 | .*..*... 3162 | ..*..*.. 3163 | ...*..*. 3164 | ...*..*. 3165 | ..*..*.. 3166 | .*..*... 3167 | *..*.... 3168 | ........ 3169 | ........ 3170 | ........ 3171 | ........ 3172 | 3173 | char 0xb0 3174 | ...*...* 3175 | .*...*.. 3176 | ...*...* 3177 | .*...*.. 3178 | ...*...* 3179 | .*...*.. 3180 | ...*...* 3181 | .*...*.. 3182 | ...*...* 3183 | .*...*.. 3184 | ...*...* 3185 | .*...*.. 3186 | ...*...* 3187 | .*...*.. 3188 | ...*...* 3189 | .*...*.. 3190 | 3191 | char 0xb1 3192 | .*.*.*.* 3193 | *.*.*.*. 3194 | .*.*.*.* 3195 | *.*.*.*. 3196 | .*.*.*.* 3197 | *.*.*.*. 3198 | .*.*.*.* 3199 | *.*.*.*. 3200 | .*.*.*.* 3201 | *.*.*.*. 3202 | .*.*.*.* 3203 | *.*.*.*. 3204 | .*.*.*.* 3205 | *.*.*.*. 3206 | .*.*.*.* 3207 | *.*.*.*. 3208 | 3209 | char 0xb2 3210 | .***.*** 3211 | **.***.* 3212 | .***.*** 3213 | **.***.* 3214 | .***.*** 3215 | **.***.* 3216 | .***.*** 3217 | **.***.* 3218 | .***.*** 3219 | **.***.* 3220 | .***.*** 3221 | **.***.* 3222 | .***.*** 3223 | **.***.* 3224 | .***.*** 3225 | **.***.* 3226 | 3227 | char 0xb3 3228 | ...*.... 3229 | ...*.... 3230 | ...*.... 3231 | ...*.... 3232 | ...*.... 3233 | ...*.... 3234 | ...*.... 3235 | ...*.... 3236 | ...*.... 3237 | ...*.... 3238 | ...*.... 3239 | ...*.... 3240 | ...*.... 3241 | ...*.... 3242 | ...*.... 3243 | ...*.... 3244 | 3245 | char 0xb4 3246 | ...*.... 3247 | ...*.... 3248 | ...*.... 3249 | ...*.... 3250 | ...*.... 3251 | ...*.... 3252 | ...*.... 3253 | ****.... 3254 | ...*.... 3255 | ...*.... 3256 | ...*.... 3257 | ...*.... 3258 | ...*.... 3259 | ...*.... 3260 | ...*.... 3261 | ...*.... 3262 | 3263 | char 0xb5 3264 | ...*.... 3265 | ...*.... 3266 | ...*.... 3267 | ...*.... 3268 | ...*.... 3269 | ...*.... 3270 | ...*.... 3271 | ****.... 3272 | ...*.... 3273 | ****.... 3274 | ...*.... 3275 | ...*.... 3276 | ...*.... 3277 | ...*.... 3278 | ...*.... 3279 | ...*.... 3280 | 3281 | char 0xb6 3282 | ...*.*.. 3283 | ...*.*.. 3284 | ...*.*.. 3285 | ...*.*.. 3286 | ...*.*.. 3287 | ...*.*.. 3288 | ...*.*.. 3289 | ****.*.. 3290 | ...*.*.. 3291 | ...*.*.. 3292 | ...*.*.. 3293 | ...*.*.. 3294 | ...*.*.. 3295 | ...*.*.. 3296 | ...*.*.. 3297 | ...*.*.. 3298 | 3299 | char 0xb7 3300 | ........ 3301 | ........ 3302 | ........ 3303 | ........ 3304 | ........ 3305 | ........ 3306 | ........ 3307 | ******.. 3308 | ...*.*.. 3309 | ...*.*.. 3310 | ...*.*.. 3311 | ...*.*.. 3312 | ...*.*.. 3313 | ...*.*.. 3314 | ...*.*.. 3315 | ...*.*.. 3316 | 3317 | char 0xb8 3318 | ........ 3319 | ........ 3320 | ........ 3321 | ........ 3322 | ........ 3323 | ........ 3324 | ........ 3325 | ****.... 3326 | ...*.... 3327 | ****.... 3328 | ...*.... 3329 | ...*.... 3330 | ...*.... 3331 | ...*.... 3332 | ...*.... 3333 | ...*.... 3334 | 3335 | char 0xb9 3336 | ...*.*.. 3337 | ...*.*.. 3338 | ...*.*.. 3339 | ...*.*.. 3340 | ...*.*.. 3341 | ...*.*.. 3342 | ...*.*.. 3343 | ****.*.. 3344 | .....*.. 3345 | ****.*.. 3346 | ...*.*.. 3347 | ...*.*.. 3348 | ...*.*.. 3349 | ...*.*.. 3350 | ...*.*.. 3351 | ...*.*.. 3352 | 3353 | char 0xba 3354 | ...*.*.. 3355 | ...*.*.. 3356 | ...*.*.. 3357 | ...*.*.. 3358 | ...*.*.. 3359 | ...*.*.. 3360 | ...*.*.. 3361 | ...*.*.. 3362 | ...*.*.. 3363 | ...*.*.. 3364 | ...*.*.. 3365 | ...*.*.. 3366 | ...*.*.. 3367 | ...*.*.. 3368 | ...*.*.. 3369 | ...*.*.. 3370 | 3371 | char 0xbb 3372 | ........ 3373 | ........ 3374 | ........ 3375 | ........ 3376 | ........ 3377 | ........ 3378 | ........ 3379 | ******.. 3380 | .....*.. 3381 | ****.*.. 3382 | ...*.*.. 3383 | ...*.*.. 3384 | ...*.*.. 3385 | ...*.*.. 3386 | ...*.*.. 3387 | ...*.*.. 3388 | 3389 | char 0xbc 3390 | ...*.*.. 3391 | ...*.*.. 3392 | ...*.*.. 3393 | ...*.*.. 3394 | ...*.*.. 3395 | ...*.*.. 3396 | ...*.*.. 3397 | ****.*.. 3398 | .....*.. 3399 | ******.. 3400 | ........ 3401 | ........ 3402 | ........ 3403 | ........ 3404 | ........ 3405 | ........ 3406 | 3407 | char 0xbd 3408 | ...*.*.. 3409 | ...*.*.. 3410 | ...*.*.. 3411 | ...*.*.. 3412 | ...*.*.. 3413 | ...*.*.. 3414 | ...*.*.. 3415 | ******.. 3416 | ........ 3417 | ........ 3418 | ........ 3419 | ........ 3420 | ........ 3421 | ........ 3422 | ........ 3423 | ........ 3424 | 3425 | char 0xbe 3426 | ...*.... 3427 | ...*.... 3428 | ...*.... 3429 | ...*.... 3430 | ...*.... 3431 | ...*.... 3432 | ...*.... 3433 | ****.... 3434 | ...*.... 3435 | ****.... 3436 | ........ 3437 | ........ 3438 | ........ 3439 | ........ 3440 | ........ 3441 | ........ 3442 | 3443 | char 0xbf 3444 | ........ 3445 | ........ 3446 | ........ 3447 | ........ 3448 | ........ 3449 | ........ 3450 | ........ 3451 | ****.... 3452 | ...*.... 3453 | ...*.... 3454 | ...*.... 3455 | ...*.... 3456 | ...*.... 3457 | ...*.... 3458 | ...*.... 3459 | ...*.... 3460 | 3461 | char 0xc0 3462 | ...*.... 3463 | ...*.... 3464 | ...*.... 3465 | ...*.... 3466 | ...*.... 3467 | ...*.... 3468 | ...*.... 3469 | ...***** 3470 | ........ 3471 | ........ 3472 | ........ 3473 | ........ 3474 | ........ 3475 | ........ 3476 | ........ 3477 | ........ 3478 | 3479 | char 0xc1 3480 | ...*.... 3481 | ...*.... 3482 | ...*.... 3483 | ...*.... 3484 | ...*.... 3485 | ...*.... 3486 | ...*.... 3487 | ******** 3488 | ........ 3489 | ........ 3490 | ........ 3491 | ........ 3492 | ........ 3493 | ........ 3494 | ........ 3495 | ........ 3496 | 3497 | char 0xc2 3498 | ........ 3499 | ........ 3500 | ........ 3501 | ........ 3502 | ........ 3503 | ........ 3504 | ........ 3505 | ******** 3506 | ...*.... 3507 | ...*.... 3508 | ...*.... 3509 | ...*.... 3510 | ...*.... 3511 | ...*.... 3512 | ...*.... 3513 | ...*.... 3514 | 3515 | char 0xc3 3516 | ...*.... 3517 | ...*.... 3518 | ...*.... 3519 | ...*.... 3520 | ...*.... 3521 | ...*.... 3522 | ...*.... 3523 | ...***** 3524 | ...*.... 3525 | ...*.... 3526 | ...*.... 3527 | ...*.... 3528 | ...*.... 3529 | ...*.... 3530 | ...*.... 3531 | ...*.... 3532 | 3533 | char 0xc4 3534 | ........ 3535 | ........ 3536 | ........ 3537 | ........ 3538 | ........ 3539 | ........ 3540 | ........ 3541 | ******** 3542 | ........ 3543 | ........ 3544 | ........ 3545 | ........ 3546 | ........ 3547 | ........ 3548 | ........ 3549 | ........ 3550 | 3551 | char 0xc5 3552 | ...*.... 3553 | ...*.... 3554 | ...*.... 3555 | ...*.... 3556 | ...*.... 3557 | ...*.... 3558 | ...*.... 3559 | ******** 3560 | ...*.... 3561 | ...*.... 3562 | ...*.... 3563 | ...*.... 3564 | ...*.... 3565 | ...*.... 3566 | ...*.... 3567 | ...*.... 3568 | 3569 | char 0xc6 3570 | ...*.... 3571 | ...*.... 3572 | ...*.... 3573 | ...*.... 3574 | ...*.... 3575 | ...*.... 3576 | ...*.... 3577 | ...***** 3578 | ...*.... 3579 | ...***** 3580 | ...*.... 3581 | ...*.... 3582 | ...*.... 3583 | ...*.... 3584 | ...*.... 3585 | ...*.... 3586 | 3587 | char 0xc7 3588 | ...*.*.. 3589 | ...*.*.. 3590 | ...*.*.. 3591 | ...*.*.. 3592 | ...*.*.. 3593 | ...*.*.. 3594 | ...*.*.. 3595 | ...*.*** 3596 | ...*.*.. 3597 | ...*.*.. 3598 | ...*.*.. 3599 | ...*.*.. 3600 | ...*.*.. 3601 | ...*.*.. 3602 | ...*.*.. 3603 | ...*.*.. 3604 | 3605 | char 0xc8 3606 | ...*.*.. 3607 | ...*.*.. 3608 | ...*.*.. 3609 | ...*.*.. 3610 | ...*.*.. 3611 | ...*.*.. 3612 | ...*.*.. 3613 | ...*.*** 3614 | ...*.... 3615 | ...***** 3616 | ........ 3617 | ........ 3618 | ........ 3619 | ........ 3620 | ........ 3621 | ........ 3622 | 3623 | char 0xc9 3624 | ........ 3625 | ........ 3626 | ........ 3627 | ........ 3628 | ........ 3629 | ........ 3630 | ........ 3631 | ...***** 3632 | ...*.... 3633 | ...*.*** 3634 | ...*.*.. 3635 | ...*.*.. 3636 | ...*.*.. 3637 | ...*.*.. 3638 | ...*.*.. 3639 | ...*.*.. 3640 | 3641 | char 0xca 3642 | ...*.*.. 3643 | ...*.*.. 3644 | ...*.*.. 3645 | ...*.*.. 3646 | ...*.*.. 3647 | ...*.*.. 3648 | ...*.*.. 3649 | ****.*** 3650 | ........ 3651 | ******** 3652 | ........ 3653 | ........ 3654 | ........ 3655 | ........ 3656 | ........ 3657 | ........ 3658 | 3659 | char 0xcb 3660 | ........ 3661 | ........ 3662 | ........ 3663 | ........ 3664 | ........ 3665 | ........ 3666 | ........ 3667 | ******** 3668 | ........ 3669 | ****.*** 3670 | ...*.*.. 3671 | ...*.*.. 3672 | ...*.*.. 3673 | ...*.*.. 3674 | ...*.*.. 3675 | ...*.*.. 3676 | 3677 | char 0xcc 3678 | ...*.*.. 3679 | ...*.*.. 3680 | ...*.*.. 3681 | ...*.*.. 3682 | ...*.*.. 3683 | ...*.*.. 3684 | ...*.*.. 3685 | ...*.*** 3686 | ...*.... 3687 | ...*.*** 3688 | ...*.*.. 3689 | ...*.*.. 3690 | ...*.*.. 3691 | ...*.*.. 3692 | ...*.*.. 3693 | ...*.*.. 3694 | 3695 | char 0xcd 3696 | ........ 3697 | ........ 3698 | ........ 3699 | ........ 3700 | ........ 3701 | ........ 3702 | ........ 3703 | ******** 3704 | ........ 3705 | ******** 3706 | ........ 3707 | ........ 3708 | ........ 3709 | ........ 3710 | ........ 3711 | ........ 3712 | 3713 | char 0xce 3714 | ...*.*.. 3715 | ...*.*.. 3716 | ...*.*.. 3717 | ...*.*.. 3718 | ...*.*.. 3719 | ...*.*.. 3720 | ...*.*.. 3721 | ****.*** 3722 | ........ 3723 | ****.*** 3724 | ...*.*.. 3725 | ...*.*.. 3726 | ...*.*.. 3727 | ...*.*.. 3728 | ...*.*.. 3729 | ...*.*.. 3730 | 3731 | char 0xcf 3732 | ...*.... 3733 | ...*.... 3734 | ...*.... 3735 | ...*.... 3736 | ...*.... 3737 | ...*.... 3738 | ...*.... 3739 | ******** 3740 | ........ 3741 | ******** 3742 | ........ 3743 | ........ 3744 | ........ 3745 | ........ 3746 | ........ 3747 | ........ 3748 | 3749 | char 0xd0 3750 | ...*.*.. 3751 | ...*.*.. 3752 | ...*.*.. 3753 | ...*.*.. 3754 | ...*.*.. 3755 | ...*.*.. 3756 | ...*.*.. 3757 | ******** 3758 | ........ 3759 | ........ 3760 | ........ 3761 | ........ 3762 | ........ 3763 | ........ 3764 | ........ 3765 | ........ 3766 | 3767 | char 0xd1 3768 | ........ 3769 | ........ 3770 | ........ 3771 | ........ 3772 | ........ 3773 | ........ 3774 | ........ 3775 | ******** 3776 | ........ 3777 | ******** 3778 | ...*.... 3779 | ...*.... 3780 | ...*.... 3781 | ...*.... 3782 | ...*.... 3783 | ...*.... 3784 | 3785 | char 0xd2 3786 | ........ 3787 | ........ 3788 | ........ 3789 | ........ 3790 | ........ 3791 | ........ 3792 | ........ 3793 | ******** 3794 | ...*.*.. 3795 | ...*.*.. 3796 | ...*.*.. 3797 | ...*.*.. 3798 | ...*.*.. 3799 | ...*.*.. 3800 | ...*.*.. 3801 | ...*.*.. 3802 | 3803 | char 0xd3 3804 | ...*.*.. 3805 | ...*.*.. 3806 | ...*.*.. 3807 | ...*.*.. 3808 | ...*.*.. 3809 | ...*.*.. 3810 | ...*.*.. 3811 | ...***** 3812 | ........ 3813 | ........ 3814 | ........ 3815 | ........ 3816 | ........ 3817 | ........ 3818 | ........ 3819 | ........ 3820 | 3821 | char 0xd4 3822 | ...*.... 3823 | ...*.... 3824 | ...*.... 3825 | ...*.... 3826 | ...*.... 3827 | ...*.... 3828 | ...*.... 3829 | ...***** 3830 | ...*.... 3831 | ...***** 3832 | ........ 3833 | ........ 3834 | ........ 3835 | ........ 3836 | ........ 3837 | ........ 3838 | 3839 | char 0xd5 3840 | ........ 3841 | ........ 3842 | ........ 3843 | ........ 3844 | ........ 3845 | ........ 3846 | ........ 3847 | ...***** 3848 | ...*.... 3849 | ...***** 3850 | ...*.... 3851 | ...*.... 3852 | ...*.... 3853 | ...*.... 3854 | ...*.... 3855 | ...*.... 3856 | 3857 | char 0xd6 3858 | ........ 3859 | ........ 3860 | ........ 3861 | ........ 3862 | ........ 3863 | ........ 3864 | ........ 3865 | ...***** 3866 | ...*.*.. 3867 | ...*.*.. 3868 | ...*.*.. 3869 | ...*.*.. 3870 | ...*.*.. 3871 | ...*.*.. 3872 | ...*.*.. 3873 | ...*.*.. 3874 | 3875 | char 0xd7 3876 | ...*.*.. 3877 | ...*.*.. 3878 | ...*.*.. 3879 | ...*.*.. 3880 | ...*.*.. 3881 | ...*.*.. 3882 | ...*.*.. 3883 | ****.*** 3884 | ...*.*.. 3885 | ...*.*.. 3886 | ...*.*.. 3887 | ...*.*.. 3888 | ...*.*.. 3889 | ...*.*.. 3890 | ...*.*.. 3891 | ...*.*.. 3892 | 3893 | char 0xd8 3894 | ...*.... 3895 | ...*.... 3896 | ...*.... 3897 | ...*.... 3898 | ...*.... 3899 | ...*.... 3900 | ...*.... 3901 | ******** 3902 | ...*.... 3903 | ******** 3904 | ...*.... 3905 | ...*.... 3906 | ...*.... 3907 | ...*.... 3908 | ...*.... 3909 | ...*.... 3910 | 3911 | char 0xd9 3912 | ...*.... 3913 | ...*.... 3914 | ...*.... 3915 | ...*.... 3916 | ...*.... 3917 | ...*.... 3918 | ...*.... 3919 | ****.... 3920 | ........ 3921 | ........ 3922 | ........ 3923 | ........ 3924 | ........ 3925 | ........ 3926 | ........ 3927 | ........ 3928 | 3929 | char 0xda 3930 | ........ 3931 | ........ 3932 | ........ 3933 | ........ 3934 | ........ 3935 | ........ 3936 | ........ 3937 | ...***** 3938 | ...*.... 3939 | ...*.... 3940 | ...*.... 3941 | ...*.... 3942 | ...*.... 3943 | ...*.... 3944 | ...*.... 3945 | ...*.... 3946 | 3947 | char 0xdb 3948 | ******** 3949 | ******** 3950 | ******** 3951 | ******** 3952 | ******** 3953 | ******** 3954 | ******** 3955 | ******** 3956 | ******** 3957 | ******** 3958 | ******** 3959 | ******** 3960 | ******** 3961 | ******** 3962 | ******** 3963 | ******** 3964 | 3965 | char 0xdc 3966 | ........ 3967 | ........ 3968 | ........ 3969 | ........ 3970 | ........ 3971 | ........ 3972 | ........ 3973 | ........ 3974 | ******** 3975 | ******** 3976 | ******** 3977 | ******** 3978 | ******** 3979 | ******** 3980 | ******** 3981 | ******** 3982 | 3983 | char 0xdd 3984 | ****.... 3985 | ****.... 3986 | ****.... 3987 | ****.... 3988 | ****.... 3989 | ****.... 3990 | ****.... 3991 | ****.... 3992 | ****.... 3993 | ****.... 3994 | ****.... 3995 | ****.... 3996 | ****.... 3997 | ****.... 3998 | ****.... 3999 | ****.... 4000 | 4001 | char 0xde 4002 | ....**** 4003 | ....**** 4004 | ....**** 4005 | ....**** 4006 | ....**** 4007 | ....**** 4008 | ....**** 4009 | ....**** 4010 | ....**** 4011 | ....**** 4012 | ....**** 4013 | ....**** 4014 | ....**** 4015 | ....**** 4016 | ....**** 4017 | ....**** 4018 | 4019 | char 0xdf 4020 | ******** 4021 | ******** 4022 | ******** 4023 | ******** 4024 | ******** 4025 | ******** 4026 | ******** 4027 | ******** 4028 | ........ 4029 | ........ 4030 | ........ 4031 | ........ 4032 | ........ 4033 | ........ 4034 | ........ 4035 | ........ 4036 | 4037 | char 0xe0 4038 | ........ 4039 | ........ 4040 | ........ 4041 | ........ 4042 | ........ 4043 | ........ 4044 | ........ 4045 | ........ 4046 | ........ 4047 | ........ 4048 | ........ 4049 | ........ 4050 | ........ 4051 | ........ 4052 | ........ 4053 | ........ 4054 | 4055 | char 0xe1 4056 | ........ 4057 | ........ 4058 | ........ 4059 | ........ 4060 | ........ 4061 | ........ 4062 | ........ 4063 | ........ 4064 | ........ 4065 | ........ 4066 | ........ 4067 | ........ 4068 | ........ 4069 | ........ 4070 | ........ 4071 | ........ 4072 | 4073 | char 0xe2 4074 | ........ 4075 | ........ 4076 | ........ 4077 | ........ 4078 | ........ 4079 | ........ 4080 | ........ 4081 | ........ 4082 | ........ 4083 | ........ 4084 | ........ 4085 | ........ 4086 | ........ 4087 | ........ 4088 | ........ 4089 | ........ 4090 | 4091 | char 0xe3 4092 | ........ 4093 | ........ 4094 | ........ 4095 | ........ 4096 | ........ 4097 | ........ 4098 | ........ 4099 | ........ 4100 | ........ 4101 | ........ 4102 | ........ 4103 | ........ 4104 | ........ 4105 | ........ 4106 | ........ 4107 | ........ 4108 | 4109 | char 0xe4 4110 | ........ 4111 | ........ 4112 | ........ 4113 | ........ 4114 | ........ 4115 | ........ 4116 | ........ 4117 | ........ 4118 | ........ 4119 | ........ 4120 | ........ 4121 | ........ 4122 | ........ 4123 | ........ 4124 | ........ 4125 | ........ 4126 | 4127 | char 0xe5 4128 | ........ 4129 | ........ 4130 | ........ 4131 | ........ 4132 | ........ 4133 | ........ 4134 | ........ 4135 | ........ 4136 | ........ 4137 | ........ 4138 | ........ 4139 | ........ 4140 | ........ 4141 | ........ 4142 | ........ 4143 | ........ 4144 | 4145 | char 0xe6 4146 | ........ 4147 | ........ 4148 | ........ 4149 | ........ 4150 | ........ 4151 | ........ 4152 | ........ 4153 | ........ 4154 | ........ 4155 | ........ 4156 | ........ 4157 | ........ 4158 | ........ 4159 | ........ 4160 | ........ 4161 | ........ 4162 | 4163 | char 0xe7 4164 | ........ 4165 | ........ 4166 | ........ 4167 | ........ 4168 | ........ 4169 | ........ 4170 | ........ 4171 | ........ 4172 | ........ 4173 | ........ 4174 | ........ 4175 | ........ 4176 | ........ 4177 | ........ 4178 | ........ 4179 | ........ 4180 | 4181 | char 0xe8 4182 | ........ 4183 | ........ 4184 | ........ 4185 | ........ 4186 | ........ 4187 | ........ 4188 | ........ 4189 | ........ 4190 | ........ 4191 | ........ 4192 | ........ 4193 | ........ 4194 | ........ 4195 | ........ 4196 | ........ 4197 | ........ 4198 | 4199 | char 0xe9 4200 | ........ 4201 | ........ 4202 | ........ 4203 | ........ 4204 | ........ 4205 | ........ 4206 | ........ 4207 | ........ 4208 | ........ 4209 | ........ 4210 | ........ 4211 | ........ 4212 | ........ 4213 | ........ 4214 | ........ 4215 | ........ 4216 | 4217 | char 0xea 4218 | ........ 4219 | ........ 4220 | ........ 4221 | ........ 4222 | ........ 4223 | ........ 4224 | ........ 4225 | ........ 4226 | ........ 4227 | ........ 4228 | ........ 4229 | ........ 4230 | ........ 4231 | ........ 4232 | ........ 4233 | ........ 4234 | 4235 | char 0xeb 4236 | ........ 4237 | ........ 4238 | ........ 4239 | ........ 4240 | ........ 4241 | ........ 4242 | ........ 4243 | ........ 4244 | ........ 4245 | ........ 4246 | ........ 4247 | ........ 4248 | ........ 4249 | ........ 4250 | ........ 4251 | ........ 4252 | 4253 | char 0xec 4254 | ........ 4255 | ........ 4256 | ........ 4257 | ........ 4258 | ........ 4259 | ........ 4260 | ........ 4261 | ........ 4262 | ........ 4263 | ........ 4264 | ........ 4265 | ........ 4266 | ........ 4267 | ........ 4268 | ........ 4269 | ........ 4270 | 4271 | char 0xed 4272 | ........ 4273 | ........ 4274 | ........ 4275 | ........ 4276 | ........ 4277 | ........ 4278 | ........ 4279 | ........ 4280 | ........ 4281 | ........ 4282 | ........ 4283 | ........ 4284 | ........ 4285 | ........ 4286 | ........ 4287 | ........ 4288 | 4289 | char 0xee 4290 | ........ 4291 | ........ 4292 | ........ 4293 | ........ 4294 | ........ 4295 | ........ 4296 | ........ 4297 | ........ 4298 | ........ 4299 | ........ 4300 | ........ 4301 | ........ 4302 | ........ 4303 | ........ 4304 | ........ 4305 | ........ 4306 | 4307 | char 0xef 4308 | ........ 4309 | ........ 4310 | ........ 4311 | ........ 4312 | ........ 4313 | ........ 4314 | ........ 4315 | ........ 4316 | ........ 4317 | ........ 4318 | ........ 4319 | ........ 4320 | ........ 4321 | ........ 4322 | ........ 4323 | ........ 4324 | 4325 | char 0xf0 4326 | ........ 4327 | ........ 4328 | ........ 4329 | ........ 4330 | ........ 4331 | ........ 4332 | ........ 4333 | ........ 4334 | ........ 4335 | ........ 4336 | ........ 4337 | ........ 4338 | ........ 4339 | ........ 4340 | ........ 4341 | ........ 4342 | 4343 | char 0xf1 4344 | ........ 4345 | ........ 4346 | ........ 4347 | ........ 4348 | ........ 4349 | ........ 4350 | ........ 4351 | ........ 4352 | ........ 4353 | ........ 4354 | ........ 4355 | ........ 4356 | ........ 4357 | ........ 4358 | ........ 4359 | ........ 4360 | 4361 | char 0xf2 4362 | ........ 4363 | ........ 4364 | ........ 4365 | ........ 4366 | ........ 4367 | ........ 4368 | ........ 4369 | ........ 4370 | ........ 4371 | ........ 4372 | ........ 4373 | ........ 4374 | ........ 4375 | ........ 4376 | ........ 4377 | ........ 4378 | 4379 | char 0xf3 4380 | ........ 4381 | ........ 4382 | ........ 4383 | ........ 4384 | ........ 4385 | ........ 4386 | ........ 4387 | ........ 4388 | ........ 4389 | ........ 4390 | ........ 4391 | ........ 4392 | ........ 4393 | ........ 4394 | ........ 4395 | ........ 4396 | 4397 | char 0xf4 4398 | ........ 4399 | ........ 4400 | ........ 4401 | ........ 4402 | ........ 4403 | ........ 4404 | ........ 4405 | ........ 4406 | ........ 4407 | ........ 4408 | ........ 4409 | ........ 4410 | ........ 4411 | ........ 4412 | ........ 4413 | ........ 4414 | 4415 | char 0xf5 4416 | ........ 4417 | ........ 4418 | ........ 4419 | ........ 4420 | ........ 4421 | ........ 4422 | ........ 4423 | ........ 4424 | ........ 4425 | ........ 4426 | ........ 4427 | ........ 4428 | ........ 4429 | ........ 4430 | ........ 4431 | ........ 4432 | 4433 | char 0xf6 4434 | ........ 4435 | ........ 4436 | ........ 4437 | ........ 4438 | ........ 4439 | ........ 4440 | ........ 4441 | ........ 4442 | ........ 4443 | ........ 4444 | ........ 4445 | ........ 4446 | ........ 4447 | ........ 4448 | ........ 4449 | ........ 4450 | 4451 | char 0xf7 4452 | ........ 4453 | ........ 4454 | ........ 4455 | ........ 4456 | ........ 4457 | ........ 4458 | ........ 4459 | ........ 4460 | ........ 4461 | ........ 4462 | ........ 4463 | ........ 4464 | ........ 4465 | ........ 4466 | ........ 4467 | ........ 4468 | 4469 | char 0xf8 4470 | ........ 4471 | ........ 4472 | ........ 4473 | ........ 4474 | ........ 4475 | ........ 4476 | ........ 4477 | ........ 4478 | ........ 4479 | ........ 4480 | ........ 4481 | ........ 4482 | ........ 4483 | ........ 4484 | ........ 4485 | ........ 4486 | 4487 | char 0xf9 4488 | ........ 4489 | ........ 4490 | ........ 4491 | ........ 4492 | ........ 4493 | ........ 4494 | ........ 4495 | ........ 4496 | ........ 4497 | ........ 4498 | ........ 4499 | ........ 4500 | ........ 4501 | ........ 4502 | ........ 4503 | ........ 4504 | 4505 | char 0xfa 4506 | ........ 4507 | ........ 4508 | ........ 4509 | ........ 4510 | ........ 4511 | ........ 4512 | ........ 4513 | ........ 4514 | ........ 4515 | ........ 4516 | ........ 4517 | ........ 4518 | ........ 4519 | ........ 4520 | ........ 4521 | ........ 4522 | 4523 | char 0xfb 4524 | ........ 4525 | ........ 4526 | ........ 4527 | ........ 4528 | ........ 4529 | ........ 4530 | ........ 4531 | ........ 4532 | ........ 4533 | ........ 4534 | ........ 4535 | ........ 4536 | ........ 4537 | ........ 4538 | ........ 4539 | ........ 4540 | 4541 | char 0xfc 4542 | ........ 4543 | ........ 4544 | ........ 4545 | ........ 4546 | ........ 4547 | ........ 4548 | ........ 4549 | ........ 4550 | ........ 4551 | ........ 4552 | ........ 4553 | ........ 4554 | ........ 4555 | ........ 4556 | ........ 4557 | ........ 4558 | 4559 | char 0xfd 4560 | ........ 4561 | ........ 4562 | ........ 4563 | ........ 4564 | ........ 4565 | ........ 4566 | ........ 4567 | ........ 4568 | ........ 4569 | ........ 4570 | ........ 4571 | ........ 4572 | ........ 4573 | ........ 4574 | ........ 4575 | ........ 4576 | 4577 | char 0xfe 4578 | ........ 4579 | ........ 4580 | ........ 4581 | ........ 4582 | ........ 4583 | ........ 4584 | ........ 4585 | ........ 4586 | ........ 4587 | ........ 4588 | ........ 4589 | ........ 4590 | ........ 4591 | ........ 4592 | ........ 4593 | ........ 4594 | 4595 | char 0xff 4596 | ........ 4597 | ........ 4598 | ........ 4599 | ........ 4600 | ........ 4601 | ........ 4602 | ........ 4603 | ........ 4604 | ........ 4605 | ........ 4606 | ........ 4607 | ........ 4608 | ........ 4609 | ........ 4610 | ........ 4611 | ........ 4612 | -------------------------------------------------------------------------------- /font/makefont.c: -------------------------------------------------------------------------------- 1 | // originally from https://github.com/HariboteOS/tolsrc 2 | // [ADD] header 3 | 4 | #include 5 | 6 | int main(int argc, char **argv){ 7 | FILE *fp0, *fp1; 8 | if(argc < 3){ 9 | puts("usage> makefont source.txt font.bin"); 10 | return 1; 11 | } 12 | 13 | fp0 = fopen(argv[1], "r"); 14 | fp1 = fopen(argv[2], "wb"); 15 | 16 | if(fp0 == NULL){ 17 | puts("can't open input file."); 18 | return 2; 19 | } 20 | 21 | if(fp1 == NULL){ 22 | puts("can't open output file."); 23 | return 3; 24 | } 25 | 26 | // load header 27 | unsigned int xsize,ysize; 28 | fscanf(fp0, "%d", &xsize); 29 | fscanf(fp0, "%d", &ysize); 30 | 31 | printf("font size: %dx%d\n", xsize, ysize); 32 | fprintf(fp1, "%d\n%d\n", xsize, ysize); 33 | 34 | do { 35 | char s[12]; 36 | int i; 37 | if(fgets(s, 12, fp0) != NULL && (s[0] == ' ' || s[0] == '*' || s[0] == '.')){ 38 | i = (s[0] == '*') << 7; 39 | i |= (s[1] == '*') << 6; 40 | i |= (s[2] == '*') << 5; 41 | i |= (s[3] == '*') << 4; 42 | i |= (s[4] == '*') << 3; 43 | i |= (s[5] == '*') << 2; 44 | i |= (s[6] == '*') << 1; 45 | i |= (s[7] == '*') ; 46 | fputc(i, fp1); 47 | } 48 | } while (!feof(fp0)); 49 | 50 | fclose(fp0); 51 | fclose(fp1); 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /font/sjis2utf8.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # originaly from https://gist.github.com/hikalium/6b78979187a32a88215716278a011eb0 4 | 5 | echo $1 6 | LANG=C file $1 | grep -v -q "UTF-8" && \ 7 | cp $1 $1.org && \ 8 | iconv -f shift-jis -t utf-8 $1.org | \ 9 | sed -e 's/‾/~/g' | \ 10 | sed -e 's/¥/\\/g' > tmp 11 | tr -d '\r' < tmp > $1 12 | rm tmp 13 | -------------------------------------------------------------------------------- /gui.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "gui.h" 6 | 7 | Gui::Gui() : disp(nullptr) { 8 | Init(); 9 | } 10 | 11 | Gui::~Gui(){ 12 | End(); 13 | } 14 | 15 | void Gui::Init(){} 16 | 17 | void Gui::Start(){ 18 | flg = true; 19 | th = std::thread(&Gui::proc, this); 20 | } 21 | 22 | void Gui::End(){ 23 | flg = false; 24 | if(th.joinable()) 25 | th.join(); 26 | } 27 | 28 | void Gui::proc(){ 29 | GLFWwindow *win; 30 | 31 | glfwInit(); 32 | 33 | if(disp == nullptr) throw "display is null"; 34 | win = glfwCreateWindow(disp->GetSizeX(), disp->GetSizeY(), "emulator", nullptr, nullptr); 35 | 36 | glfwMakeContextCurrent(win); 37 | 38 | glPixelZoom(1,-1); 39 | glRasterPos2f(-1,1); 40 | 41 | while(!glfwWindowShouldClose(win) && flg){ 42 | glClear(GL_COLOR_BUFFER_BIT); 43 | 44 | // if(disp != nullptr){ 45 | disp->FlushImage(); 46 | glDrawPixels(disp->GetSizeX(), disp->GetSizeY(), GL_RGB, GL_UNSIGNED_BYTE, disp->GetImage()); 47 | // } 48 | 49 | glfwSwapBuffers(win); 50 | glfwPollEvents(); 51 | } 52 | 53 | glfwDestroyWindow(win); 54 | onExit(); 55 | } 56 | -------------------------------------------------------------------------------- /gui.h: -------------------------------------------------------------------------------- 1 | #ifndef GUI_H_ 2 | #define GUI_H_ 3 | 4 | #include 5 | #include 6 | #include "device/display.h" 7 | 8 | class Gui { 9 | public: 10 | Gui(); 11 | ~Gui(); 12 | 13 | void Init(); 14 | void SetDisplay(Device::Display &d){ this->disp = &d; } 15 | void Start(); 16 | void Start(Device::Display &d){ 17 | SetDisplay(d); 18 | Start(); 19 | } 20 | void End(); 21 | 22 | std::function onExit; 23 | private: 24 | void proc(); 25 | bool flg; 26 | std::thread th; 27 | Device::Display *disp; 28 | std::vector font; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /gui_old/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := gui.a 2 | OBJS := gui.o 3 | 4 | default: 5 | make $(TARGET) 6 | 7 | clean: 8 | rm -f $(TARGET) $(OBJS) 9 | 10 | $(TARGET):$(OBJS) 11 | ar rcs $@ $^ 12 | 13 | -------------------------------------------------------------------------------- /gui_old/gui.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "gui.h" 4 | 5 | using namespace std; 6 | 7 | vector Gui::instances; 8 | 9 | Gui::Gui(){ 10 | instances.push_back(this); 11 | Init(); 12 | } 13 | 14 | Gui::~Gui(){ 15 | th_flg = false; 16 | gui_th->join(); 17 | // for(;!th_flg;); 18 | cerr<<"neko!w"<FlushImage(); 71 | glDrawPixels(scrnx, scrny, GL_RGB, GL_UNSIGNED_BYTE, disp->GetImage()); 72 | } 73 | 74 | glfwSwapBuffers(win); 75 | glfwWaitEvents(); 76 | } 77 | 78 | cerr<<"Gui::gui_proc() ending..."< 5 | #include 6 | #include "../device/display.h" 7 | 8 | #define DEFAULT_SCRNX 320 9 | #define DEFAULT_SCRNY 200 10 | 11 | class Gui { 12 | public: 13 | Gui(); 14 | ~Gui(); 15 | 16 | void Init(); 17 | int Start(); 18 | 19 | void SetDisplay(Display *disp){ this->disp = disp; } 20 | 21 | void gui_proc(); 22 | private: 23 | static std::vector instances; 24 | std::thread *gui_th; 25 | bool th_flg; 26 | int scrnx, scrny; 27 | Display *disp; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /insn_base.h: -------------------------------------------------------------------------------- 1 | #ifndef INSN_BASE_H_ 2 | #define INSN_BASE_H_ 3 | 4 | #include 5 | #include 6 | #include "common.h" 7 | 8 | class EmulatorBase; 9 | class InstructionBase; 10 | using insnfunc_t = void (InstructionBase::*)(); 11 | 12 | class InstructionBase { 13 | public: 14 | InstructionBase(){ 15 | /* ✟私はコンストラクタで純粋仮想関数を使おうとしました✟ */ 16 | //insn = std::vector(0xff, (insnfunc_t)&InstructionBase::not_impl_insn); 17 | } 18 | //InstructionBase(EmulatorBase *e) : emu(e) {} 19 | virtual ~InstructionBase(){} 20 | 21 | //void SetEmu(EmulatorBase *emu){ this->emu=emu; } 22 | void ClearInsn(size_t num){ insn.resize(num, (insnfunc_t)&InstructionBase::not_impl_insn); } 23 | virtual void Init() = 0; 24 | virtual void Fetch() = 0; 25 | virtual void Decode() = 0; 26 | virtual void Exec() = 0; 27 | protected: 28 | //EmulatorBase *emu; 29 | // typedef void (InstructionBase::*insnfunc_t)(); 30 | std::vector insn; 31 | std::vector insn_name; 32 | virtual void not_impl_insn() = 0; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERRUPT_H_ 2 | #define INTERRUPT_H_ 3 | 4 | class Interrupt { 5 | public: 6 | Interrupt(); 7 | private: 8 | 9 | }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /io.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_H_ 2 | #define IO_H_ 3 | 4 | #include 5 | #include "device/device.h" 6 | 7 | class IO { 8 | public: 9 | IO(){} 10 | ~IO(){} 11 | 12 | using Port = uint16_t; 13 | std::unordered_map port; 14 | 15 | bool check(const Port &p){ 16 | if(port.find(p) != port.end()) return true; 17 | DOUT(std::endl<<"no device connected at port:0x"<in8(p); 25 | } 26 | 27 | void out8(const Port &p, const uint8_t &data){ 28 | check(p); 29 | port[p]->out8(p, data); 30 | } 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include // https://github.com/sk2sat/libsksat 5 | #include "emulator.h" 6 | #include "gui.h" 7 | 8 | EmulatorCtrl::Setting set; 9 | EmulatorCtrl emuctrl; 10 | 11 | int main(int argc, char **argv){ 12 | using std::cout; 13 | using std::endl; 14 | using std::string; 15 | try{ 16 | set.arch = ARCH::x86; 17 | set.memsize = 1; // 1MB 18 | 19 | sksat::optparse o; 20 | string arch_str; 21 | string fda_file; // A drive (floppy) 22 | string font_file = "font/hankaku.bin"; 23 | 24 | { 25 | string exe_dir = argv[0]; 26 | auto end = exe_dir.size(); 27 | for(;;end--){ 28 | if(exe_dir[end] == '/') break; 29 | } 30 | auto path = exe_dir.substr(0, end); 31 | font_file = path + '/' + font_file; 32 | } 33 | 34 | o.add_opt(arch_str, 'a', "arch", "architecture"); 35 | o.add_opt(set.junk_bios, "junk-bios", "enable junk BIOS"); 36 | o.add_opt(set.memsize, 'm', "memory-size", "memory size(MB)"); 37 | o.add_opt(set.gui, "gui", "with GUI"); 38 | o.add_opt(fda_file, "fda", "floppy disk image file"); 39 | o.add_opt(font_file, "font", "font file"); 40 | 41 | if(!o.parse(argc, argv)){ 42 | cout <<"simple x86 emulator by sksat"<memory->Init(set.memsize * MB); 65 | // emu->memory->LoadBinary("sample/harib27f.img", 0x7c00, 512); 66 | 67 | cout<<"memory size: "<ConnectDevice(fda); 73 | } 74 | 75 | std::unique_ptr gui; 76 | Device::Display disp; 77 | auto& port = emu->io->port; 78 | port[0x03c8] = port[0x03c9] = &disp; 79 | bool halt_exit = false; 80 | if(set.gui){ 81 | disp.LoadFont(font_file); 82 | disp.RegisterVRAM(emu->memory, 0xa0000, 0xffff); 83 | emu->ConnectDevice(disp); 84 | 85 | gui = std::make_unique(); 86 | gui->onExit = [&](){ emu->finish_flg = true; }; 87 | gui->Start(disp); 88 | }else{ 89 | halt_exit = true; // CLIだったらhaltした時に終了するようにする 90 | } 91 | 92 | if(set.junk_bios){ 93 | cout<<"setup junk BIOS..."<SetBios(new BIOS::Junk::x86(dynamic_cast(emu))); 98 | break; 99 | default: 100 | throw "not implemented junk BIOS for this arch."; 101 | break; 102 | } 103 | if(set.gui) emu->bios->SetDisplay(disp); 104 | emu->bios->Boot(); 105 | } 106 | 107 | cout<<"emulation start"<Run(halt_exit); 112 | 113 | auto end = std::chrono::system_clock::now(); 114 | 115 | emu->Dump(); 116 | if(set.gui) gui->End(); 117 | 118 | std::cout<<"time: "<<(double)std::chrono::duration_cast(end - start).count()<<"s"<Dump(); 124 | }catch(string msg){ 125 | cout<Dump(); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /memory.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "memory.h" 5 | 6 | using namespace std; 7 | 8 | Memory::Memory():size(0x00){ 9 | virt_flg = false; 10 | } 11 | 12 | Memory::~Memory(){} 13 | 14 | void Memory::Init(int size){ 15 | this->size = size; 16 | if(mem.size() == 0) 17 | mem.clear(); 18 | mem.resize(size); 19 | virt_flg = false; 20 | minfo.clear(); 21 | return; 22 | } 23 | 24 | int Memory::GetSize(){ 25 | return size; 26 | } 27 | 28 | uint8_t Memory::GetData8(uint32_t addr) { 29 | if(addr > static_cast(size)){ 30 | stringstream ss; 31 | ss<<"memory: out of range address ("<>(i*8)); 82 | } 83 | 84 | void Memory::SetData32Little(uint32_t addr, uint32_t val){ 85 | for(int i=0;i<4;i++) 86 | SetData8(addr+i, val>>(i*8)); 87 | return; 88 | } 89 | 90 | void Memory::MapDevice(Device::Base *dev, uint32_t addr, unsigned int size){ 91 | // throw "Memory: MapDevice() not implemented."; 92 | MapInfo mi; 93 | mi.dev = dev; 94 | mi.mem = nullptr; 95 | mi.addr = addr; 96 | mi.end_addr = addr + size; 97 | minfo.push_back(mi); 98 | } 99 | 100 | void Memory::MapMemory(uint8_t *mem, uint32_t addr, unsigned int size){ 101 | // throw "Memory: MapMemory() not implemented."; 102 | MapInfo mi; 103 | mi.dev = nullptr; 104 | mi.mem = mem; 105 | mi.addr = addr; 106 | mi.end_addr = addr + size; 107 | minfo.push_back(mi); 108 | } 109 | 110 | void Memory::LoadBinary(FILE *fp, uint32_t addr, size_t size){ 111 | if(fp == nullptr) throw "FILE* is nullptr"; 112 | // fread(mem + addr, 1, size, fp); 113 | cout<<"fread: "<<"size: "<operator[](addr+size); 121 | 122 | cout<<"loading binary from file: \""<operator[](addr+size); 132 | FILE *fp; 133 | fp = fopen(fname, "wb"); 134 | if(fp == NULL) throw "memory: Dump: can't open file."; 135 | fwrite(&mem[addr], sizeof(uint8_t), size, fp); 136 | fclose(fp); 137 | } 138 | 139 | -------------------------------------------------------------------------------- /memory.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_H_ 2 | #define MEMORY_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "common.h" 8 | #include "device/device.h" 9 | 10 | enum class ENDIAN { BIG, LITTLE, }; 11 | 12 | namespace Device { 13 | class Base; 14 | } 15 | 16 | struct MapInfo { 17 | uint32_t addr; 18 | uint32_t end_addr; 19 | Device::Base *dev; 20 | uint8_t *mem; 21 | }; 22 | 23 | class Memory { 24 | public: 25 | ENDIAN endian; 26 | int size; 27 | 28 | Memory(); 29 | ~Memory(); 30 | 31 | void Init(int size); 32 | int GetSize(); 33 | 34 | bool IsVirt() const { return virt_flg; } 35 | void EnableVirt(){ virt_flg=true; } 36 | void UnableVirt(){ virt_flg=false; } 37 | 38 | std::vector& GetRaw(){ return mem; } 39 | 40 | // Memory* operator->(){ return this; } 41 | 42 | // little endianでのuint32_tの読み込み処理はEmulatorクラスから持ってくる 43 | uint8_t operator [] (uint32_t addr){ 44 | return GetData8(addr); 45 | } 46 | //int8_t operator [] (uint32_t addr){ return static_cast(operator=(addr)); } 47 | // uint32_t operator[](uint32_t addr); 48 | 49 | uint8_t GetData8(uint32_t addr); 50 | 51 | uint16_t GetData16Big(uint32_t addr){ throw "not implemented: big endian"; } 52 | uint16_t GetData16Little(uint32_t addr); 53 | inline uint16_t GetData16(uint32_t addr){ 54 | if(endian == ENDIAN::BIG) return GetData32Big(addr); 55 | return GetData32Little(addr); 56 | } 57 | 58 | uint32_t GetData32Big(uint32_t addr){ throw "not implemented: big endian"; } 59 | uint32_t GetData32Little(uint32_t addr); 60 | inline uint32_t GetData32(uint32_t addr){ 61 | if(endian == ENDIAN::BIG) return GetData32Big(addr); 62 | return GetData32Little(addr); 63 | } 64 | 65 | void SetData8(uint32_t addr, uint8_t val){ 66 | if(addr > static_cast(size)){ 67 | DOUT("addr=0x"< mem; 100 | std::vector minfo; 101 | int minfo_num; 102 | bool virt_flg; 103 | }; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /register_base.cc: -------------------------------------------------------------------------------- 1 | #include "register_base.h" 2 | -------------------------------------------------------------------------------- /register_base.h: -------------------------------------------------------------------------------- 1 | #ifndef REGISTER_BASE_H_ 2 | #define REGISTER_BASE_H_ 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | 9 | class Register { 10 | public: 11 | Register(){} 12 | explicit Register(size_t size){} 13 | explicit Register(uint8_t r) : low8(r) {} 14 | explicit Register(uint16_t r): reg16(r){} 15 | explicit Register(uint32_t r): reg32(r){} 16 | 17 | void SetSize(size_t size){} 18 | 19 | // とりあえずサイズのチェックはしない 20 | uint8_t Get8() { return low8; } 21 | int8_t GetSign8() { return (int8_t)Get8(); } 22 | uint8_t GetHigh8() { return high8; } 23 | int8_t GetSignHign8(){return (int8_t)GetHigh8();} 24 | uint16_t Get16() { return reg16;} 25 | int16_t GetSign16() { return (int16_t)Get16(); } 26 | uint32_t Get32() { return reg32; } 27 | int32_t GetSign32() { return (int32_t)Get32(); } 28 | 29 | operator uint8_t() { return Get8(); } 30 | operator int8_t() { return GetSign8(); } 31 | operator uint16_t() { return Get16(); } 32 | operator int16_t() { return GetSign16(); } 33 | operator uint32_t() { return Get32(); } 34 | operator int32_t() { return GetSign32(); } 35 | 36 | std::string name; 37 | 38 | public: 39 | size_t size; 40 | union { 41 | uint32_t reg32; 42 | uint16_t reg16; 43 | struct { 44 | uint8_t low8; 45 | uint8_t high8; 46 | }; 47 | }; 48 | }; 49 | 50 | */ 51 | 52 | class RegisterBase { 53 | public: 54 | explicit RegisterBase(std::size_t s) : size(s) {}; 55 | 56 | std::size_t GetSize() const { return size; } 57 | void SetSize(std::size_t s) { size = s; } 58 | 59 | const std::string GetName() const { return name; } 60 | void SetName(std::string n) { name = n; } 61 | void SetName(const char* n) { name = n; } 62 | 63 | virtual const std::string GetDataByString() const = 0; 64 | private: 65 | std::size_t size; 66 | std::string name; 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | *.img 3 | z_tools 4 | harib27f* 5 | haribote-os/ 6 | -------------------------------------------------------------------------------- /sample/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = helloos.img 2 | OBJS = startup.o main.o 3 | 4 | HARIB27F_APP = bball 5 | 6 | HARIB_VER = harib02f 7 | #HARIB_DAY = 02 8 | 9 | default: 10 | make $(TARGET) 11 | 12 | set_branch: 13 | ifdef HARIB_VER 14 | $(eval HARIB_BRANCH=refs/tags/$(HARIB_VER)) 15 | else 16 | ifdef HARIB_DAY 17 | $(eval HARIB_BRANCH=day/$(HARIB_DAY)) 18 | endif 19 | endif 20 | 21 | HARIB_BRANCH ?= master 22 | 23 | CFLAGS = -m32 24 | CFLAGS += -nostdlib -fno-asynchronous-unwind-tables -g -fno-stack-protector 25 | LDFLAGS = -melf_i386 26 | LDFLAGS += --entry=start -Ttext=0x7c00 27 | 28 | include ../common.mk 29 | 30 | %.o:%.S 31 | gcc -m32 -c $< -o $@ 32 | 33 | %.o:%.asm 34 | nasm -f elf $< 35 | 36 | %.o:%.c 37 | gcc $(CFLAGS) -c $< -o $@ 38 | 39 | clean: 40 | rm -f *.img *.bin *.o 41 | 42 | tmp.elf:$(OBJS) 43 | ld $(LDFLAGS) $^ -o $@ 44 | 45 | test.bin:tmp.elf 46 | objcopy -O binary tmp.elf $@ 47 | rm $< 48 | 49 | z_tools: 50 | git clone https://github.com/HariboteOS/z_tools_linux.git 51 | mv z_tools_linux $@ 52 | 53 | haribote-os: 54 | git clone https://github.com/sk2sat/haribote-os.git 55 | cd $@ && ./install.sh 56 | 57 | helloos.img:haribote-os 58 | cd $< && git checkout 2-4 59 | make -C $= 0) 3 | return i; 4 | return -i; 5 | } 6 | 7 | void loop2(){ 8 | volatile int i; 9 | for(i=0;i<10000;i++); 10 | return; 11 | } 12 | 13 | int main(void){ 14 | loop2(); 15 | return abs(3); 16 | } 17 | -------------------------------------------------------------------------------- /sample/osecpu/app0100.ose: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sksat/emu/909411730c2af56d01321792a7e20020fc440511/sample/osecpu/app0100.ose -------------------------------------------------------------------------------- /sample/osecpu/app0102.ose: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sksat/emu/909411730c2af56d01321792a7e20020fc440511/sample/osecpu/app0102.ose -------------------------------------------------------------------------------- /sample/startup.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | extern main 3 | global start 4 | ; org 0x7c00 5 | 6 | start: 7 | ; call main 8 | mov dword [0x00], 10000000 9 | call loop 10 | jmp 0 11 | 12 | loop: 13 | inc ecx 14 | cmp ecx,[0x00] 15 | jnz loop 16 | ret 17 | -------------------------------------------------------------------------------- /script_out.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sksat/emu/909411730c2af56d01321792a7e20020fc440511/script_out.txt -------------------------------------------------------------------------------- /shell/Makefile: -------------------------------------------------------------------------------- 1 | SHELL_LIB := shell.a 2 | SHELL_OBJS:= shell.o command.o 3 | 4 | default: 5 | make $(SHELL_LIB) 6 | 7 | clean: 8 | rm -f *.a *.o 9 | 10 | $(SHELL_LIB):$(SHELL_OBJS) 11 | ar rcs $@ $^ 12 | -------------------------------------------------------------------------------- /shell/command.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "command.h" 5 | 6 | using namespace std; 7 | 8 | namespace shell { 9 | 10 | void InitDefaultCommand(Shell *sh){ 11 | sh->Register("exit", exit); 12 | sh->Register("test", test); 13 | sh->Register("print", print); 14 | sh->Register("init", init); 15 | sh->Register("load", load); 16 | sh->Register("run", run); 17 | sh->Register("startg", startg); 18 | sh->Register("congui", congui); 19 | } 20 | 21 | int exit(Shell *sh, vector args){ 22 | int i=0, size = args.size(); 23 | if(size > 2){ 24 | cout<<"exit: Too many arguments."< args){ 35 | cout<<"test command."< args){ 39 | Emulator *emu = sh->get_emu(); 40 | if(emu == nullptr) throw "emulator is null"; 41 | cout<<"EIP : "<EIP<ESP< args){ 47 | try{ 48 | Emulator *emu = sh->get_emu(); 49 | int siz = args.size(); 50 | int memory_size; 51 | uint32_t init_eip, init_esp; 52 | 53 | int tmp = args[1].size(), unit=1, unit_long=0; 54 | 55 | if(siz < 2){ 56 | emu->Init(1 * MB, 0x7c00, 0x7c00); 57 | return 0; 58 | } 59 | // if(siz<4){ cout<<"init: Too few arguments."<4){ cout<<"init: Too many arguments."< 2) 98 | init_eip = stoi(args[2], nullptr, 0); 99 | if(siz > 3) 100 | init_esp = stoi(args[3], nullptr, 0); 101 | 102 | cout<<"memory size : "<Init(memory_size, init_eip, init_esp); 106 | return 0; 107 | init_usage: 108 | cout<<"> init memory_size init_eip init_esp"< args){ 122 | Emulator *emu = sh->get_emu(); 123 | if(args.size() != 3) throw "option error."; 124 | if(args[1] == "binary") cout<<"loading binary..."<LoadBinary(args[2].c_str(), 0x7c00, 512); 129 | } 130 | 131 | int run(Shell *sh, vector args){ 132 | Emulator *emu = sh->get_emu(); 133 | cout<<"runing..."<Start(); 135 | return 0; 136 | } 137 | 138 | //starting GUI 139 | int startg(Shell *sh, vector args){ 140 | Gui *gui = new Gui(); 141 | // gui->gui_proc(); 142 | sh->set_gui(gui); 143 | gui->Start(); 144 | cout<<"starting GUI : "<get_guinum()< args){ 151 | Emulator *emu; 152 | Gui *gui; 153 | Display *disp; 154 | 155 | switch(args.size()){ 156 | case 1: 157 | emu = sh->get_emu(); 158 | gui = sh->get_gui(); 159 | break; 160 | default: 161 | cout<<"congui: arg num error"<GetDisplay(); 171 | if(disp == nullptr){ 172 | cout<<"can't get display."<SetDisplay(disp); 176 | 177 | return 0; 178 | } 179 | 180 | }; 181 | -------------------------------------------------------------------------------- /shell/command.h: -------------------------------------------------------------------------------- 1 | #ifndef SHELL_COMMAND_H_ 2 | #define SHELL_COMMAND_H_ 3 | 4 | #include "shell.h" 5 | 6 | namespace shell { 7 | 8 | void InitDefaultCommand(Shell *sh); 9 | int alias(Shell *sh, std::vector arg); 10 | int exit(Shell *sh, std::vector args); 11 | int test(Shell *sh, std::vector args); 12 | int print(Shell *sh, std::vector args); 13 | int init(Shell *sh, std::vector args); 14 | int load(Shell *sh, std::vector args); 15 | int run(Shell *sh, std::vector args); 16 | int startg(Shell *sh, std::vector args); 17 | int congui(Shell *sh, std::vector args); 18 | 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /shell/shell.cc: -------------------------------------------------------------------------------- 1 | #include "shell.h" 2 | #include "command.h" 3 | 4 | using namespace std; 5 | using namespace shell; 6 | 7 | streambuf* Shell::cin_buf = nullptr; 8 | streambuf* Shell::cout_buf= nullptr; 9 | int Shell::sh_num = 0; 10 | 11 | void Shell::Init(Emulator *emu){ 12 | // if(emu == nullptr) throw "shell: Emulator* is nullptr."; 13 | this->emu = emu; 14 | this->gui = nullptr; 15 | this->guis = vector(); 16 | this->guis.push_back(nullptr); 17 | sh_thread = nullptr; 18 | ifs = nullptr; 19 | ofs = nullptr; 20 | if(sh_num == 0){ 21 | cin_buf = cin.rdbuf(); 22 | cout_buf= cout.rdbuf(); 23 | }else{ 24 | SetDefaultStream(); 25 | } 26 | script_flg = false; 27 | sh_num++; 28 | } 29 | 30 | void Shell::SetDefaultStream(){ 31 | cin.rdbuf(cin_buf); 32 | cout.rdbuf(cout_buf); 33 | script_flg = false; 34 | } 35 | 36 | void Shell::ChangeStream(ifstream &ifs){ 37 | SetDefaultStream(); 38 | cin.rdbuf(ifs.rdbuf()); 39 | script_flg = true; 40 | } 41 | 42 | void Shell::ChangeStream(ofstream &ofs){ 43 | // SetDefaultStream(); 44 | cout.rdbuf(ofs.rdbuf()); 45 | } 46 | 47 | void Shell::Start(){ 48 | if(sh_thread != nullptr){ 49 | delete sh_thread; 50 | } 51 | sh_thread = new thread(&Shell::sh_proc, this); 52 | } 53 | 54 | int Shell::Exec(const char *script){ 55 | ifstream ifs; 56 | 57 | ifs.open(script); 58 | Exec(ifs); 59 | return 0; 60 | } 61 | 62 | int Shell::Exec(ifstream &script){ 63 | Shell *sh; 64 | sh = new Shell(emu); 65 | sh->ChangeStream(script); 66 | 67 | ofstream ofs; 68 | ofs.open("script_out.txt"); 69 | // sh->ChangeStream(ofs); 70 | 71 | sh->sh_proc(); 72 | SetDefaultStream(); 73 | // delete sh; 74 | return 0; 75 | } 76 | 77 | struct COMMAND_DATA { 78 | vector args; 79 | }; 80 | 81 | string rm_space(string str){ 82 | string tmp, ret; 83 | 84 | for(int i=0;i str; 104 | }; 105 | 106 | vector parse_line(string line){ 107 | vector arg; 108 | bool flg=false; 109 | int now=0; 110 | arg.push_back(string()); 111 | for(int i=0;i "; 150 | char c; 151 | for(;;){ 152 | c = cin.get(); 153 | if(c=='\n' || c==EOF) break; 154 | line.push_back(c); 155 | } 156 | // cout<<"line: "< args = parse_line(line); 158 | // if(args[0].empty()) continue; 159 | if(args.size() == 1){ 160 | if(args[0].empty()){ 161 | if(cin.eof()) break; 162 | cerr<<"empty"< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../emulator.h" 10 | #include "../gui/gui.h" 11 | 12 | class Shell; 13 | class Emulator; 14 | 15 | typedef int command_func_t(Shell* sh, std::vector args); 16 | 17 | struct CommandInfo { 18 | const char *command; 19 | command_func_t *func; 20 | }; 21 | 22 | class Shell { 23 | public: 24 | Shell(Emulator *emu){ Init(emu); } 25 | Shell(Emulator *emu, std::ifstream &ifs, std::ofstream &ofs){ 26 | Init(emu); 27 | ChangeStream(ifs, ofs); 28 | } 29 | ~Shell(){ Close(); } 30 | void Init(Emulator *emu); 31 | void SetDefaultStream(); 32 | void ChangeStream(std::ifstream &ifs); 33 | void ChangeStream(std::ofstream &ofs); 34 | void ChangeStream(std::ifstream &ifs, std::ofstream &ofs){ 35 | ChangeStream(ifs); 36 | ChangeStream(ofs); 37 | } 38 | void Start(); 39 | void Stop(); 40 | void Close(); 41 | void Register(const char *com, command_func_t* f){ 42 | CommandInfo i; 43 | i.command = com; 44 | i.func = f; 45 | cinfo.push_back(i); 46 | } 47 | int Exec(const char *script); 48 | int Exec(std::ifstream &script); 49 | 50 | int exec_command(std::string); 51 | 52 | Emulator* get_emu(){ return emu; } 53 | void set_emu(Emulator *emu){ this->emu = emu; } 54 | Gui* get_gui(){ return gui; } 55 | Gui* get_gui(int n){ 56 | if(ngui = gui; 68 | guis.push_back(gui); 69 | } 70 | //private: 71 | int sh_proc(void); 72 | private: 73 | Emulator *emu; 74 | Gui *gui; 75 | std::vector guis; 76 | std::thread *sh_thread; 77 | std::vector cinfo; 78 | std::ifstream *ifs; 79 | std::ofstream *ofs; 80 | bool script_flg; 81 | static std::streambuf *cin_buf, *cout_buf; 82 | static int sh_num; 83 | }; 84 | 85 | #endif 86 | --------------------------------------------------------------------------------