x86 and xv6 CS 450: Operating Systems Michael Saelee

Size: px
Start display at page:

Download "x86 and xv6 CS 450: Operating Systems Michael Saelee"

Transcription

1 x86 and xv6 CS 450: Operating Systems Michael Saelee

2 To work on an OS kernel, we must be intimately familiar with the underlying ISA, hardware, and system conventions - x86 ISA - C architecture - Unix, GCC, ELF, etc.

3 x86 ISA

4 - Intel IA-32 Software Developer s Manuals (linked on course website) are comprehensive references - Volume 1: Architectural Overview (e.g., regs, addressing) - Volume 2: Instruction Set Reference - Volume 3: Systems rogramming Guide (e.g., mechanisms that let operating system control/configure hardware) - (Majority of diagrams in slides are from these manuals)

5 x86 Family of ISAs - Started with Intel s bit CU in Followed by 80186, 80286, 80386, (then entium ) introduced 32-bit addressing ( IA-32 architecture) - CISC-style ISA - Large instruction set, complex addressing modes

6 Backwards Compatibility - x86 implies backwards compatibility all the way to All x86 CUs boot into 16-bit real address mode (aka real mode ) - Supported CUs can switch into 32-bit rotected Mode - i.e., we need to understand real mode to write an OS!

7 Instruction Set Overview - Arithmetic: add, sub, and, etc. - Moving data: mov, push, pop, etc. - Control flow: jmp, call, ret, etc. - I/O: in, out - rivileged: int, iret, hlt, etc.

8 Instruction formats: - 0 operands, e.g., ret - 1 operand, e.g., pushl %ebp - 2 operands O SRC, DST e.g., movl $0xa, %eax - Operands may be immediate values (constants), registers, memory addresses

9 NB: we ll be using AT&T syntax for x86 assembly - output by GCC/GAS - Constants are prefixed with $, Register names with % - Instruction suffixes (b=8-bit, w=16-bit, l=32-bit, etc.) used to indicate operand sizes - not the same as official Intel syntax! (output by NASM)

10 General-urpose Registers bit 32-bit AH AL AX EAX BH BL BX EBX CH CL CX ECX DH DL DX EDX B EB SI ESI DI EDI S ES Figure 3-5. Alternate General-urpose Register Names EAX Accumulator for operands and results data EBX ointer to data in the DS segment ECX Counter for string and loop operations EDX I/O pointer ESI ointer to data in the segment pointed to by the DS register; source pointer for string operations EDI ointer to data (or destination) in the segment pointed to by the ES register; destination pointer for string operations ES Stack pointer (in the SS segment) EB ointer to data on the stack (in the SS segment) As shown in Figure 3-5, the lower 16 bits of the general-purpose registers map directly to the register set found in

11 EFLAGS register used for conditional operations E.g., if last operation resulted in zero/nonzero/neg/etc..l0: movl $0, %eax for (i=0; i<10; i++); addl $1, %eax cmpl $10, %eax # 10-eax jne.l0 # jump if ZF 0

12 I D V I V I F A C V M R F 0 N T I O L O F D F I F T F S F Z F 0 A F 0 F 1 C F X ID Flag (ID) X Virtual Interrupt ending (VI) X Virtual Interrupt Flag (VIF) X Alignment Check / Access Control (AC) X Virtual-8086 Mode (VM) X Resume Flag (RF) X Nested Task (NT) X I/O rivilege Level (IOL) S Overflow Flag (OF) C Direction Flag (DF) X Interrupt Enable Flag (IF) X Trap Flag (TF) S Sign Flag (SF) S Zero Flag (ZF) S Auxiliary Carry Flag (AF) S arity Flag (F) S Carry Flag (CF) S Indicates a Status Flag C Indicates a Control Flag X Indicates a System Flag Reserved bit positions. DO NOT USE. Always set to values previously read. Figure 3-8. EFLAGS Register (only bottom 16-bits in real mode)

13 I (16-bit) / EI (32-bit) is instruction pointer register (C elsewhere) - always points to next instruction; automatically incremented - change explicitly with jump, call, ret, etc.

14 Addressing modes: - Direct: movl 0x401000, %eax eax = *(uint32_t *)(0x401000) - Indirect: movl (%ebx), %eax eax = *(uint32_t *)ebx

15 Addressing modes (continued): - Base-Displacement: movl 8(%ebx), %eax eax = *(uint32_t *)(ebx + 8) - Indexed & Scaled: movl (%ebx, %ecx, 4), %eax eax = *(uint32_t *)(ebx + ecx*4)

16 16-bit addressing modes: 32-bit addressing modes: (Courtesy WikiMedia Commons)

17 Real mode addressing has 16-bit registers, but 20-bit physical addresses - Use one of four 16-bit segment registers: CS, DS, SS, ES - Shift left by 4 bits (i.e., 16) to obtain a segment base address - Add to virtual address to obtain physical address

18 Real mode addressing - Code and Stack accesses using I, S, and B automatically use CS (code segment) and SS (stack segment) values - e.g., if I=0x4000 and CS=0x1100, CS:I refers to absolute address 0x x4000 = 0x Can be confusing and unwieldy (especially if data straddles segments)

19 rotected mode addressing - Full 32-bit addresses stored in registers - Segment registers (expanded to CS, DS, SS, ES, FS, GS, and still all 16-bit) no longer hold base addresses, but selectors - Selectors are used to load segment descriptors from a descriptor table which describe location/size/status/etc. of segments

20 Logical Address 15 0 Seg. Selector 31(63) Offset (Effective Address) 0 Descriptor Table Segment Descriptor Base Address + 31(63) Linear Address 0 Figure 3-5. Logical Address to Linear Address Translation

21 Segmentation - Recall: segmentation allows virtual addresses to be translated using segment base addresses - Segment descriptors also allow for access control (e.g., restricted access to certain segments) - Mapping from segmented to linear address can be simple/ flat or arbitrarily complex!

22 Segment Registers CS SS Code- and Data-Segment Descriptors Linear Address Space (or hysical Memory) Code Not resent FFFFFFFFH DS ES Access Limit Base Address Data and Stack 0 FS GS Figure 3-2. Flat Model

23 Segment Registers CS ES SS DS FS GS Segment Descriptors Access Limit Base Address Access Limit Base Address Linear Address Space (or hysical Memory) Code Not resent Memory I/O Data and Stack FFFFFFFFH 0 Figure 3-3. rotected Flat Model

24 Segment Registers CS SS DS ES FS GS Segment Descriptors Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Linear Address Space (or hysical Memory) Stack Code Data Data Data Data Figure 3-4. Multi-Segment Model

