#1
8-bit CPU with 256 bytes of RAM (Lodestar microcomputer)
Archive: 13 posts
Over the last couple of months I've developed an 8-bit CPU and 256-byte RAM chip. Together I believe they represent the fastest and most versatile computer made in LBP to date. I call this system the Lodestar. http://i.imgur.com/iOpsaVv.jpg A Lodestar system drawing a bunny. Why? Because bunnies. 1 INTRODUCTION 1.1 SPECIFICATION 1.2 DESIGN AND INTERFACE 1.3 INSTRUCTION SET 2 PROGRAMMING 2.1 YOUR FIRST PROGRAM 2.2 ADDITION 2.3 MULTIPLICATION 2.4 INPUT AND OUTPUT 2.5 GRAPHICS 2.6 SOUND 3 WHERE TO GET IT 1 INTRODUCTION The Lodestar is an 8-bit microcomputer that supports arithmetic, logic, conditional jumps, a stack, subroutines, serial I/O and interrupts. It can also generate music. The most challenging part of developing the CPU were signal timing issues. To make the best use of each frame the system runs unclocked at 30 Hz, resulting in speeds of around 3 instructions per second. One of the problems with past computers in LBP is how poorly documented they were by their authors. With this post I hope to provide a comprehensive guide to the system. 1.1 SPECIFICATION Accumulator architecture 256 bytes of memory 2 addressing modes Serial I/O ports 3 bars of thermo Internally the system is split into 2 chips: the CPU and RAM. Together they use 4000 components total. http://i.imgur.com/eBHmNTj.jpg These chips are mounted on a board above the switch assembly. 1.2 DESIGN AND INTERFACE The Lodestar's front panel has 20 lights and 12 flip switches. Since I'm a fan of vintage computers the front panel is inspired by machines like the PDP-8 and Altair 8800. http://i.imgur.com/N2rwbME.jpg There are 4 control switches: RUN starts and stops a program, EXA examines a memory address, DEP deposits a value into memory, DAT toggles display of the accumulator or data bus. The address lights show the current memory address. The data lights show either the contents of memory or the accumulator depending on the position of the DAT switch. The status lights indicate the internal state of the machine, such as overflow and I/O port activity. On the right side of the machine are the serial input and output ports. 1.3 INSTRUCTION SET The Lodestar instruction set features 36 documented instructions. HEX MNEMONIC DESCRIPTION 00 HLT halt 01 NOP no operation 49 LDA load accumulator 8C STA store accumulator 2D ADD add D5 SUB subtract 44 INC increment accumulator 84 DEC decrement accumulator 20 SHL shift left 40 SHR shift right 30 ROL rotate left 50 ROR rotate right 79 NOT bitwise not 09 OR bitwise or 71 NOR bitwise nor 41 AND bitwise and 79 NAND bitwise nand 29 XOR bitwise xor 51 XNOR bitwise xnor 14 PUSH push to stack 24 PULL pull from stack 55 CG compare greater than D5 CL compare less than D5 CGE compare greater than or equal to 55 CLE compare less than or equal to 28 JG jump if greater than 18 JL jump if less than 28 JGE jump if greater than or equal 18 JLE jump if less than or equal 48 JNZ jump if not zero 88 JMP unconditional jump 1C JSR jump to subroutine 2C RET return from subroutine 2E RTI return from interrupt 80 OUT serial out 4C SPK accumulator to speaker There are two addressing modes for the LDA, STA, ADD, SUB and bitwise instructions: immediate and absolute. This is determined by the 1th bit of the instruction as demonstrated below. HEX MNEMONIC COMMENT 49 08 LDA 8 ;load 8 4B 08 LDA @8 ;load the contents of memory address 8 These addressing modes allow the use of variables in programs. 2 PROGRAMMING A Lodestar program is a series of instructions. When you flip the RUN switch the program will begin executing from the current memory address. Programs are entered byte by byte. To input a byte into memory: Set input switches to desired address and examine Set input switches to desired value and deposit To input the value 44 at address 08 for instance you would first examine 08 and then deposit 44. What follows is a tutorial that introduces the instruction set through 6 programs. All the programs begin from address 0. 2.1 YOUR FIRST PROGRAM A program can be as simple as a single instruction. 88 00 JMP 0 ;jump to memory address 0 This program uses the jump instruction to jump to itself, creating an infinite loop. 2.2 ADDITION Performing arithmetic is just as simple. 49 05 LDA 5 ;load 5 2D 03 ADD 3 ;add 3 00 HLT ;halt the program This program loads 5 into the accumulator, then adds 3 to it. As the name implies the accumulator accumulates the result of all operations. To see the result of this program displayed on the data lights flip the DAT switch up. 2.3 MULTIPLICATION There's no multiply instruction. Instead, repeated addition can be used. 4B 05 loop: LDA @x ;load x variable 2D 05 ADD 5 ;add 5 to x 8C 00 STA x ;store x 4B 0A LDA @i ;load i variable 84 DEC ;decrement i 8C 04 STA i ;store i 48 00 JNZ loop ;if i is not zero jump to loop 00 HLT ;halt the program This program performs 5 x 4. There are two variables used: x and i. The variable x is initially set to zero and accumulates the result with each iteration of the loop. The variable i is decremented once per iteration and acts as a counter, when it reaches zero the program halts. 2.4 INPUT AND OUTPUT Located on the right side of the Lodestar are both the serial input port and serial output port. These can be used to connect peripherals or to create networks of Lodestar systems. On receiving a byte via the input port an interrupt is triggered. An interrupt pushes the current memory address to the stack and the CPU jumps to address 0. After an interrupt has been handled a RTI instruction can be used to return the CPU to the prior address. 14 PUSH ;push interrupt to stack 4B 08 LDA @p ;load pointer variable 44 INC ;increment pointer 8E 08 STA @p ;store pointer 24 PULL ;pull interrupt back from stack 8E 0B STA @p ;store interrupt where the pointer points 2E RTI ;return from interrupt 88 0A loop: JMP loop ;wait for another interrupt This is a powerful program that listens to the input port, copying whatever it receives to memory. This means we can hook up a keyboard to the system, so programs can be entered easier and faster. In fact, all the programs in this tutorial were written using this program and a keyboard. Although not necessary, this program uses the stack to temporarily store the interrupt. The stack starts at address FF and decrements down. This is a handy way to pass data around without using lots of LDA and STA instructions. 2.5 GRAPHICS Using the serial output port it's possible to communicate with peripherals such as a monitor. 4B 0D loop: LDA @i ;load pixel 80 OUT ;send to monitor 4B 01 LDA @i ;load pixel address 44 INC ;increment 8E 01 STA @i ;store new address 55 0F CG 0F ;if last pixel address is greater than new address, 28 00 JG loop ;jump to loop, 00 HLT ;else halt 80 0F FF ;pixel data This program sends a region of memory to the serial output port, byte by byte. The monitor treats these bytes as pixel coordinates and updates the screen. In this case, the pixel data is 3 bytes long and draws a triangle. https://i.imgur.com/LKKAIFa.jpg By combining this program with the program in the previous section it's possible to copy programs and data from one Lodestar system to another. 2.6 SOUND Lastly, the Lodestar is also capable of generating music. The lowest 4 bits of the accumulator determine the pitch when the SPK instruction is used. 4B 04 loop: LDA @x ;load, increment and store x 44 INC 8C 00 STA x 41 0D AND 0D ;discard the 1th bit 4C SPK ;send x to speaker 88 00 JMP loop ;jump to loop This program plays a spooky song. 3 WHERE TO GET IT The level, which features a running system, can be found here: https://lbp.me/v/qvz2ch0 Simply complete the level to collect the Lodestar, monitor and keyboard as shareable prizes. | 2015-03-07 22:22:00 Author: Ayneh ![]() Posts: 2454 |
How... When... Where!? *Head explodes* | 2015-03-07 22:40:00 Author: Pan_Ziemniak ![]() Posts: 40 |
But Ayneh can it love.. CAN IT LOVE? ... Also can it fix me a can of soup? =D BTW nice to see you finally got your tech-toy done! :> | 2015-03-07 22:58:00 Author: Lord-Dreamerz ![]() Posts: 4261 |
That's so awesome. I don't understand how it is possible. Bravo! | 2015-03-08 03:04:00 Author: IAB98 ![]() Posts: 23 |
I think you just won LBP sir. | 2015-07-29 09:45:00 Author: comishguy67 ![]() Posts: 849 |
Insane... and I think comishguy67 is right, here | 2015-07-29 10:02:00 Author: amiel445566 ![]() Posts: 664 |
Well. I just saw this, but my my, it's incredibly impressive. Will you keep trying to make computers in LBP 3? | 2015-08-03 06:56:00 Author: Kalawishis ![]() Posts: 928 |
My god that's insane! Does that mean you've mastered the LBP3 logic completely??? Always so befuddled and awed by this type of logic. What do you like doing in real life? | 2015-10-17 22:01:00 Author: AxisTheLegend ![]() Posts: 59 |
Tried it, couldn't get it to work. It needs a manual of some kind to know what to do with the buttons. All it said was "HI" which then faded away into nothingness. Good idea, I have something that might work. | 2017-01-10 10:50:00 Author: M_R_Enigma ![]() Posts: 161 |
My head hurts. Good job, however! | 2017-01-13 05:45:00 Author: Sir monacle ![]() Posts: 4155 |
This heading towards Black Mirror levels of freakiness - sackthing simulating other sackthings in a spiraling simulation infinity :eek: I'm both impressed and bewildered - wow! Great work! I bow before you! | 2018-01-03 03:34:00 Author: aratiatia ![]() Posts: 374 |
My mind is blown. I just... I dont see how this is possible. I'd like to see the logic for each component on a smaller scale. | 2018-01-04 07:48:00 Author: Wafflegod345 ![]() Posts: 74 |
This is impressive, I agree. For me personally it's important that the logic works and not how it works. But this inspires me to learn more about logic. | 2018-01-07 20:55:00 Author: mdkd99 ![]() Posts: 1172 |
LBPCentral Archive Statistics
Posts: 1077139
Threads: 69970
Members: 9661
Archive-Date: 2019-01-19
Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.