From - Fri Sep 19 12:35:49 1997 Path: news.mitre.org!blanket.mitre.org!agate!howland.erols.net!news-peer.sprintlink.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!128.143.2.44!hearst.acc.Virginia.EDU!murdoch.acc.Virginia.EDU!not-for-mail From: chapin@adder.cs.virginia.edu (Steve J. Chapin) Newsgroups: comp.arch Subject: Re: single instruction cpu Date: 19 Sep 1997 10:58:33 -0400 Organization: University of Virginia Lines: 114 Message-ID: References: <34212C18.41C6@prenhall.com> NNTP-Posting-Host: adder-fo.cs.virginia.edu X-Newsreader: Gnus v5.3/Emacs 19.34 Rich Puchalik wrote: }} Does anyone know: }} }} If there was a cpu with one single instruction/operand, what would it }} be. This is a question asked by my professor, he gave us a hint that }} it's not add because add isn't used in loops. This is in no way original to me. Here is a posting I saved from more than ten years ago, from Mike Mahar. I've just cleaned up the formatting a bit, and fixed a typo or two. ------ begin Mike's text ---------------- Several people have asked me to mail them or post the macro package for a one instruction machine call urisc. Ultimate risc. The instruction is: Reverse subtract and skip if borrow. The accumulator is subtracted from the memory location and the next instruction is skipped if there was a borrow. The result is stored in both the accumulator and the memory location. The PC is memory location 0. I tried to respond to these by mail, but about half of them came back. Several people thought this might be of general interest and asked me to post it. So, here it is. The original work on this package was done by Mike Albaugh of Atari Games. He gave me the macros over the phone so any errors are probably mine. Mike Mahar The ADDRESS macro takes two operands. A word of memory is allocated which contains the difference between the two operands. If the first operand is less then the second operand 1 is subtracted from result. The address of the memory word is the instruction emitted. macro clr %p1 ;clear accumulator and memory %p1 ; accessing the same location three %p1 ; times clears it and acc %p1 endmacro macro mov %p1,%p2 ;mov data from p1 to p2 clr %p2 ; clear destination and acc scratch ; load scratch to accumulator scratch ; clear scratch and acc note: no skip here %p1 ; load p1 into acc (acc = p1 - 0) scratch ; scratch,acc = 0 - p1 or -p1 scratch ; skipped always or 0 %p2 ; p2 = p2 - (-p1) p2 was zero acc was -p1 scratch ; skipped always or 0 endmacro macro jmp %p1 ;jmp to label p1 clr scratch ; clear the scratch area ADDRESS %next,%p1 ; ADDRESS is a pointer to a location ; containing the expression. If p1 is lss then ; next subtract 1 from expression. ; acc contains the difference between the label ; and the current pc %next: pc ; pc = pc - offset (branch) endmacro macro zajmp %p1 ;jmp to label p1 if acc is zero. zero = 0 zero ; zero,acc = zero - 0; zero,acc = zero - # ADDRESS %p1,%next ;acc = p1 - next ; skipped zero ; zero - (p1 - next) ; zero - zero = 0 zero ; skipped ; zero - 0 = 0 %next: pc ; pc = pc - offset ; pc = pc - 0 endmacro macro zjmp %p1,%p2 ;jmp to p2 if p1 = 0 clr zero ; make location zero = 0 %p1 ; load p1 zajmp %p1 ; jmp if acc zero endmacro sub %p1,%p2 ;p2 = p2 - p1 clr scratch ; clear scratch,acc %p1 ; load p1 %p2 ; p2,acc = p2 - p1 scratch ; skip if borrow scratch ; endmacro add %p1,%p2 ;p2 = p1 + p2 clr scratch2 %p1 scratch2 ; scratch = -p1 sub scratch2,%p2 endmacro Mike Mahar UUCP: {turtlevax, cae780}!weitek!mahar Disclaimer: The above opinions are, in fact, not opinions. They are facts. --------------- end Mike's text --------------- chapin@cs.virginia.edu Steve Chapin Today's Usage Lesson: Aye, I like her eyes! "Oh my God! I shot my eye out!" (Ralphie Parker, in "A Christmas Story")