25 Segment Descriptor Tables - Kernel is responsible for maintaining descriptor tables on a system wide (via Global Descriptor Table) or task-specific (via Local Descriptor Table) basis - art of growing list of kernel data structures!

26 Index T I RL Table Indicator 0 = GDT 1 = LDT Requested rivilege Level (RL) Figure 3-6. Segment Selector Global Descriptor Table (GDT) Local Descriptor Table (LDT) T I Segment Selector TI = 0 56 TI = First Descriptor in GDT is Not Used GDTR Register LDTR Register Limit Base Address Limit Base Address Seg. Sel. Figure Global and Local Descriptor Tables

27 Base 31:24 G D / B Seg. A D L V Limit S Type Base 23:16 4 L 19:16 L Base Address 15:00 Segment Limit 15:00 0 L 64-bit code segment (IA-32e mode only) AVL Available for use by system software BASE Segment base address D/B Default operation size (0 = 16-bit segment; 1 = 32-bit segment) DL Descriptor privilege level G Granularity LIMIT Segment Limit Segment present S Descriptor type (0 = system; 1 = code or data) TYE Segment type Figure 3-8. Segment Descriptor

28 CS and CL - Bottom 2 bits of CS indicate the CL (current privilege level) - Recall: 0 = highest, 3 = lowest used to guard access to privileged/restricted instructions and memory - CS segment selector cannot be manipulated directly (why?) - Loaded from descriptor DL (when switching segments)

29 xv6 and Segmentation - xv6 mostly uses a flat model, so segmentation setup is simple - But segmentation descriptors are very similar to those used in interrupt descriptor tables (IDTs) - Used for carrying out interrupts and enforcing privilege level (CL) policies coming later

30 aging - Recall: paging allows for more granular mapping of linear address spaces onto physical memory - Fixed sized pages mapped from linear to physical address space - We will use support for 2-level paging for 32-bit addresses: - 1K page directory entries 1K page tables (each) - 4KB pages

31 Linear Address Directory Table Offset KByte age 10 age Directory 10 age Table hysical Address DE with S=0 20 TE CR3 Figure 4-2. Linear-Address Translation to a 4-KByte age using 32-Bit aging

32 Segmentation & aging - Segmentation is set up to provide a (mostly) flat model in xv6 - aging is used to do heavy lifting of virtual physical memory mapping - xv6 sets up paging structures on a per-process basis

33 Logical Address (or Far ointer) Segment Selector Offset Linear Address Space Global Descriptor Table (GDT) Linear Address Dir Table Offset hysical Address Space Segment Descriptor Segment Lin. Addr. age Directory age Table Entry age hy. Addr. Entry Segment Base Address age Segmentation aging Figure 3-1. Segmentation and aging

34 Address of page directory 1 Ignored C D W T Ignored CR3 Bits 31:22 of address of 4MB page frame Reserved (must be 0) Bits 39:32 of address 2 A T Ignored G 1 D A C D W T U / S R / W 1 DE: 4MB page Address of page table Ignored 0 I g n A C D W T U / S R DE: / W 1 page table Ignored 0 DE: not present Address of 4KB page frame Ignored G A T D A C D W T U / S R / W 1 TE: 4KB page Ignored 0 TE: not present NOTES: Figure 4-4. Formats of CR3 and aging-structure Entries with 32-Bit aging

35 Control & System Registers - Transitioning between real & protected mode, activating paging, switching descriptor tables, etc., are all governed by control & system register settings - Modifying these settings is restricted by CL

36 31(63) Reserved K E S M A S M E S M X E V M X E U M I C E G E M C E A E S E D E T S D V I V M E CR4 OSXSAVE FSGSBASE CIDE OSFXSR OSXMMEXCT 31(63) age-directory Base C D W T CR3 (DBR) 31(63) 0 age-fault Linear Address CR2 31(63) 0 CR G C D N W A M W N E E T T S E M M E CR0 Reserved Figure 2-7. Control Registers

37 31(63) Reserved K E S M A S M E OSXSAVE 31(63) S M X E V M X E U M I FSGSBASE CIDE C E G E M C E A E S E D E T S D OSFXSR OSXMMEXCT V I V M E CR4 Real-Address Mode Reset or E=1 E=0 Reset or RSM SMI# age-directory Base 31(63) 0 age-fault Linear Address C D W T CR3 (DBR) CR2 Reset rotected Mode SMI# RSM LME=1, CR0.G=1* SMI# System Management Mode 31(63) 0 CR1 VM=0 VM=1 See** IA-32e Mode RSM G C D N W Reserved A M W N E E T T S E M M E CR0 Virtual-8086 Mode SMI# RSM * See Section ** See Section Figure 2-7. Control Registers Figure 2-3. Transitions Among the rocessor s Operating Modes

38 .code16.globl start start: cli # Assemble for 16-bit mode # BIOS enabled interrupts; disable # Zero data segment registers DS, ES, and SS. xorw %ax,%ax # Set %ax to zero movw %ax,%ds # -> Data Segment... lgdt movl orl movl gdtdesc %cr0, %eax $CR0_E, %eax %eax, %cr0 # Complete transition to 32-bit protected mode by using long jmp # to reload %cs and %eip. The segment descriptors are set up with no # translation, so that the mapping is still the identity mapping. ljmp $(SEG_KCODE<<3), $start32.code32 # Tell assembler to generate 32-bit code now. start32: # Set up the protected-mode data segment registers movw $(SEG_KDATA<<3), %ax # Our data segment selector movw %ax, %ds # -> DS: Data Segment... # Set up the stack pointer and call into C. movl $start, %esp call bootmain xv6 bootstrap assembly

39 I/O - Two basic models for accessing I/O devices: - Separate I/O port address space from data address space - Memory-mapped I/O

40 I/O orts - Separated, limited address space - Special, privileged instructions (in/out) to explicitly read from /write to I/O ports - e.g., in $0x60, %al # get last typed # character (S/2 kbd)

41 Memory-mapped I/O - I/O controllers responsible for mapping ranges of physical addresses to I/O devices - Look like regular memory accesses - No special instructions! - Accessing these special addresses read/write I/O devices

42 I/O rotocols - Two basic protocols for interacting with I/O devices: - olling, aka rogrammed I/O (IO) - Interrupt-driven I/O

43 olling / rogrammed I/O - Software-driven, e.g., L0: inb STATUS_ORT, %al andb %al, BUSY_FLAG jne L0 # check if busy (e.g., still writing) movb (%esi,%ebx), %al incb %ebx # load data byte # increment index outb DATA_ORT, %al # write data byte to data port outb CONTROL_ORT, $0x01 # let device know to inspect data outb CONTROL_ORT, 0 jmp L0

