Writing an 8086 emulator in Python
|
|
- Logan Small
- 8 years ago
- Views:
Transcription
1 Writing an 8086 emulator in Python Cesare Di Mauro PyCon 2015 Florence April 2015 April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 1
2 The geek experience Writing your own o.s.: A few steps for a minimal o.s. example: - write an 8086 boot loader (MBR for floppy) - take control of the hardware (clear/set interrupts, etc.) - write some text on the screen from the main code - loop forever (or halt the execution) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 2
3 The result Credits to Ben Barbour s article: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 3
4 What s next The geeks dream! Credits to Wikipedia: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 4
5 What s really next: some graphic! A mode 13h (320x200 x 256 colors) example Credits to Wikipedia: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 5
6 Beyond 8086: Protected Mode The old 8086 (Real Mode) was very limited: - 16-bit code only - 1MB, segmented address space (64KB segments) - no paging (MMU) & virtualization The Protected Mode offers: - 16/32-bit code or 32/64-bit (with Long Mode) - 4GB or 256TB (virtual) linear address space - Paging & virtualization April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 6
7 Using BIOS services: no chance! Many of them don t work in protected mode! Possible solutions: - Switch back to 8086 (Real) mode - Use an 8086 Virtual Monitor (vm8086) Many drawbacks: - Interrupts served by Real Mode code or disabled! - Some 8086 BIOS calls can switch to Protected Mode - Some 8086 BIOS calls can directly use the hardware - No vm8086 in Long Mode April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 7
8 Best compromise: 8086 emulator Pros: - Works in Protected Mode, Long Mode, and even on different architectures (ARM, MIPS,PowerPCs, etc.) - Simple routing of hardware accesses ( ports I/O) - Simple routing of interrupts disable/enable requests - Perfect sandboxing (full control of the emulator) Cons: - Slow (not the most important thing; optimizations possible) - A lot of work (writing and testing) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 8
9 Why another 8086 emulator? Existing emulators can be difficult to adapt Licensing issues (GPL = viral) No weak neither perfect emulation needed: good enough! Easy to read, maintain, modify/experiment Reasonable speed for common cases (make them fast!) Fun! April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 9
10 Planning 8086 emulator prototype + unit test (in Python) Simple/minimal PC emulator (in Python too) Final C version (Windows DLL for testing) Integration on an hobby o.s. (AROS) AROS: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 10
11 Why AROS? A lightweight and small o.s. Let you easily experiment ideas An Amiga o.s. derived/inspired Passion! Fun! Credits to Eric W. Schwart: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 11
12 What AROS needs Drivers. Drivers. Have I said drivers? Difficult port: Amiga o.s. APIs/ABI Windows or Unix/Posix Primary need: graphic drivers. Few cards supported Primary fallback for graphic drivers: handling VESA modes April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 12
13 VESA mode (not modes!) Problems: - Only one VESA mode selectable at boot (from GRUB) - Changing VESA mode requires entire o.s. reboot Solution. Calling VESA BIOS APIs (INT 10h) let to: - List available screen modes - Change current mode - Set/Get palette colors - Set screen display inside the framebuffer (virtual screens) - More April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 13
14 How the trick works Boot time: AROS driver initialize 8086 emulator AROS driver calls emulator s INT 10h (VESA BIOS services) Emulator calls AROS driver s callbacks when needed AROS driver gets results from emulator call AROS: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 14
15 Emulator overview Some APIs exposed to set emulator status & callbacks A couple of APIs to run/stop execution Execution might hang by design! External events & emulation status controlled by caller It s an emulator, not a full PC: no hardware emulated! April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 15
16 The 8086 architecture General purpose Registers AH AL AX BH BL BX CH CL CX DH DL DX Index Registers Segment Registers Program Counter SI DI SP BP CS DS SS ES IP Source Index Destination Index Stack Pointer Base Pointer Code Segment Data Segment Stack Segment Extra Segment Status Register Flags All registers are 16-bit April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 16
17 Registers representation Array with bit values 0 AX 1 CX 2 DX 3 BX 4 SP 5 BP 6 SI 7 DI 8 (INTERNAL) ES 9 (INTERNAL) CS 10 (INTERNAL) SS 11 (INTERNAL) DS 12 *NOT USED* 13 *SCRATCH PAD* 14 (INTERNAL) IP 15 (INTERNAL) FLAGS April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 17
18 Registers definition # General purpose registers AX, CX, DX, BX, SP, BP, SI, DI = xrange(8) # Segment registers # Cannot be written normally! Use proper write_segment function INTERNAL_ES, INTERNAL_CS, INTERNAL_SS, INTERNAL_DS = xrange(8, 12) # Special registers # Cannot be read or written normally! # Use proper read/write_ip or read/write_flags functions INTERNAL_TEMP_REG, INTERNAL_IP, INTERNAL_FLAGS = xrange(13, 16) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 18
19 Registers class class Registers(object): def init (self): self._pointer = Pointer(16 * 2) def getitem (self, index): return internal_read_word(self._pointer, index * 2) def setitem (self, index, value): internal_write_word(self._pointer, index * 2, value) def len (self): return 16 def add (self, other): return self._pointer + other * 2 April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 19
20 Accessing registers like in C registers = Registers() # The unique/global registers data structure def registers_as_bytes_pointer(): return registers + 0 def pointer_to_byte_register(reg): return registers_as_bytes_pointer() + register_byte_index_to_offset[reg] #AL,CL,DL,BL,AH,CH,DH,BH register_byte_index_to_offset = 0, 2, 4, 6, 1, 3, 5, 7 def inc_reg(reg): inc_operand_16(registers + reg) registers[ax] April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 20
21 Registers public interface def read_register(reg): return registers[reg] def write_register(reg, value): # The 0xffff masking can be avoided in C registers[reg] = value & 0xffff def read_byte_register(reg): return pointer_to_byte_register(reg)[0] def write_byte_register(reg, value): # The 0xff masking can be avoided in C pointer_to_byte_register(reg)[0] = value & 0xff April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 21
22 The 8086 memory model Physical address = Segment * 16 + Offset Credits to Brock University: April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 22
23 Segments public interface def read_segment(segment): return read_register(segment + INTERNAL_ES) def write_segment(segment, value): write_register(segment + INTERNAL_ES, value) cache_segment(segment) and private! def cache_segment(segment): segments_addresses[segment] = memory + \ read_register(segment + INTERNAL_ES) * 16 April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 23
24 Pointer class part 1 class Pointer(object): def init (self, size=0, buffer=none, position=0): self._buffer = buffer or bytearray(size) self._position = position def getitem (self, address): return self._buffer[self._position + address] def setitem (self, address, value): self._buffer[self._position + address] = value def add (self, other): return Pointer(buffer=self._buffer, position=self._position + other) def sub (self, other): if isinstance(other, Pointer): return self._position - other._position else: return Pointer(buffer=self._buffer, position=self._position - other) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 24
25 Pointer class part 2 class Pointer(object): [ ] def iadd (self, other): self._position += other return self def isub (self, other): self._position -= other return self def int (self): return self._position April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 25
26 Memory data structures # 1MB + 128KB to protect the upper memory access memory = Pointer(( ) * 1024) # 64KB I/O space + 2 bytes to protect the upper I/O access ports = Pointer(64 * ) # Caches the linear address for every segment # The current instruction is cached as segment #6 == IP segments_addresses = [memory + 0 for i in xrange(8)] April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 26
27 Memory public interface def fill_memory(start_address, length, value): for address in xrange(start_address, start_address + length): memory[address] = value def read_byte(address): return memory[address] def write_byte(address, value): memory[address] = value def read_word(address): return internal_read_word(memory, address) def write_word(address, value): internal_write_word(memory, address, value) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 27
28 Accessing words (16-bits data) def internal_read_word(pointer, address): # WARNING: pointer + address are treated as a linear address, # so it can cross the 64KB segment limit, like return pointer[address] + (pointer[address + 1] << 8) def internal_write_word(pointer, address, value): # The 0xff masking can be avoided in C pointer[address] = value & 0xff # WARNING: 64KB segment cross # The 0xff masking can be avoided in C pointer[address + 1] = (value >> 8) & 0xff April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 28
29 Resetting the emulator CS=0xffff, IP=0x0000 -> first instruction at 0xffff0 def reset_8086(): for i in xrange(len(registers)): write_register(i, 0) write_register(internal_cs, 0xffff) write_register(internal_flags, 0xf002) for i in xrange(4): cache_segment(i) # For all four segments. See below segments_addresses[ip] = memory + read_register(internal_cs) * 16 ES, CS, SS, DS = xrange(4) TEMP_REG, IP, FLAGS = xrange(5, 8) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 29
30 8086 Instructions Instructions may be preceded by one or more prefixes: - LOCK - Data segment override (ES:, CS:, SS:, DS:) - String repeat (REP/REPE, REPNE) - WAIT (for FPU instructions) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 30
31 Instruction decoding & execution By design, LOCK and WAIT prefixes are ignored (NOPs) Segment and String prefixes must be stored Prefixes must be be cleared after execution Opcodes are grouped to simplify decoding and execution MOV to SS register should be atomic with next instruction April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 31
32 The main loop! def run_8086(): global running, segment_override, rep_prefix running = True segment_override = NO_SEGMENT_OVERRIDE rep_prefix = NO_REPEAT while running: macro_opcode, parameter = split_opcode[get_byte()] macro_opcode_execute[macro_opcode](parameter) NO_SEGMENT_OVERRIDE = 0 SEGMENT_OVERRIDE_ENABLED = 8 NO_REPEAT, REPEAT_ZERO, REPEAT_NOT_ZERO = xrange(3) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 32
33 (Macro)Grouping opcodes split_opcode = ( # 0x (BINARY_MEM_REG_8, ADD), (BINARY_MEM_REG_16, ADD), (BINARY_REG_MEM_8, ADD), (BINARY_REG_MEM_16, ADD), (BINARY_AL_IMM_8, ADD), (BINARY_AX_IMM_16, ADD), (PUSH_REG, INTERNAL_ES), (POP_SEG, ES), # 9x (XCHG_REG, (XCHG_REG, (XCHG_REG, (XCHG_REG, (XCHG_REG, (XCHG_REG, (XCHG_REG, (XCHG_REG, AX), # NOP! CX), DX), BX), SP), BP), SI), DI), (BINARY_MEM_REG_8, OR), (BINARY_MEM_REG_16, OR), (BINARY_REG_MEM_8, OR), (BINARY_REG_MEM_16, OR), (BINARY_AL_IMM_8, OR), (BINARY_AX_IMM_16, OR), (PUSH_REG, INTERNAL_CS), (POP_REG, INTERNAL_CS), # 1x (BINARY_MEM_REG_8, ADC), (BINARY_MEM_REG_16, ADC), (INSTRUCTION, CBW), (INSTRUCTION, CWD), (INSTRUCTION, CALL_FAR_IMM16_IMM16), (INSTRUCTION, WAIT), (INSTRUCTION, PUSHF), (INSTRUCTION, POPF), (INSTRUCTION, SAHF), (INSTRUCTION, LAHF), # Ax (INSTRUCTION_IMM_16, MOV_AL_FROM_DIRECT), (INSTRUCTION_IMM_16, MOV_AX_FROM_DIRECT), April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 33
34 Executing a (macro)instruction def add_16bit(source, target, result): global flags_first_operand, flags_second_operand, \ flags_result, flags_operation flags_first_operand = source flags_second_operand = target flags_result = source + target write_word_to_location(result, flags_result) flags_operation = FLAGS_ADD16 binary_16_execute = ( add_16bit, or_16bit, adc_16bit, sbb_16bit, and_16bit, sub_16bit, xor_16bit, cmp_16bit, mov_16bit, test_16bit, ) def binary_mem_reg_16(code): address, register_pointer = decode_modrm_16bit() binary_16_execute[code](read_word_from_location(address), read_word_from_location(register_pointer), address) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 34
35 The Mod/RM byte MOD REG R/M REG -> 8 or 16-bit register MOD 00 -> Memory, no displacement* 01 -> Memory, 8-bit displacement 10 -> Memory, 16-bit displacement 11 -> 8 or 16-bit register *MOD=00 -> R/M=[Direct Address] R/M 000 -> [SI+BX+Displacement] 001 -> [DI+BX+Displacement] 010 -> [SI+BP+Displacement] 011 -> [DI+BP+Displacement] 100 -> [SI+Displacement] 101 -> [DI+Displacement] 110 -> [BP+Displacement]* 111 -> [BX+Displacement] April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 35
36 Decoding the ModR/M def decode_modrm_16bit(): modrm = get_byte() rm = modrm & 7 mod_ = modrm >> 6 offset = modrm_offset[rm + segment_override]() address = modrm_address_16bit[mod_](offset, rm) reg = (modrm >> 3) & 7 register_pointer = registers + reg return address, register_pointer modrm_address_16bit = ( mod0_no_displacement, mod1_8bit_displacement, mod2_16bit_displacement, mod3_16bit_register, ) modrm_offset = ( rm0_bx_si_ds, rm1_bx_di_ds, rm2_bp_si_ss, rm3_bp_di_ss, rm4_si_ds, rm5_di_ds, rm6_bp_ss, rm7_bx_ds, rm0_bx_si, rm1_bx_di, rm2_bp_si, rm3_bp_di, rm4_si, rm5_di, rm6_bp, rm7_bx, ) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 36
37 The FLAGS register O D I T S Z 0 A 0 P 1 C O Overflow D Direction I Interrupt T Trace S Sign Z Zero A Auxiliary Carry P Parity C Carry 1 RESERVED Always 1 0 RESERVED Always 0 April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 37
38 Flags update Arithmetic operations usually update 6 flags (O, S, Z, A, P, C) Exceptions: INC/DEC don t update the Carry! Logical instructions update S, Z, P; clear O, C; A is undefined Rotates only updates O and C! Luckily, many times some flags are undefined Updating flags has a HUGE impact on performance! April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 38
39 Calculating flags: THE nightmare! def common_read_flags_8bit(auxiliar): global flags_operation flags_operation = FLAGS_NORMAL # The 0xff masking can be avoided in C result = flags_result & 0xff def read_auxiliary_add(): return ((flags_first_operand & 0x0f) + \ (flags_second_operand & 0x0f)) & \ AUXILIARY_MASK carry = (flags_result >> 8) & CARRY_MASK parity = parity_table[result & 0xff] zero = (result == 0) << ZERO_FLAG sign = result & SIGN_MASK overflow = ((flags_first_operand ^ flags_second_operand ^ result) << (OVERFLOW_FLAG - 7)) & OVERFLOW_MASK flags = (read_register(internal_flags) & (~(CARRY_MASK PARITY_MASK AUXILIARY_MASK ZERO_MASK SIGN_MASK OVERFLOW_MASK RESERVED3_MASK RESERVED5_MASK))) \ (carry parity auxiliar zero sign overflow) write_register(internal_flags, flags) return flags April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 39
40 A quantum approach to flags Operations do NOT calculate flags every time Operands, result, and rough operation saved Flags status collapses only when needed If few flags needed, calculate ONLY them! If more flags needed, full calculation made Rotates always calculate flags April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 40
41 An example: CMP + JNZ def cmp_16bit(source, target, result): global flags_first_operand, flags_second_operand, \ flags_result, flags_operation flags_first_operand = source flags_second_operand = target flags_result = source - target flags_operation = FLAGS_SUB16 jump_short_execute = ( cc_o, cc_no, cc_c, cc_nc, cc_z, cc_nz, cc_be, cc_nbe, [ ] def jump_short(jump_type): if jump_short_execute[jump_type](): [ ] def cc_nz(): return not read_zero_for_logical_from_operation[flags_operation]() read_zero_for_logical_from_operation = ( [ ] read_zero_for_logical_generic_16bit, def read_zero_for_logical_generic_16bit(): return not(flags_result & 0xffff) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 41
42 Testing the beast Unit test developed with regular code! One feature or opcode -> one or multiple tests written All public APIs tested as well Exercise as much scenarios as possible Tests makes it safer (enough!) to experiment Standard lib unittest module used (supported by PTVS) April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 42
43 Tests in action April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 43
44 Testing the final C version C 8086 emulator compiled as DLL DLL imported by Python wrapper (ctypes) Python callbacks provided to the DLL Tests transparently run with the regular test suite April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 44
45 The callbacks def set_on_disable_interrupts(handler): global on_disable_interrupts on_disable_interrupts = handler def set_on_enable_interrupts(handler): global on_enable_interrupts on_enable_interrupts = handler def set_on_byte_input(handler): global on_byte_input on_byte_input = handler def set_on_byte_output(handler): global on_byte_output on_byte_output = handler April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 45
46 What s missing Unary operations (NOT, NEG, shifts, etc.) String operations (REP MOVS, REP STOS, etc.) Tracing instructions (not needed; easy to implement) 8086 specific behaviors (too much effort; almost zero return) Much more tests coverage April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 46
47 Thanks to My family To stand me... April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 47
48 Q & A April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 48
Complete 8086 instruction set
Page 1 of 53 Complete 8086 instruction set Quick reference: AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD CLI CMC CMP CMPSB CMPSW CWD DAA DAS DEC DIV HLT IDIV IMUL IN INC INT INTO I JA JAE JB JBE JC JCXZ
More informationFaculty of Engineering Student Number:
Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, First Semester: 2012/2013 Course Title: Microprocessors Date: 17/01//2013 Course No:
More informationBCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example
BCD (ASCII) Arithmetic We will first look at unpacked BCD which means strings that look like '4567'. Bytes then look like 34h 35h 36h 37h OR: 04h 05h 06h 07h x86 processors also have instructions for packed
More informationComputer Organization and Architecture
Computer Organization and Architecture Chapter 11 Instruction Sets: Addressing Modes and Formats Instruction Set Design One goal of instruction set design is to minimize instruction length Another goal
More information8086 Microprocessor (cont..)
8086 Microprocessor (cont..) It is a 16 bit µp. 8086 has a 20 bit address bus can access upto 2 20 memory locations ( 1 MB). It can support upto 64K I/O ports. It provides 14, 16-bit registers. It has
More informationMachine Programming II: Instruc8ons
Machine Programming II: Instrucons Move instrucons, registers, and operands Complete addressing mode, address computaon (leal) Arithmec operaons (including some x6 6 instrucons) Condion codes Control,
More informationUnpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD
BCD (ASCII) Arithmetic The Intel Instruction set can handle both packed (two digits per byte) and unpacked BCD (one decimal digit per byte) We will first look at unpacked BCD Unpacked BCD can be either
More information8085 INSTRUCTION SET
DATA TRANSFER INSTRUCTIONS Opcode Operand Description 8085 INSTRUCTION SET INSTRUCTION DETAILS Copy from source to destination OV Rd, Rs This instruction copies the contents of the source, Rs register
More informationMICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS
MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS 1) Which is the microprocessor comprises: a. Register section b. One or more ALU c. Control unit 2) What is the store by register? a. data b. operands
More informationSystems Design & Programming Data Movement Instructions. Intel Assembly
Intel Assembly Data Movement Instruction: mov (covered already) push, pop lea (mov and offset) lds, les, lfs, lgs, lss movs, lods, stos ins, outs xchg, xlat lahf, sahf (not covered) in, out movsx, movzx
More informationCOMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ
COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 1 - INTRODUCTION JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ Unit 1.MaNoTaS 1 Definitions (I) Description A computer is: A
More informationThe 80x86 Instruction Set
Thi d t t d ith F M k 4 0 2 The 80x86 Instruction Set Chapter Six Until now, there has been little discussion of the instructions available on the 80x86 microprocessor. This chapter rectifies this situation.
More informationThe x86 PC: Assembly Language, Design, and Interfacing 5 th Edition
Online Instructor s Manual to accompany The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition Muhammad Ali Mazidi Janice Gillispie Mazidi Danny Causey Prentice Hall Boston Columbus Indianapolis
More informationPART B QUESTIONS AND ANSWERS UNIT I
PART B QUESTIONS AND ANSWERS UNIT I 1. Explain the architecture of 8085 microprocessor? Logic pin out of 8085 microprocessor Address bus: unidirectional bus, used as high order bus Data bus: bi-directional
More informationHow To Use A Computer With A Screen On It (For A Powerbook)
page 44,100 TITLE ASMXMPLE Video equ 10h ;video functions interrupt number Keyboard equ 16h ;keyboard functions interrupt number DOS equ 21h ;call DOS interrupt number PrtSc equ 5h ;Print Screen Bios interrupt
More informationCHAPTER 6 TASK MANAGEMENT
CHAPTER 6 TASK MANAGEMENT This chapter describes the IA-32 architecture s task management facilities. These facilities are only available when the processor is running in protected mode. 6.1. TASK MANAGEMENT
More informationOutline. Lecture 3. Basics. Logical vs. physical memory. 8086 physical memory. x86 byte ordering
Outline Lecture 3 bout Memory ddressing memory Data types MOV instruction ddressing modes Instruction format Dr. Dimitrios S. Nikolopoulos SL/UIU Basics Logical vs. physical memory Memory in the x processors
More informationLecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com
CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified)
More informationMICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1
MICROPROCESSOR A microprocessor incorporates the functions of a computer s central processing unit (CPU) on a single Integrated (IC), or at most a few integrated circuit. It is a multipurpose, programmable
More information150127-Microprocessor & Assembly Language
Chapter 3 Z80 Microprocessor Architecture The Z 80 is one of the most talented 8 bit microprocessors, and many microprocessor-based systems are designed around the Z80. The Z80 microprocessor needs an
More informationMouse Programming. 25.1 Mouse Interrupts. 25.2 Useful Mouse functions. 25.2.1 Mouselib.h. 25.2.2 Mouselib.c
25 Show respect for all people. Mouse Programming As everyone knows, mouse is one of the inputting devices. In this chapter, I explain interrupts for mouse programming and a few concepts regarding mouse
More informationAn Implementation Of Multiprocessor Linux
An Implementation Of Multiprocessor Linux This document describes the implementation of a simple SMP Linux kernel extension and how to use this to develop SMP Linux kernels for architectures other than
More informationInstruction Set Design
Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,
More informationIntroduction. What is an Operating System?
Introduction What is an Operating System? 1 What is an Operating System? 2 Why is an Operating System Needed? 3 How Did They Develop? Historical Approach Affect of Architecture 4 Efficient Utilization
More informationInterpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters
Interpreters and virtual machines Michel Schinz 2007 03 23 Interpreters Interpreters Why interpreters? An interpreter is a program that executes another program, represented as some kind of data-structure.
More informationMICROPROCESSOR AND MICROCOMPUTER BASICS
Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit
More informationChapter 7D The Java Virtual Machine
This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly
More informationZ80 Instruction Set. Z80 Assembly Language
75 Z80 Assembly Language The assembly language allows the user to write a program without concern for memory addresses or machine instruction formats. It uses symbolic addresses to identify memory locations
More informationInstruction Set Architecture
Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)
More informationPCI BIOS SPECIFICATION. Revision 2.1
PCI BIOS SPECIFICATION Revision 2.1 August 26, 1994 ii PCI BIOS Specification Revision 2.1 REVISION REVISION HISTORY DATE 1.0 Original issue distributed by Intel 9/28/92 2.0 Updated to be in synch with
More informationCentral Processing Unit (CPU)
Central Processing Unit (CPU) CPU is the heart and brain It interprets and executes machine level instructions Controls data transfer from/to Main Memory (MM) and CPU Detects any errors In the following
More informationELEC 377. Operating Systems. Week 1 Class 3
Operating Systems Week 1 Class 3 Last Class! Computer System Structure, Controllers! Interrupts & Traps! I/O structure and device queues.! Storage Structure & Caching! Hardware Protection! Dual Mode Operation
More informationCOS 318: Operating Systems
COS 318: Operating Systems OS Structures and System Calls Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall10/cos318/ Outline Protection mechanisms
More informationFlash Microcontroller. Memory Organization. Memory Organization
The information presented in this chapter is collected from the Microcontroller Architectural Overview, AT89C51, AT89LV51, AT89C52, AT89LV52, AT89C2051, and AT89C1051 data sheets of this book. The material
More informationAdapting the PowerPC 403 ROM Monitor Software for a 512Kb Flash Device
Adapting the PowerPC 403 ROM Monitor Software for a 512Kb Flash Device IBM Microelectronics Dept D95/Bldg 060 3039 Cornwallis Road Research Triangle Park, NC 27709 Version: 1 December 15, 1997 Abstract
More informationIntel 8086 architecture
Intel 8086 architecture Today we ll take a look at Intel s 8086, which is one of the oldest and yet most prevalent processor architectures around. We ll make many comparisons between the MIPS and 8086
More informationCloud Computing. Up until now
Cloud Computing Lecture 11 Virtualization 2011-2012 Up until now Introduction. Definition of Cloud Computing Grid Computing Content Distribution Networks Map Reduce Cycle-Sharing 1 Process Virtual Machines
More informationComputer Organization and Assembly Language
Computer Organization and Assembly Language Lecture 8 - Strings and Arrays Introduction We already know that assembly code will execute significantly faster than code written in a higher-level language
More informationAn Introduction to the ARM 7 Architecture
An Introduction to the ARM 7 Architecture Trevor Martin CEng, MIEE Technical Director This article gives an overview of the ARM 7 architecture and a description of its major features for a developer new
More informationIntroduction to Embedded Systems. Software Update Problem
Introduction to Embedded Systems CS/ECE 6780/5780 Al Davis logistics minor Today s topics: more software development issues 1 CS 5780 Software Update Problem Lab machines work let us know if they don t
More informationCPU Organization and Assembly Language
COS 140 Foundations of Computer Science School of Computing and Information Science University of Maine October 2, 2015 Outline 1 2 3 4 5 6 7 8 Homework and announcements Reading: Chapter 12 Homework:
More informationASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER
ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER Pierre A. von Kaenel Mathematics and Computer Science Department Skidmore College Saratoga Springs, NY 12866 (518) 580-5292 pvonk@skidmore.edu ABSTRACT This paper
More informationAdvanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2
Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of
More informationMS-DOS, PC-BIOS, and File I/O Chapter 13
Thi d t t d ith F M k 4 0 2 MS-DOS, PC-BIOS, and File I/O Chapter 13 A typical PC system consists of many component besides the 80x86 CPU and memory. MS-DOS and the PC s BIOS provide a software connection
More informationMACHINE ARCHITECTURE & LANGUAGE
in the name of God the compassionate, the merciful notes on MACHINE ARCHITECTURE & LANGUAGE compiled by Jumong Chap. 9 Microprocessor Fundamentals A system designer should consider a microprocessor-based
More informationIntel 64 and IA-32 Architectures Software Developer s Manual
Intel 64 and IA-32 Architectures Software Developer s Manual Volume 3A: System Programming Guide, Part 1 NOTE: The Intel 64 and IA-32 Architectures Software Developer's Manual consists of eight volumes:
More informationPCI-SIG ENGINEERING CHANGE REQUEST
PCI-SIG ENGINEERING CHANGE REQUEST TITLE: Update DMTF SM CLP Specification References DATE: 8/2009 AFFECTED DOCUMENT: PCIFW30_CLP_1_0_071906.pdf SPONSOR: Austin Bolen, Dell Inc. Part I 1. Summary of the
More informationIA-32 Intel Architecture Software Developer s Manual
IA-32 Intel Architecture Software Developer s Manual Volume 2B: Instruction Set Reference, N-Z NOTE: The IA-32 Intel Architecture Software Developer s Manual consists of four volumes: Basic Architecture,
More informationW4118: segmentation and paging. Instructor: Junfeng Yang
W4118: segmentation and paging Instructor: Junfeng Yang Outline Memory management goals Segmentation Paging TLB 1 Uni- v.s. multi-programming Simple uniprogramming with a single segment per process Uniprogramming
More informationExceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine
7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change
More informationDongwoo Kim : Hyeon-jeong Lee s Husband
2/ 32 Who we are Dongwoo Kim : Hyeon-jeong Lee s Husband Ph.D. Candidate at Chungnam National University in South Korea Majoring in Computer Communications & Security Interested in mobile hacking, digital
More informationPhoenix Technologies Ltd.
PC Division Desktop Product Line Subject: Standard BIOS 32-bit Service Directory Proposal Revision: 0.4 Revision Date: June 22, 1993 Document ID: Author: ATBIOS Thomas C. Block Origin Date: May 24, 1993
More informationOverview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX
Overview CISC Developments Over Twenty Years Classic CISC design: Digital VAX VAXÕs RISC successor: PRISM/Alpha IntelÕs ubiquitous 80x86 architecture Ð 8086 through the Pentium Pro (P6) RJS 2/3/97 Philosophy
More informationWriting a Simple Operating System from Scratch
Writing a Simple Operating System from Scratch i by Nick Blundell School of Computer Science, University of Birmingham, UK Draft: December 2, 2010 Copyright c 2009 2010 Nick Blundell Contents Contents
More information8. MACROS, Modules, and Mouse
8. MACROS, Modules, and Mouse Background Macros, Modules and the Mouse is a combination of concepts that will introduce you to modular programming while learning how to interface with the mouse. Macros
More informationHacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail
Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail All materials is licensed under a Creative Commons Share Alike license http://creativecommonsorg/licenses/by-sa/30/ # whoami Ali
More informationEmbedded x86 Programming: Protected Mode
by JEAN GAREAU Embedded x86 Programming: Protected Mode The x86 architecture is ubiquitous on the desktop and is spilling over into embedded systems environments. This article begins a series designed
More informationChapter 1 Computer System Overview
Operating Systems: Internals and Design Principles Chapter 1 Computer System Overview Eighth Edition By William Stallings Operating System Exploits the hardware resources of one or more processors Provides
More informationInstruction Set Architecture (ISA)
Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine
More information8051 hardware summary
8051 hardware summary 8051 block diagram 8051 pinouts + 5V ports port 0 port 1 port 2 port 3 : dual-purpose (general-purpose, external memory address and data) : dedicated (interfacing to external devices)
More informationVirtual machines and operating systems
V i r t u a l m a c h i n e s a n d o p e r a t i n g s y s t e m s Virtual machines and operating systems Krzysztof Lichota lichota@mimuw.edu.pl A g e n d a Virtual machines and operating systems interactions
More informationIntel Architecture Software Developer s Manual
Intel Architecture Software Developer s Manual Volume 1: Basic Architecture NOTE: The Intel Architecture Software Developer s Manual consists of three volumes: Basic Architecture, Order Number 243190;
More informationVESA BIOS Extension/Accelerator Functions (VBE/AF)
VBE/AF Standard Video Electronics Standards Association 860 Hillview Court, Suite 150 Phone: (408) 957-9270 Milpitas, CA 95035 FAX: (408) 957-9277 VESA BIOS Extension/Accelerator Functions (VBE/AF) Version:
More informationThe ARM Architecture. With a focus on v7a and Cortex-A8
The ARM Architecture With a focus on v7a and Cortex-A8 1 Agenda Introduction to ARM Ltd ARM Processors Overview ARM v7a Architecture/Programmers Model Cortex-A8 Memory Management Cortex-A8 Pipeline 2 ARM
More informationThe Java Virtual Machine and Mobile Devices. John Buford, Ph.D. buford@alum.mit.edu Oct 2003 Presented to Gordon College CS 311
The Java Virtual Machine and Mobile Devices John Buford, Ph.D. buford@alum.mit.edu Oct 2003 Presented to Gordon College CS 311 Objectives Review virtual machine concept Introduce stack machine architecture
More informationTHUMB Instruction Set
5 THUMB Instruction Set This chapter describes the THUMB instruction set. Format Summary 5-2 Opcode Summary 5-3 5. Format : move shifted register 5-5 5.2 Format 2: add/subtract 5-7 5.3 Format 3: move/compare/add/subtract
More informationIntel Vanderpool Technology for IA-32 Processors (VT-x) Preliminary Specification
Intel Vanderpool Technology for IA-32 Processors (VT-x) Preliminary Specification Order Number C97063-001 January 2005 THIS DOCUMENT AND RELATED MATERIALS AND INFORMATION ARE PROVIDED "AS IS" WITH NO WARRANTIES,
More informationb. A program calls malloc to request more memory from the operating system. i.what system call would malloc use to request more memory of the OS?
CS 4410 Operating Systems Prelim II, Fall 2013 Profs. Sirer and van Renesse Name: NETID: This is a closed book examination. It is 10 pages long. You have 120 minutes. No electronic devices of any kind
More informationPython, C++ and SWIG
Robin Dunn Software Craftsman O Reilly Open Source Convention July 21 25, 2008 Slides available at http://wxpython.org/oscon2008/ Python & C++ Comparisons Each is a general purpose programming language,
More informationException and Interrupt Handling in ARM
Exception and Interrupt Handling in ARM Architectures and Design Methods for Embedded Systems Summer Semester 2006 Author: Ahmed Fathy Mohammed Abdelrazek Advisor: Dominik Lücke Abstract We discuss exceptions
More informationTIn 1: Lecture 3: Lernziele. Lecture 3 The Belly of the Architect. Basic internal components of the 8086. Pointers and data storage in memory
Mitglied der Zürcher Fachhochschule TIn 1: Lecture 3 The Belly of the Architect. Lecture 3: Lernziele Basic internal components of the 8086 Pointers and data storage in memory Architektur 8086 Besteht
More informationENGG*44200 Real Time System Design Lab3 Implement VoIP on ARM Outline
ENGG*44200 Real Time System Design Lab3 Implement VoIP on ARM 1 Outline Features of VoIP IP Communication Device Examples Phone Protocol of the Lab 2 VoIP Voice Calls are transmitted over Packet Switched
More informationData Cables. Schmitt TTL LABORATORY ELECTRONICS II
Data Cables Data cables link one instrument to another. Signals can attenuate or disperse on long wires. A direct wire works best for short cables of less than 10 ft. A TTL cable connection can use a Schmitt
More informationCS352H: Computer Systems Architecture
CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline - Hazards October 1, 2009 University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell Data Hazards in ALU Instructions
More informationUsing Debug 1 INTRODUCING DEBUG
Using Debug Copyright Prentice-Hall Publishing, 1999. All rights reserved B.1 Introducing Debug B.2 Debug Command Summary Command Parameters B.3 Individual Commands? (Help) A (Assemble) C (Compare) D (Dump)
More informationAppendix C: Keyboard Scan Codes
Thi d t t d ith F M k 4 0 2 Appendix C: Keyboard Scan Codes Table 90: PC Keyboard Scan Codes (in hex) Key Down Up Key Down Up Key Down Up Key Down Up Esc 1 81 [ { 1A 9A, < 33 B3 center 4C CC 1! 2 82 ]
More informationADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory
ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory 1 1. Memory Organisation 2 Random access model A memory-, a data byte, or a word, or a double
More informationEECS 427 RISC PROCESSOR
RISC PROCESSOR ISA FOR EECS 427 PROCESSOR ImmHi/ ImmLo/ OP Code Rdest OP Code Ext Rsrc Mnemonic Operands 15-12 11-8 7-4 3-0 Notes (* is Baseline) ADD Rsrc, Rdest 0000 Rdest 0101 Rsrc * ADDI Imm, Rdest
More informationInstruction Set Architecture. or How to talk to computers if you aren t in Star Trek
Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture
More information1. Computer System Structure and Components
1 Computer System Structure and Components Computer System Layers Various Computer Programs OS System Calls (eg, fork, execv, write, etc) KERNEL/Behavior or CPU Device Drivers Device Controllers Devices
More informationReal-time Java Processor for Monitoring and Test
Real-time Java Processor for Monitoring and Test Martin Zabel, Thomas B. Preußer, Rainer G. Spallek Technische Universität Dresden {zabel,preusser,rgs}@ite.inf.tu-dresden.de Abstract This paper introduces
More informationHardware Assisted Virtualization
Hardware Assisted Virtualization G. Lettieri 21 Oct. 2015 1 Introduction In the hardware-assisted virtualization technique we try to execute the instructions of the target machine directly on the host
More informationUnderstanding a Simple Operating System
Understanding a Simple Operating System SOS is a Simple Operating System designed for the 32- bit x86 architecture. Its purpose is to understand basic concepts of operating system design. These notes are
More information5.14. EXCEPTION AND INTERRUPT REFERENCE
5.14. EXCEPTION AND INTERRUPT REFERENCE The following sections describe conditions which generate exceptions and interrupts. They are arranged in the order of vector numbers. The information contained
More informationApplication Note 195. ARM11 performance monitor unit. Document number: ARM DAI 195B Issued: 15th February, 2008 Copyright ARM Limited 2007
Application Note 195 ARM11 performance monitor unit Document number: ARM DAI 195B Issued: 15th February, 2008 Copyright ARM Limited 2007 Copyright 2007 ARM Limited. All rights reserved. Application Note
More informationA Choices Hypervisor on the ARM architecture
A Choices Hypervisor on the ARM architecture Rishi Bhardwaj, Phillip Reames, Russell Greenspan Vijay Srinivas Nori, Ercan Ucan ABSTRACT Choices is an object oriented operating system that runs on the x86
More informationSYSTEM ecos Embedded Configurable Operating System
BELONGS TO THE CYGNUS SOLUTIONS founded about 1989 initiative connected with an idea of free software ( commercial support for the free software ). Recently merged with RedHat. CYGNUS was also the original
More informationCOMPUTER HARDWARE. Input- Output and Communication Memory Systems
COMPUTER HARDWARE Input- Output and Communication Memory Systems Computer I/O I/O devices commonly found in Computer systems Keyboards Displays Printers Magnetic Drives Compact disk read only memory (CD-ROM)
More informationCentral Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis
Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis 1 1 Table of Contents 1 Table of Contents... 3 2 Overview... 5 3 Installation... 7 4 The CPU
More informationCS5460: Operating Systems
CS5460: Operating Systems Lecture 13: Memory Management (Chapter 8) Where are we? Basic OS structure, HW/SW interface, interrupts, scheduling Concurrency Memory management Storage management Other topics
More informationCOS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware
COS 318: Operating Systems I/O and Drivers Input and Output A computer s job is to process data Computation (, cache, and memory) Move data into and out of a system (between I/O devices and memory) Challenges
More information3. USB FLASH DRIVE PREPARATION. Almost all current PC firmware permits booting from a USB drive, allowing the launch
3. USB FLASH DRIVE PREPARATION 3.1 INTRODUCTION Almost all current PC firmware permits booting from a USB drive, allowing the launch of an operating system from a bootable flash drive. Such a configuration
More informationTech Tip: Understanding Server Memory Counters
Tech Tip: Understanding Server Memory Counters Written by Bill Bach, President of Goldstar Software Inc. This tech tip is the second in a series of tips designed to help you understand the way that your
More informationJorix kernel: real-time scheduling
Jorix kernel: real-time scheduling Joris Huizer Kwie Min Wong May 16, 2007 1 Introduction As a specialized part of the kernel, we implemented two real-time scheduling algorithms: RM (rate monotonic) and
More informationChapter 2 Array Configuration [SATA Setup Utility] This chapter explains array configurations using this array controller.
Embedded MegaRAID SATA User's Guide Areas Covered Before Reading This Manual This section explains the notes for your safety and conventions used in this manual. Chapter 1 Overview This chapter introduces
More informationVirtualization. Explain how today s virtualization movement is actually a reinvention
Virtualization Learning Objectives Explain how today s virtualization movement is actually a reinvention of the past. Explain how virtualization works. Discuss the technical challenges to virtualization.
More informationComputer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu.
Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu.tw Review Computers in mid 50 s Hardware was expensive
More informationOperating Systems. Virtual Memory
Operating Systems Virtual Memory Virtual Memory Topics. Memory Hierarchy. Why Virtual Memory. Virtual Memory Issues. Virtual Memory Solutions. Locality of Reference. Virtual Memory with Segmentation. Page
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code
More informationLecture 25 Symbian OS
CS 423 Operating Systems Design Lecture 25 Symbian OS Klara Nahrstedt Fall 2011 Based on slides from Andrew S. Tanenbaum textbook and other web-material (see acknowledgements) cs423 Fall 2011 1 Overview
More information