|
Prev: MI5 Persecution: BBC Newscasters Lie & Deny Theyre Watching Me (9002)
Next: assembly language and reverse engineering
From: Rod Pemberton on 1 Dec 2007 12:30 <robertwessel2(a)yahoo.com> wrote in message news:333531d8-76d8-417b-a601-7d6ba5196d4a(a)y5g2000hsf.googlegroups.com... > On Nov 30, 11:45 pm, Evenbit <nbaker2...(a)charter.net> wrote: >> [snip, topic: "Okay, here is my 'rough draft' of the instruction layout for a CPU emulator that builds on the basic premise of the Simple Machine Language (SML) interpreter"] > > You seem to be implying a 24 bit address space in the ISA, yet your > sample code appeared lo load 0xffffffff into SP. For a student > machine, you may want to just limit this to 24 bits. 16 bits is fine. Look at FORTH's compactness. Non-threaded code and stackframes of compiled languages are the memory hogs... > Also, I assume > this is a 32 bit ISA? You're obviously implying a word addressed > machine, which is fine, but it's probably a much better idea to leave > the addresses shifted by the appropriate amount to allow the straight > forward creation of byte granularity pointers (IOW, consecutive memory > words should be 0, 4, 8, 12..., not 0, 1, 2, 3 - there are good > reasons the later went out of style a long time ago). I agree. It can be difficult to do strings, arrays, or implement C without byte granularity. > And finally, > you desperately need an indexed or indirect addressing mode - oddly > you've got that for the branches - or you can't even program basic > string functions without self modifying code. Not to mention a few > more ALU instructions. > I agree. It's pretty hard to create a stackframe without such an addressing mode. > But why not go for a more load/store architecture. If you want > simplicity for the student, that has a lot of advantages. How about: > I agree. Although, the linked SML page seems to have a pretty good reduced or modified 6502 like instruction set. You could start by looking at reducing the 6502 or Z80's instruction set. I reduced the 6502's down to 13 on paper. Working, but slow versions, of interpreted FORTH can be implemented in 9 "primitives." And, a basic LISP interpreter can be done in 8. C, for the most part, can be reduced to about 16 actions and 20 arithmetic operations, more if you need mixed sizes 8,16,32... You could also look at the Brainfuck language. Rod Pemberton |