44 olling / rogrammed I/O - CU must periodically probe hardware for status - to check if device is ready to be written to - to check if data is available to be read - to check for exceptional conditions

45 Interrupt-driven I/O - Device is responsible for notifying CU of event - CU might still initial request, but doesn t need to poll - Notification happens via hardware interrupt mechanism - Invokes interrupt handler (kernel routine)

46 ros/cons of olled vs. Interrupt-driven I/O?

47 ros/cons of olling - no additional hardware requirements - easy to program - if CU is idle, increase - places burden on CU problematic if heavy load - possibly unresponsive - even if no I/O is needed! utilization

48 ros/cons of Interrupt-driven - good for CU utilization - outsource responsibility - if no I/O needed, no CU activity at all! - requires hardware support (limited interrupts) - if frequent I/O, requires lots of context switches! - concurrency issues?

49 Interrupts & Exceptions - NB: terminology differs a bit from what we used in CS 351! - Encompass all events that request special CU attention, typically by transferring control from the active task to a special interrupt/exception handler

50 Interrupts - Hardware-sourced events requesting CU attention - Typically unrelated to executing instruction - Can also be generated by software with int N instruction

51 Exceptions - Errors/Events arising due to the currently executing instruction - Classes: - Faults - Traps - Aborts

52 Exception classes (review!) - Faults: can be corrected after handler, return to state prior to faulting instruction (e.g., page fault) - Traps: reported immediately after execution of instruction (e.g., debugging breakpoint, system call), regular return - Abort: severe errors; cannot return to task

53 Tasks - Must be some sort of context to be interrupted - TSS segment is used to define the currently executing task - General purpose registers - Control registers (including EFLAGS, EI, LDTR, etc.) - Stack pointers for different privilege levels

54 Code Segment Task-State Segment (TSS) Data Segment Stack Segment (Current riv. Level) Stack Seg. riv. Level 0 Stack Seg. riv. Level 1 Task Register CR3 Stack Segment (riv. Level 2) Figure 7-1. Structure of a Task

55 I/O Map Base Address Reserved T 100 Reserved LDT Segment Selector 96 Reserved GS 92 Reserved FS 88 Reserved DS 84 Reserved Reserved SS CS Reserved ES 72 EDI 68 ESI 64 EB 60 ES 56 EBX 52 EDX 48 ECX 44 EAX 40 EFLAGS 36 EI 32 CR3 (DBR) 28 Reserved SS2 24 ES2 20 Reserved SS1 16 ES1 12 Reserved SS0 8 ES0 4 Reserved revious Task Link 0 Reserved bits. Set to 0. Figure Bit Task-State Segment (TSS)

56 Handling Interrupts/Exceptions - Interrupt Descriptor Table (IDT) contains gate descriptors associating service routines with interrupt/exception numbers total indices (aka vector numbers): : architecture-defined : user-defined; can be assigned to I/O devices

57 47 IDTR Register IDT Base Address IDT Limit + Interrupt Descriptor Table (IDT) Gate for Interrupt #n (n 1) 8 Gate for Interrupt #3 Gate for Interrupt #2 Gate for Interrupt #1 Figure 6-1. Relationship of the IDTR and IDT

58 IDT Destination Code Segment Interrupt Vector Interrupt or Trap Gate Offset + Interrupt rocedure Segment Selector GDT or LDT Base Address Segment Descriptor Figure 6-3. Interrupt rocedure Call

59 Interrupt/Exception Vectors Vector Mnemonic Table 6-1. rotected-mode Exceptions and Interrupts Description Type Error Code Source 0 #DE Divide Error Fault No DIV and IDIV instructions. 1 #DB Debug Exception Fault/ Trap No Instruction, data, and I/O breakpoints; single-step; and others. 2 NMI Interrupt Interrupt No Nonmaskable external interrupt. 3 #B Breakpoint Trap No INT3 instruction. 4 #OF Overflow Trap No INTO instruction. 5 #BR BOUND Range Exceeded Fault No BOUND instruction. 6 #UD Invalid Opcode (Undefined Opcode) Fault No UD instruction or reserved opcode. 7 #NM Device Not Available (No Math Coprocessor) 8 #DF Double Fault Abort Yes (zero) 9 Coprocessor Segment Overrun (reserved) Fault No Floating-point or WAIT/FWAIT instruction. Any instruction that can generate an exception, an NMI, or an INTR. Fault No Floating-point instruction #TS Invalid TSS Fault Yes Task switch or TSS access. 11 #N Segment Not resent Fault Yes Loading segment registers or accessing system segments. 12 #SS Stack-Segment Fault Fault Yes Stack operations and SS register loads. 13 #G General rotection Fault Yes Any memory reference and other protection checks. 14 #F age Fault Fault Yes Any memory reference. 15 (Intel reserved. Do not use.) No 16 #MF x87 FU Floating-oint Error (Math Fault) 17 #AC Alignment Check Fault Yes (Zero) Fault No x87 FU floating-point or WAIT/FWAIT instruction. Any data reference in memory #MC Machine Check Abort No Error codes (if any) and source are model dependent #XM SIMD Floating-oint Exception Fault No SSE/SSE2/SSE3 floating-point instructions 4 20 #VE Virtualization Exception Fault No ET violations Intel reserved. Do not use User Defined (Non-reserved) Interrupts NOTES: Table 6-1. rotected-mode Exceptions and Interrupts (Contd.) Interrupt External interrupt or INT n instruction.

60 Gate Descriptors - Interrupts are associated with Interrupt Gates - Exceptions are associated with Trap Gates

61 Task Gate D L TSS Segment Selector 0 Interrupt Gate Offset D L 0 D Segment Selector Offset Trap Gate Offset D L 0 D Segment Selector Offset DL Offset Selector D Descriptor rivilege Level Offset to procedure entry point Segment resent flag Segment Selector for destination code segment Size of gate: 1 = 32 bits; 0 = 16 bits Reserved Figure 6-2. IDT Gate Descriptors

62 rivilege level checks - Hardware ensures that interrupts cannot transfer control from more-privileged to less-privileged code - i.e., enforce CL destination segment DL - For interrupts generated with int instruction, gate DL is checked to restrict interrupts - i.e., enforce CL gate DL

63 Masking Interrupts - Most external interrupts can be masked (i.e., ignored), by setting the IF (interrupt flag) in EFLAGS register - cli/sti instructions: clear/set interrupt flag - IF is automatically cleared when an interrupt (but not a trap) gate is taken - How is this useful?

