From: Simon Krahnke Date: 2007-08-19T04:04:59+09:00 Subject: Re: 8086 simulator in ruby * Vasil Vangelovski (21:14) schrieb: > I'm thinking of writing a simulator for the intel 8086 processor in > ruby. At first I'm interested in implementing basic instruction > execution and memory access, no interrupts. The interface may later be > implemented with Tk maybe even as an ajax application on rails. My buest > guess is using metaprogramming for interpreting the assembly > instructions. I'm not wery experienced with design patterns, so I need > some ideas on the levels of abstraction (the classes) i need to start > with this. Any ideas? That depends on the level of emulation you want. What others propose here seems to be a quite high level assembler interpreter. A CPU bascically operates on memory and has several registers, one being the instruction pointer. So on some no-exact-timing, debugger-like level you implement just that: Memory can be an array or a string[1]. At each step the byte at the ip is read, decoded and the ip incremented until you have a full instruction, referenced memory is read, instruction executed and the result stored in memory or a register. class CPU8086 attr_accessor :memory, :ip, :sp, :ax, :bc, :cx ... The instruction manual basically describes the interface. mfg, simon .... l [1] Is there a performing byte storage in Ruby 1.9?