I\'ve ported my library x86Lib to mbed. It fully emulates the 8086 processor, but a few things I\'m still working on. Notable missing things are interrupts. Previously I used exceptions for interrupts, but exceptions aren\'t supported with the mbed compiler. It is also quite slow
ops/strings.cpp@0:217a7931b41f, 2012-03-04 (annotated)
- Committer:
- earlz
- Date:
- Sun Mar 04 08:15:47 2012 +0000
- Revision:
- 0:217a7931b41f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
earlz | 0:217a7931b41f | 1 | /** |
earlz | 0:217a7931b41f | 2 | Copyright (c) 2007 - 2009 Jordan "Earlz/hckr83" Earls <http://www.Earlz.biz.tm> |
earlz | 0:217a7931b41f | 3 | All rights reserved. |
earlz | 0:217a7931b41f | 4 | |
earlz | 0:217a7931b41f | 5 | Redistribution and use in source and binary forms, with or without |
earlz | 0:217a7931b41f | 6 | modification, are permitted provided that the following conditions |
earlz | 0:217a7931b41f | 7 | are met: |
earlz | 0:217a7931b41f | 8 | |
earlz | 0:217a7931b41f | 9 | 1. Redistributions of source code must retain the above copyright |
earlz | 0:217a7931b41f | 10 | notice, this list of conditions and the following disclaimer. |
earlz | 0:217a7931b41f | 11 | 2. Redistributions in binary form must reproduce the above copyright |
earlz | 0:217a7931b41f | 12 | notice, this list of conditions and the following disclaimer in the |
earlz | 0:217a7931b41f | 13 | documentation and/or other materials provided with the distribution. |
earlz | 0:217a7931b41f | 14 | 3. The name of the author may not be used to endorse or promote products |
earlz | 0:217a7931b41f | 15 | derived from this software without specific prior written permission. |
earlz | 0:217a7931b41f | 16 | |
earlz | 0:217a7931b41f | 17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
earlz | 0:217a7931b41f | 18 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
earlz | 0:217a7931b41f | 19 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
earlz | 0:217a7931b41f | 20 | THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
earlz | 0:217a7931b41f | 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
earlz | 0:217a7931b41f | 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
earlz | 0:217a7931b41f | 23 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
earlz | 0:217a7931b41f | 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
earlz | 0:217a7931b41f | 25 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
earlz | 0:217a7931b41f | 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
earlz | 0:217a7931b41f | 27 | |
earlz | 0:217a7931b41f | 28 | This file is part of the x86Lib project. |
earlz | 0:217a7931b41f | 29 | **/ |
earlz | 0:217a7931b41f | 30 | #define X86LIB_BUILD |
earlz | 0:217a7931b41f | 31 | #include <x86Lib.h> |
earlz | 0:217a7931b41f | 32 | namespace x86Lib{ |
earlz | 0:217a7931b41f | 33 | using namespace std; |
earlz | 0:217a7931b41f | 34 | |
earlz | 0:217a7931b41f | 35 | |
earlz | 0:217a7931b41f | 36 | |
earlz | 0:217a7931b41f | 37 | void x86CPU::op16_movsb(){ |
earlz | 0:217a7931b41f | 38 | WriteByte(cES,*regs16[DI],ReadByte(DS,*regs16[SI])); |
earlz | 0:217a7931b41f | 39 | SetIndex8(); |
earlz | 0:217a7931b41f | 40 | } |
earlz | 0:217a7931b41f | 41 | |
earlz | 0:217a7931b41f | 42 | void x86CPU::op16_movsw(){ |
earlz | 0:217a7931b41f | 43 | WriteWord(cES,*regs16[DI],ReadWord(DS,*regs16[SI])); |
earlz | 0:217a7931b41f | 44 | SetIndex16(); |
earlz | 0:217a7931b41f | 45 | } |
earlz | 0:217a7931b41f | 46 | |
earlz | 0:217a7931b41f | 47 | void x86CPU::op16_cmpsb(){ |
earlz | 0:217a7931b41f | 48 | string_compares=1; |
earlz | 0:217a7931b41f | 49 | Sub8(ReadByte(DS,*regs16[SI]),ReadByte(cES,*regs16[DI])); |
earlz | 0:217a7931b41f | 50 | SetIndex8(); |
earlz | 0:217a7931b41f | 51 | } |
earlz | 0:217a7931b41f | 52 | |
earlz | 0:217a7931b41f | 53 | void x86CPU::op16_cmpsw(){ |
earlz | 0:217a7931b41f | 54 | string_compares=1; |
earlz | 0:217a7931b41f | 55 | Sub16(ReadWord(DS,*regs16[SI]),ReadWord(cES,*regs16[DI])); |
earlz | 0:217a7931b41f | 56 | SetIndex16(); |
earlz | 0:217a7931b41f | 57 | } |
earlz | 0:217a7931b41f | 58 | |
earlz | 0:217a7931b41f | 59 | void x86CPU::op16_lodsb(){ |
earlz | 0:217a7931b41f | 60 | *regs8[AL]=ReadByte(DS,*regs16[SI]); |
earlz | 0:217a7931b41f | 61 | SetIndex8(); |
earlz | 0:217a7931b41f | 62 | } |
earlz | 0:217a7931b41f | 63 | void x86CPU::op16_lodsw(){ |
earlz | 0:217a7931b41f | 64 | *regs16[AX]=ReadWord(DS,*regs16[SI]); |
earlz | 0:217a7931b41f | 65 | SetIndex16(); |
earlz | 0:217a7931b41f | 66 | } |
earlz | 0:217a7931b41f | 67 | |
earlz | 0:217a7931b41f | 68 | void x86CPU::op16_scasb(){ |
earlz | 0:217a7931b41f | 69 | string_compares=1; |
earlz | 0:217a7931b41f | 70 | Sub8(*regs8[AL],ReadByte(cES,*regs16[DI])); |
earlz | 0:217a7931b41f | 71 | SetIndex8(); |
earlz | 0:217a7931b41f | 72 | } |
earlz | 0:217a7931b41f | 73 | void x86CPU::op16_scasw(){ |
earlz | 0:217a7931b41f | 74 | string_compares=1; |
earlz | 0:217a7931b41f | 75 | Sub16(*regs16[AX],ReadWord(cES,*regs16[DI])); |
earlz | 0:217a7931b41f | 76 | SetIndex16(); |
earlz | 0:217a7931b41f | 77 | } |
earlz | 0:217a7931b41f | 78 | void x86CPU::op16_stosb(){ |
earlz | 0:217a7931b41f | 79 | WriteByte(ES,*regs16[DI],*regs8[AL]); |
earlz | 0:217a7931b41f | 80 | SetIndex8(); |
earlz | 0:217a7931b41f | 81 | } |
earlz | 0:217a7931b41f | 82 | void x86CPU::op16_stosw(){ |
earlz | 0:217a7931b41f | 83 | WriteWord(ES,*regs16[DI],*regs16[AX]); |
earlz | 0:217a7931b41f | 84 | SetIndex16(); |
earlz | 0:217a7931b41f | 85 | } |
earlz | 0:217a7931b41f | 86 | |
earlz | 0:217a7931b41f | 87 | |
earlz | 0:217a7931b41f | 88 | |
earlz | 0:217a7931b41f | 89 | }; |
earlz | 0:217a7931b41f | 90 | |
earlz | 0:217a7931b41f | 91 | |
earlz | 0:217a7931b41f | 92 |