64 Interrupt rocedure When the processor performs a call to the exception- or interrupt-handler procedure: If the handler procedure is going to be executed at a numerically lower privilege level, a stack switch occurs. When the stack switch occurs: a. The segment selector and stack pointer for the stack to be used by the handler are obtained from the TSS for the currently executing task. On this new stack, the processor pushes the stack segment selector and stack pointer of the interrupted procedure. b. The processor then saves the current state of the EFLAGS, CS, and EI registers on the new stack (see Figures 6-4). c. If an exception causes an error code to be saved, it is pushed on the new stack after the EI value. If the handler procedure is going to be executed at the same privilege level as the interrupted procedure: a. The processor saves the current state of the EFLAGS, CS, and EI registers on the current stack (see Figures 6-4). b. If an exception causes an error code to be saved, it is pushed on the current stack after the EI value.

65 Interrupted rocedure s and Handler s Stack Stack Usage with No rivilege-level Change EFLAGS CS EI Error Code ES Before Transfer to Handler ES After Transfer to Handler Interrupted rocedure s Stack Stack Usage with rivilege-level Change ES Before Transfer to Handler ES After Transfer to Handler Handler s Stack SS ES EFLAGS CS EI Error Code Figure 6-4. Stack Usage on Transfers to Interrupt and Exception-Handling Routines

66 Returning from interrupt - Need to restore previous stack/register states, and potentially return to previous privileged level (switch stacks) - iret instruction automatically restores state using values saved on stack (including EI, CS, EFLAGS) by interrupt procedure

67 EFLAGS Register Control Registers CR4 CR3 CR2 CR1 CR0 Task Register hysical Address Linear Address Segment Selector Register Global Descriptor Table (GDT) Task-State Segment (TSS) Code, Data or Stack Segment Task Code Data Stack Interrupt Vector IDTR Interrupt Descriptor Table (IDT) Interrupt Gate Task Gate Trap Gate XCR0 (XFEM) Segment Sel. TSS Seg. Sel. Call-Gate Segment Selector GDTR LDTR Seg. Desc. TSS Desc. Seg. Desc. TSS Desc. LDT Desc. Local Descriptor Table (LDT) Seg. Desc. Call Gate Current TSS Task-State Segment (TSS) Current TSS Interrupt Handler Code Stack Task Code Data Stack Exception Handler Code Stack rotected rocedure Code Current TSS Stack Linear Address Space Linear Address Dir Table Offset Linear Addr. age Directory age Table age g. Dir. Entry g. Tbl. Entry hysical Addr. 0 CR3* *hysical Address This page mapping example is for 4-KByte pages and the normal 32-bit physical address size. Figure 2-1. IA-32 System-Level Registers and Data Structures

68 C Architecture

69 What else? - Memory + memory layout - ersistent store (disk) - Text/graphics display - Keyboard/Mouse + other I/O devices and controllers - BIOS, Clock

70 0xFFFFFFFF (4GB) rotected mode memorymapped devices hysical memory map Unused Extended memory BIOS ROM Real-mode devices VGA display Low memory hysical RAM limit 0x (1MB) 0x000F0000 (960KB) 0x000C0000 (768KB) 0x000A0000 (640KB) 0x

71 Startup & BIOS - On startup, transfer control to address FFFF:0000 (real mode) - BIOS executes power on self test, initializes video card, disk controller, and sets up basic interrupt routines for simple I/O - If boot drive is found, load boot sector (512 bytes, tagged with ending 0x55AA marker) from drive at address 0000:7C00

72 Bootloader Responsibilities - Set up minimal execution environment (stack, protected mode) - Scans disk for kernel image (may load second-stage bootloader to navigate partitions, file system, executable formats, etc.) - Load kernel image at predetermined location in memory - Transfer control to kernel

73 On Bootloaders - Bootloaders can get very complicated! - E.g., multistage boot loaders like Linux Loader (LILO) and Grand Unified Bootloader (GRUB) understand file systems and executable file formats - Also have scripting support and built-in shells

74 QEMU

75 Full System Emulator - Emulates the behavior of a real x86 C in software - Simulates physical memory map and I/O devices - Supports up to 255 CUs (speed dependent on host machine) - Simple to debug, and won t break your actual OS! - Can connect to GDB to step through instructions

76 The QEMU C System emulator simulates the following peripherals: - i440fx host CI bridge and IIX3 CI to ISA bridge - Cirrus CLGD 5446 CI VGA card or dummy VGA card with Bochs VESA extensions (hardware level, including all non standard modes). - S/2 mouse and keyboard - 2 CI IDE interfaces with hard disk and CD-ROM support - Floppy disk - CI and ISA network adapters - Serial ports - IMI BMC, either and internal or external one - Creative SoundBlaster 16 sound card - ENSONIQ AudioCI ES1370 sound card - Intel 82801AA AC97 Audio compatible sound card - Intel HD Audio Controller and HDA codec - Adlib (OL2) - Yamaha YM3812 compatible chip - Gravis Ultrasound GF1 sound card - CS4231A compatible sound card - CI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1 hub. SM is supported with up to 255 CUs. QEMU uses the C BIOS from the Seabios project and the lex86/bochs LGL VGA BIOS.

77 Demo

IA32 Intel 32-bit Architecture

IA32 Intel 32-bit Architecture 1 2 IA32 Intel 32-bit Architecture Intel 32-bit Architecture (IA32) 32-bit machine CISC: 32-bit internal and external data bus 32-bit external address bus 8086 general registers extended to 32 bit width

More information

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II) MICROPROCESSOR UOP S.E.COMP (SEM-II) 80386 MICROPROCESSOR ARCHITECTURE Prof. P. C. Patil Department of Computer Engg Sandip Institute of Engineering & Management Nashik pc.patil@siem.org.in 1 Introduction

More information

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II) MICROPROCESSOR UOP S.E.COMP (SEM-II) 80386 MICROPROCESSOR ARCHITECTURE Prof. P. C. Patil Department of Computer Engg Sandip Institute of Engineering & Management Nashik pc.patil@siem.org.in 1 Introduction

More information

Basic Execution Environment

Basic Execution Environment Basic Execution Environment 3 CHAPTER 3 BASIC EXECUTION ENVIRONMENT This chapter describes the basic execution environment of an Intel Architecture processor as seen by assembly-language programmers.

More information

iapx Systems Electronic Computers M

iapx Systems Electronic Computers M iapx Systems Electronic Computers M 1 iapx History We analyze 32 bit systems: generalization to 64 bits is straigtforward Segment Registers (16 bits) Code Segment Stack Segment Data Segment Extra Ssegment

More information

x86 Assembly Tutorial COS 318: Fall 2017

x86 Assembly Tutorial COS 318: Fall 2017 x86 Assembly Tutorial COS 318: Fall 2017 Project 1 Schedule Design Review: Monday 9/25 Sign up for 10-min slot from 3:00pm to 7:00pm Complete set up and answer posted questions (Official) Precept: Monday

More information

CHAPTER 6 INTERRUPT AND EXCEPTION HANDLING

CHAPTER 6 INTERRUPT AND EXCEPTION HANDLING CHATER 6 INTERRUT AND EXCETION HANDLING This chapter describes the interrupt and exception-handling mechanism when operating in protected mode on an I ntel 64 or I A-32 processor. Most of the information

More information

Introduction to IA-32. Jo, Heeseung

Introduction to IA-32. Jo, Heeseung Introduction to IA-32 Jo, Heeseung IA-32 Processors Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer

More information

INTRODUCTION TO IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung INTRODUCTION TO IA-32 Jo, Heeseung IA-32 PROCESSORS Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer

More information

Assembler Programming. Lecture 2

Assembler Programming. Lecture 2 Assembler Programming Lecture 2 Lecture 2 8086 family architecture. From 8086 to Pentium4. Registers, flags, memory organization. Logical, physical, effective address. Addressing modes. Processor Processor

More information

x86 architecture et similia

x86 architecture et similia x86 architecture et similia 1 FREELY INSPIRED FROM CLASS 6.828, MIT A full PC has: PC architecture 2 an x86 CPU with registers, execution unit, and memory management CPU chip pins include address and data

More information

W4118: PC Hardware and x86. Junfeng Yang

W4118: PC Hardware and x86. Junfeng Yang W4118: PC Hardware and x86 Junfeng Yang A PC How to make it do something useful? 2 Outline PC organization x86 instruction set gcc calling conventions PC emulation 3 PC board 4 PC organization One or more

More information

Mechanisms for entering the system

Mechanisms for entering the system Mechanisms for entering the system Yolanda Becerra Fontal Juan José Costa Prats Facultat d'informàtica de Barcelona (FIB) Universitat Politècnica de Catalunya (UPC) BarcelonaTech 2017-2018 QP Content Introduction

More information

The Microprocessor and its Architecture

The Microprocessor and its Architecture The Microprocessor and its Architecture Contents Internal architecture of the Microprocessor: The programmer s model, i.e. The registers model The processor model (organization) Real mode memory addressing

More information

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998 Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998 Assembler Syntax Everything looks like this: label: instruction dest,src instruction label Comments: comment $ This is a comment

More information

Complex Instruction Set Computer (CISC)

Complex Instruction Set Computer (CISC) Introduction ti to IA-32 IA-32 Processors Evolutionary design Starting in 1978 with 886 Added more features as time goes on Still support old features, although obsolete Totally dominate computer market

More information

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86 Lecture 15 Intel Manual, Vol. 1, Chapter 3 Hampden-Sydney College Fri, Mar 6, 2009 Outline 1 2 Overview See the reference IA-32 Intel Software Developer s Manual Volume 1: Basic, Chapter 3. Instructions

More information

6/17/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

6/17/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to: Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Introduction This chapter presents the microprocessor

More information

CS3210: Booting and x86. Taesoo Kim

CS3210: Booting and x86. Taesoo Kim 1 CS3210: Booting and x86 Taesoo Kim 2 What is an operating system? e.g. OSX, Windows, Linux, FreeBSD, etc. What does an OS do for you? Abstract the hardware for convenience and portability Multiplex the

More information

CS3210: Booting and x86

CS3210: Booting and x86 CS3210: Booting and x86 Lecture 2 Instructor: Dr. Tim Andersen 1 / 34 Today: Bootstrapping CPU -> needs a first instruction Memory -> needs initial code/data I/O -> needs to know how to communicate 2 /

More information

Chapter 2: The Microprocessor and its Architecture

Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Introduction This chapter presents the microprocessor

More information

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM EXPERIMENT WRITE UP AIM: Assembly language program for 16 bit BCD addition LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM TOOLS/SOFTWARE

More information

Computer Organization (II) IA-32 Processor Architecture. Pu-Jen Cheng

Computer Organization (II) IA-32 Processor Architecture. Pu-Jen Cheng Computer Organization & Assembly Languages Computer Organization (II) IA-32 Processor Architecture Pu-Jen Cheng Materials Some materials used in this course are adapted from The slides prepared by Kip

More information

Microkernel Construction

Microkernel Construction Kernel Entry / Exit SS2013 Control Transfer Microkernel User Stack A Address Space Kernel Stack A User Stack User Stack B Address Space Kernel Stack B User Stack 1. Kernel Entry (A) 2. Thread Switch (A

More information

MICROPROCESSOR ALL IN ONE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

MICROPROCESSOR ALL IN ONE. Prof. P. C. Patil UOP S.E.COMP (SEM-II) MICROPROCESSOR UOP S.E.COMP (SEM-II) 80386 ALL IN ONE Prof. P. C. Patil Department of Computer Engg Sandip Institute of Engineering & Management Nashik pc.patil@siem.org.in 1 Architecture of 80386 2 ARCHITECTURE

More information

Microkernel Construction

Microkernel Construction Microkernel Construction Kernel Entry / Exit Nils Asmussen 05/04/2017 1 / 45 Outline x86 Details Protection Facilities Interrupts and Exceptions Instructions for Entry/Exit Entering NOVA Leaving NOVA 2

More information

IA32/Linux Virtual Memory Architecture

IA32/Linux Virtual Memory Architecture IA32/Linux Virtual Memory Architecture Basic Execution Environment Application Programming Registers General-purpose registers 31 0 EAX AH AL EBX BH BL ECX CH CL EDX DH DL EBP ESI EDI BP SI DI Segment

More information

The x86 Architecture

The x86 Architecture The x86 Architecture Lecture 24 Intel Manual, Vol. 1, Chapter 3 Robb T. Koether Hampden-Sydney College Fri, Mar 20, 2015 Robb T. Koether (Hampden-Sydney College) The x86 Architecture Fri, Mar 20, 2015

More information

Project 1: Bootloader. COS 318 Fall 2015

Project 1: Bootloader. COS 318 Fall 2015 Project 1: Bootloader COS 318 Fall 2015 Project 1: Schedule Design Review - Monday, 9/28-10- min Ime slots from 1:30pm- 6:20pm - Write funcions print_char and print_string! - Answer the quesions: ü How

More information

Buffer Overflow Attack

Buffer Overflow Attack Buffer Overflow Attack What every applicant for the hacker should know about the foundation of buffer overflow attacks By (Dalgona@wowhacker.org) Email: zinwon@gmail.com 2005 9 5 Abstract Buffer overflow.

More information

BOOTSTRAP, PC BIOS, AND IA32 MEMORY MODES. CS124 Operating Systems Winter , Lecture 5

BOOTSTRAP, PC BIOS, AND IA32 MEMORY MODES. CS124 Operating Systems Winter , Lecture 5 BOOTSTRAP, PC BIOS, AND IA32 MEMORY MODES CS124 Operating Systems Winter 2015-2016, Lecture 5 2 Bootstrapping All computers have the same basic issue: They require a program to tell them what to do but

More information

Hardware and Software Architecture. Chapter 2

Hardware and Software Architecture. Chapter 2 Hardware and Software Architecture Chapter 2 1 Basic Components The x86 processor communicates with main memory and I/O devices via buses Data bus for transferring data Address bus for the address of a

More information

Machine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Machine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Machine-level Representation of Programs Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Program? 짬뽕라면 준비시간 :10 분, 조리시간 :10 분 재료라면 1개, 스프 1봉지, 오징어

More information

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017 CS 31: Intro to Systems ISAs and Assembly Martin Gagné Swarthmore College February 7, 2017 ANNOUNCEMENT All labs will meet in SCI 252 (the robot lab) tomorrow. Overview How to directly interact with hardware

More information

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam Assembly Language Lecture 2 - x86 Processor Architecture Ahmed Sallam Introduction to the course Outcomes of Lecture 1 Always check the course website Don t forget the deadline rule!! Motivations for studying

More information

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP. Procedures: CALL: Pushes the address of the instruction following the CALL instruction onto the stack. RET: Pops the address. SUM PROC NEAR USES BX CX DX ADD AX, BX ADD AX, CX MOV AX, DX RET SUM ENDP NEAR

More information

Tutorial 10 Protection Cont.

Tutorial 10 Protection Cont. Tutorial 0 Protection Cont. 2 Privilege Levels Lower number => higher privilege Code can access data of equal/lower privilege levels only Code can call more privileged data via call gates Each level has

More information

Module 3 Instruction Set Architecture (ISA)

Module 3 Instruction Set Architecture (ISA) Module 3 Instruction Set Architecture (ISA) I S A L E V E L E L E M E N T S O F I N S T R U C T I O N S I N S T R U C T I O N S T Y P E S N U M B E R O F A D D R E S S E S R E G I S T E R S T Y P E S O

More information

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee ١ INTERNAL MICROPROCESSOR ARCHITECTURE Before a program is written or instruction investigated, internal configuration of the

More information

PROTECTION CHAPTER 4 PROTECTION

PROTECTION CHAPTER 4 PROTECTION Protection 4 CHAPTER 4 PROTECTION In protected mode, the Intel Architecture provides a protection mechanism that operates at both the segment level and the page level. This protection mechanism provides

More information

Assembly Language. Lecture 2 x86 Processor Architecture

Assembly Language. Lecture 2 x86 Processor Architecture Assembly Language Lecture 2 x86 Processor Architecture Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Introduction to the course Outcomes of Lecture 1 Always check the course

More information

The Pentium Processor

The Pentium Processor The Pentium Processor Chapter 7 S. Dandamudi Outline Pentium family history Pentium processor details Pentium registers Data Pointer and index Control Segment Real mode memory architecture Protected mode

More information

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,... COMPUTER ARCHITECTURE II: MICROPROCESSOR PROGRAMMING We can study computer architectures by starting with the basic building blocks Transistors and logic gates To build more complex circuits Adders, decoders,

More information

Unit 08 Advanced Microprocessor

Unit 08 Advanced Microprocessor Unit 08 Advanced Microprocessor 1. Features of 80386 The 80386 microprocessor is an enhanced version of the 80286 microprocessor Memory-management unit is enhanced to provide memory paging. The 80386 also

More information

Code segment Stack segment

Code segment Stack segment Registers Most of the registers contain data/instruction offsets within 64 KB memory segment. There are four different 64 KB segments for instructions, stack, data and extra data. To specify where in 1

More information

3.6. PAGING (VIRTUAL MEMORY) OVERVIEW

3.6. PAGING (VIRTUAL MEMORY) OVERVIEW an eight-byte boundary to yield the best processor performance. The limit value for the GDT is expressed in bytes. As with segments, the limit value is added to the base address to get the address of the

More information

The Instruction Set. Chapter 5

The Instruction Set. Chapter 5 The Instruction Set Architecture Level(ISA) Chapter 5 1 ISA Level The ISA level l is the interface between the compilers and the hardware. (ISA level code is what a compiler outputs) 2 Memory Models An

More information

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016 CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College February 9, 2016 Reading Quiz Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between

More information

EEM336 Microprocessors I. The Microprocessor and Its Architecture

EEM336 Microprocessors I. The Microprocessor and Its Architecture EEM336 Microprocessors I The Microprocessor and Its Architecture Introduction This chapter presents the microprocessor as a programmable device by first looking at its internal programming model and then

More information

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018 CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College September 25, 2018 Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between programmer

More information

2.5 Address Space. The IBM 6x86 CPU can directly address 64 KBytes of I/O space and 4 GBytes of physical memory (Figure 2-24).

2.5 Address Space. The IBM 6x86 CPU can directly address 64 KBytes of I/O space and 4 GBytes of physical memory (Figure 2-24). Address Space 2.5 Address Space The IBM 6x86 CPU can directly address 64 KBytes of I/O space and 4 GBytes of physical memory (Figure 2-24). Memory Address Space. Access can be made to memory addresses

More information

Basic Information. CS318 Project #1. OS Bootup Process. Reboot. Bootup Mechanism

Basic Information. CS318 Project #1. OS Bootup Process. Reboot. Bootup Mechanism Basic Information CS318 Project #1 Bootup Mechanism Lab is in 010 Friend Center Use your OIT username/password If you get the error unable to mount /u/username contact me, (most student should have it

More information

143A: Principles of Operating Systems. Lecture 7: System boot. Anton Burtsev January, 2017

143A: Principles of Operating Systems. Lecture 7: System boot. Anton Burtsev January, 2017 143A: Principles of Operating Systems Lecture 7: System boot Anton Burtsev January, 2017 Bootloader starts Bootloader starts 9111 start: 9112 cli # BIOS enabled interrupts; disable 9113 9114 # Zero data

More information

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1 Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD 21252 rkarne@towson.edu 11/12/2014 Slide 1 Intel x86 Aseembly Language Assembly Language Assembly Language

More information

IA-32 Architecture COE 205. Computer Organization and Assembly Language. Computer Engineering Department

IA-32 Architecture COE 205. Computer Organization and Assembly Language. Computer Engineering Department IA-32 Architecture COE 205 Computer Organization and Assembly Language Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Basic Computer Organization Intel

More information

SYSC3601 Microprocessor Systems. Unit 2: The Intel 8086 Architecture and Programming Model

SYSC3601 Microprocessor Systems. Unit 2: The Intel 8086 Architecture and Programming Model SYSC3601 Microprocessor Systems Unit 2: The Intel 8086 Architecture and Programming Model Topics/Reading SYSC3601 2 Microprocessor Systems 1. Registers and internal architecture (Ch 2) 2. Address generation

More information

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013) SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013) UNIT I THE 8086 MICROPROCESSOR PART A (2 MARKS) 1. What are the functional

More information

CS241 Computer Organization Spring 2015 IA

CS241 Computer Organization Spring 2015 IA CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,

More information

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University COS 318: Operating Systems Overview Prof. Margaret Martonosi Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall11/cos318/ Announcements Precepts: Tue (Tonight)!

More information

Addressing Modes on the x86

Addressing Modes on the x86 Addressing Modes on the x86 register addressing mode mov ax, ax, mov ax, bx mov ax, cx mov ax, dx constant addressing mode mov ax, 25 mov bx, 195 mov cx, 2056 mov dx, 1000 accessing data in memory There

More information

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics Moodle 4 WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics Advanced Microprocessors and Introduction to Microcontroller Moodle developed By Dr. S. R. Kumbhar Department of Electronics Willingdon

More information

Protection and System Calls. Otto J. Anshus

Protection and System Calls. Otto J. Anshus Protection and System Calls Otto J. Anshus Protection Issues CPU protection Prevent a user from using the CPU for too long Throughput of jobs, and response time to events (incl. user interactive response

More information

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź Low Level Programming Lecture 2 Intel processors' architecture reminder Fig. 1. IA32 Registers IA general purpose registers EAX- accumulator, usually used to store results of integer arithmetical or binary

More information

CHAPTER 3 BASIC EXECUTION ENVIRONMENT

CHAPTER 3 BASIC EXECUTION ENVIRONMENT CHAPTER 3 BASIC EXECUTION ENVIRONMENT This chapter describes the basic execution environment of an Intel 64 or I A-32 processor as seen by assemblylanguage programmers. It describes how the processor executes

More information

Exceptions. user mode. software should run in supervisor mode Certain features/privileges il are only allowed to code running in supervisor mode

Exceptions. user mode. software should run in supervisor mode Certain features/privileges il are only allowed to code running in supervisor mode Status Register EE 357 Unit 9 Exceptions Used for debugging; when set, it can be used to pause the CPU after execution of each instruction Coldfirecan run programs in two modes: supervisor mode (for OS

More information

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY BACKGROUND 8086 CPU has 8 general purpose registers listed below: AX - the accumulator register (divided into AH / AL): 1. Generates shortest machine code 2. Arithmetic, logic and data transfer 3. One

More information

+ Overview. Projects: Developing an OS Kernel for x86. ! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT)

+ Overview. Projects: Developing an OS Kernel for x86. ! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT) + Projects: Developing an OS Kernel for x86 Low-Level x86 Programming: Exceptions, Interrupts, and Timers + Overview! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT)! Handling

More information

Assembly Language for Intel-Based Computers, 4 th Edition. Kip R. Irvine. Chapter 2: IA-32 Processor Architecture

Assembly Language for Intel-Based Computers, 4 th Edition. Kip R. Irvine. Chapter 2: IA-32 Processor Architecture Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Chapter Overview General Concepts IA-32 Processor Architecture IA-32 Memory Management Components

More information

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher Reverse Engineering II: Basics Gergely Erdélyi Senior Antivirus Researcher Agenda Very basics Intel x86 crash course Basics of C Binary Numbers Binary Numbers 1 Binary Numbers 1 0 1 1 Binary Numbers 1

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013 TOPICS TODAY I/O Architectures Interrupts Exceptions FETCH EXECUTE CYCLE 1.7 The von Neumann Model This is a general

More information

Come and join us at WebLyceum

Come and join us at WebLyceum Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad

More information

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture. Chapter Overview.

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture. Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Slides prepared by Kip R. Irvine Revision date: 09/25/2002 Chapter corrections (Web) Printing

More information

CS 16: Assembly Language Programming for the IBM PC and Compatibles

CS 16: Assembly Language Programming for the IBM PC and Compatibles CS 16: Assembly Language Programming for the IBM PC and Compatibles Discuss the general concepts Look at IA-32 processor architecture and memory management Dive into 64-bit processors Explore the components

More information

CMSC Lecture 03. UMBC, CMSC313, Richard Chang

CMSC Lecture 03. UMBC, CMSC313, Richard Chang CMSC Lecture 03 Moore s Law Evolution of the Pentium Chip IA-32 Basic Execution Environment IA-32 General Purpose Registers Hello World in Linux Assembly Language Addressing Modes UMBC, CMSC313, Richard

More information

143A: Principles of Operating Systems. Lecture 7: System boot. Anton Burtsev October, 2017

143A: Principles of Operating Systems. Lecture 7: System boot. Anton Burtsev October, 2017 143A: Principles of Operating Systems Lecture 7: System boot Anton Burtsev October, 2017 Outline for today Boot operating system Setup segments (data and code) Switch to protected mode Load GDT (turn segmentation

More information

Reverse Engineering II: The Basics

Reverse Engineering II: The Basics Reverse Engineering II: The Basics Gergely Erdélyi Senior Manager, Anti-malware Research Protecting the irreplaceable f-secure.com Binary Numbers 1 0 1 1 - Nibble B 1 0 1 1 1 1 0 1 - Byte B D 1 0 1 1 1

More information

Introduction to The x86 Microprocessor

Introduction to The x86 Microprocessor Introduction to The x86 Microprocessor Prof. V. Kamakoti Digital Circuits And VLSI Laboratory Indian Institute of Technology, Madras Chennai - 600 036. http://vlsi.cs.iitm.ernet.in Protected Mode Memory

More information

Credits and Disclaimers

Credits and Disclaimers Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 2 nd Edition by Bryant and O'Hallaron

More information

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017 ICS143A: Principles of Operating Systems Midterm recap, sample questions Anton Burtsev February, 2017 Describe the x86 address translation pipeline (draw figure), explain stages. Address translation What

More information

BASIC INTERRUPT PROCESSING

BASIC INTERRUPT PROCESSING Interrupts BASIC INTERRUPT PROCESSING This section discusses the function of an interrupt in a microprocessor-based system. Structure and features of interrupts available to Intel microprocessors. The

More information

238P: Operating Systems. Lecture 7: System boot. Anton Burtsev January, 2017

238P: Operating Systems. Lecture 7: System boot. Anton Burtsev January, 2017 238P: Operating Systems Lecture 7: System boot Anton Burtsev January, 2017 Outline for today Boot operating system Setup segments (data and code) Switch to protected mode Load GDT (turn segmentation on)

More information

UNIT 2 PROCESSORS ORGANIZATION CONT.

UNIT 2 PROCESSORS ORGANIZATION CONT. UNIT 2 PROCESSORS ORGANIZATION CONT. Types of Operand Addresses Numbers Integer/floating point Characters ASCII etc. Logical Data Bits or flags x86 Data Types Operands in 8 bit -Byte 16 bit- word 32 bit-

More information

CC411: Introduction To Microprocessors

CC411: Introduction To Microprocessors CC411: Introduction To Microprocessors OBJECTIVES this chapter enables the student to: Describe the Intel family of microprocessors from 8085 to Pentium. In terms of bus size, physical memory & special

More information

icroprocessor istory of Microprocessor ntel 8086:

icroprocessor istory of Microprocessor ntel 8086: Microprocessor A microprocessor is an electronic device which computes on the given input similar to CPU of a computer. It is made by fabricating millions (or billions) of transistors on a single chip.

More information

9/25/ Software & Hardware Architecture

9/25/ Software & Hardware Architecture 8086 Software & Hardware Architecture 1 INTRODUCTION It is a multipurpose programmable clock drive register based integrated electronic device, that reads binary instructions from a storage device called

More information

MICROPROCESSOR TECHNOLOGY

MICROPROCESSOR TECHNOLOGY MICROPROCESSOR TECHNOLOGY Assis. Prof. Hossam El-Din Moustafa Lecture 5 Ch.2 A Top-Level View of Computer Function (Cont.) 24-Feb-15 1 CPU (CISC & RISC) Intel CISC, Motorola RISC CISC (Complex Instruction

More information

Part I. X86 architecture overview. Secure Operating System Design and Implementation x86 architecture. x86 processor modes. X86 architecture overview

Part I. X86 architecture overview. Secure Operating System Design and Implementation x86 architecture. x86 processor modes. X86 architecture overview X86 architecture overview Overview Secure Operating System Design and Implementation x86 architecture Jon A. Solworth Part I X86 architecture overview Dept. of Computer Science University of Illinois at

More information

iapx86 Protection Electronic Computers M

iapx86 Protection Electronic Computers M iapx86 Protection Electronic Computers M 1 Protection Multitasking (multiple processes) > the system must prevent an uncontrolled access of a process to the memory space of another process....and that

More information

Intel Instruction Set (gas)

Intel Instruction Set (gas) Intel Instruction Set (gas) These slides provide the gas format for a subset of the Intel processor instruction set, including: Operation Mnemonic Name of Operation Syntax Operation Examples Effect on

More information

EC-333 Microprocessor and Interfacing Techniques

EC-333 Microprocessor and Interfacing Techniques EC-333 Microprocessor and Interfacing Techniques Lecture 3 The Microprocessor and its Architecture Dr Hashim Ali Fall - 2018 Department of Computer Science and Engineering HITEC University Taxila Slides

More information

9/19/18. COS 318: Operating Systems. Overview. Important Times. Hardware of A Typical Computer. Today CPU. I/O bus. Network

9/19/18. COS 318: Operating Systems. Overview. Important Times. Hardware of A Typical Computer. Today CPU. I/O bus. Network Important Times COS 318: Operating Systems Overview Jaswinder Pal Singh and a Fabulous Course Staff Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/) u Precepts:

More information

8086 INTERNAL ARCHITECTURE

8086 INTERNAL ARCHITECTURE 8086 INTERNAL ARCHITECTURE Segment 2 Intel 8086 Microprocessor The 8086 CPU is divided into two independent functional parts: a) The Bus interface unit (BIU) b) Execution Unit (EU) Dividing the work between

More information

Darshan Institute of Engineering & Technology

Darshan Institute of Engineering & Technology 1. Explain 80286 architecture. OR List the four major processing units in an 80286 microprocessor and briefly describe the function of each. Ans - The 80286 was designed for multi-user systems with multitasking

More information

xv6 Boot Recap: Transitioning from 16 bit mode to 32 bit mode

xv6 Boot Recap: Transitioning from 16 bit mode to 32 bit mode 238P Operating Systems, Fall 2018 xv6 Boot Recap: Transitioning from 16 bit mode to 32 bit mode 3 November 2018 Aftab Hussain University of California, Irvine BIOS xv6 Boot loader what it does Sets up

More information

Operating Systems Engineering Recitation #3 (part 2): Interrupt and Exception Handling on the x86. (heavily) based on MIT 6.

Operating Systems Engineering Recitation #3 (part 2): Interrupt and Exception Handling on the x86. (heavily) based on MIT 6. 236366 Operating Systems Engineering Recitation #3 (part 2): Interrupt and Exception Handling on the x86 (heavily) based on MIT 6.828 (2005, lec8) x86 Interrupt Nomenclature Hardware Interrupt (external)

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Slides prepared by Kip R. Irvine Revision date: 09/25/2002

More information

AMD-K5. Software Development Guide PROCESSOR

AMD-K5. Software Development Guide PROCESSOR AMD-K5 TM PROCESSOR Software Development Guide Publication # 20007 Rev: D Amendment/0 Issue Date: September 1996 This document contains information on a product under development at Advanced Micro Devices

More information

Processor Structure and Function

Processor Structure and Function WEEK 4 + Chapter 14 Processor Structure and Function + Processor Organization Processor Requirements: Fetch instruction The processor reads an instruction from memory (register, cache, main memory) Interpret

More information

What You Need to Know for Project Three. Dave Eckhardt Steve Muckle

What You Need to Know for Project Three. Dave Eckhardt Steve Muckle What You Need to Know for Project Three Dave Eckhardt Steve Muckle Overview Introduction to the Kernel Project Mundane Details in x86 registers, paging, the life of a memory access, context switching,

More information