AttoWPU - Going to Intel ISEF!

Discuss everything else here

Moderator: ArcWolf

User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

AttoWPU - Going to Intel ISEF!

Post by Frooxius »

Hello, I would like to show a project I'm working on for some time already, some of you already saw the documentation before and now it's finally out, so I hopefully get some people interested and get some feedback or some help later with language (english) corrections and that sort of stuff. It's basically interesting (hopefully Image ) "toy" for programmers, maybe something like esoteric programming languages, like brain*coughcough*youknowwhat. Image

Image

Official website

It's an experimental processor from the WPU (Weird Processing Unit) series, which is an attempt of untraditional and interesting approach to machine code processing and programming: it includes programming language AttoASM (attoassembler) and CustASM (custom assembler) and associated assemblers ("compilers") and simulator, which allows you to try created programs, I also plan providing VHDL description in the future.

Also, there's a simple game included, which I programmed for my own processor in my own programming language Image You can just download the package and run it, no computing knowledge required.

Download
Includes:
- Documentation in PDF
- Assembler ("compiler") for the AttoASM programming language, Windows, Linux, CLI
- Simulator (or emulator) of the AttoWPU processor, Windows, Linux, GUI (Qt)
- Logical scheme of the processor, PDF
- Example sourcecodes in the AttoASM
- Game Pong written in the AttoASM

Changelog:
0.8.01
-Moved emulation to its own thread, better timing code. This makes the emulation frequency more precise and it should run faster, especially on multicore processors, because one core can emulate the AttoWPU, while the other one handles the GUI drawing
-Maximum/unlimited emulation speed now works: simply drag the slider all the way to the right or just click the Max button and it will emulate the AttoWPU at the fastest speed your computer can handle
-LED diodes and switches are now graphical, instead of using radios and checkboxes (but they work the same), so they should look better
-Keyboard capture is now global for the whole application, no matter what element has keyboard focus
-Fixed crashing when "Cancel" was clicked on the Load AttoASM source dialog
-Small update to the specification, about how is the speaker controlled
-Czech version of the specification is available now

0.8.02
-Linux binaries are available
-Updated attoassembler code in the emulator to prevent crashes during assembling sources

Image
(yeah I know, GUI isn't polished at all now)

What is WPU?

You probably know at least what CPU and GPU are: processing units with specific purpose and philosophy: CPU (central processing unit) is universal processor, that is capable of executing any type of a program (well, maybe not literaly), but unlike specialized units, he can't do many of them fast enough, so in case of graphic operations, GPU comes in: it's specifically designed to perform graphical operations quickly, but can't do much else (although that's somewhat changing with unified shaders and such, but that's besides the point). Point is, each of these has its philosophy and purpose, something that makes them typical, so what makes WPU typical?

WPU stands for Weird Processing Unit and such weird and crazy fun name already implies what WPU is: it's basically a processing unit, that's somehow weird - different from usual conventions. WPU can be any processor, that has at least part of it designed in a weird, unusual way, that makes programming for it and the way the machine code is executed challenging and/or interesting. It doesn't have to be practical in any way and often, it's not. It's more of a "hey, let's try this and see what happens" philosophy - purely experimental, whacky and weird for the sake of fun and curiosity.

This means, that WPU is basically any processing unit, that somehow tries to go beyond boundaries of conventions of normal processors. WPUs try to be more or less original, new and interesting concepts, that stimulate programmer's minds with untraditional design and usually untraditional programming. They can be even considered to be form of an art to some extent, something like "avant-garde processors".

What is the AttoWPU?

While WPU is common name for any processing unit, attoWPU is a specific WPU and not just that: it's the first WPU created as the start of the series of WPUs, so it's sort of the gateway into the world of the weird processing units. It's certainly not the best of them, or most original of WPUs, but it's a start.

AttoWPU is inspired by the microcode of normal processors and basically builds on the idea, that we can divide processors into two logical parts: execution unit (everything that does various calculations and operations) and control unit (part, that decodes instruction opcodes and tells execution unit what to do). AttoWPU has the control unit reduced to absurd minimum, requiring programmer to basically create a code, that will control the processor's function using three elementary instructions (attoinstructions), each one changing always only one bit. Regarding the exeuction units, AttoWPU has many of them and they do a lot of job by themselves, to make the programming simpler (if you want it even more hardcode, just wait for the zeptoWPU Image ).

This basically allows you to either create conventional (or not) software using the attoasembly language used to control the parts of the processor, making it a form of extreme/hardcore programming, or to use the attoassembly to define a processor's function and let it process higher level instructions of your design. There's also another peculiar perk: because the attocode memory is read/write, it's theoretically possible to create self modifying processor.

There's also another task, related to AttoWPU programming: code optimization and compression. AttoWPU machine code provides a lot of space for program optimization (both making it smaller and run faster, these two are actually equal to some point) and compression (A LOT of redudancy), so you can test how good programmer you are in various challenges and forthcoming competitions.

In short, AttoWPU has the AttoCore, which is capable of processing only elementary instructions, called attoinstructions. AttoWPU has one 64 bit bus, which is divided into four logical buses: address, control, data and Quick aJump bus, each attoinstruction changes always one bit of this bus. There are various units (execution units) connected in parallel to these buses, so programmer must use the buses to instruct them what to do and allow them to exchange data using the data bus. The attoCore is only capable of changing one bit on one of the logical buses at each cycle, everything else must be handled by controlling the units. For better understanding, please look at the logical scheme, which can be found at the downloads section.

What is the AttoASM?

AttoASM is a programming language used to create an attocode - machine code that's processed by the attocore of the AttoWPU. It allows you create the attocode by writing individual attoinstructions, but it also provides ways of simplifying the programming and reducing repeating source code. The same thing can't be however said about produced machine code, so if you want to optimize the resulting code, source code will probably be more complex and harder to manage or even create, but it's extreme/hardcore programing, isn't it? :-) You'll need AttoASM "compiler" - attoassembler to convert the sourcecode to attocode (machine code).

What is the CustASM?

Because you can create attocode, which will basically define a processor - it will handle decoding instructions and executing appropriate actions, you can also create any instruction set you want (higher level instructions than the attoinstructions), but if you want to write your own programs, using your own instructions, you'll need an assembly tool, which will produce correct machine code from the sourcecode, which will use your own mnemonics.

For the sake of convenience, so you don't have to write your own tools or go and search for some, CustASM language and custassembler tool is provided. This assembly language basically allows you to easily define your own mnemonics, including the argument arrangement and corresponding machine code. Custassembler tool will then use these definitions when assembling your source code.

Currently, custassembler tool is not available yet.

How can I try it?

To give anyone possibility to try the AttoWPU and programming for it, simulator is provided, together with attoassembler tool (simulator has however built-in attoassembler, so you can load the source directly into it and it will convert it to machine code automatically). Of course, you need to read the documentation first and look at the included example source codes (more will appear with time and properly commented ones), tutorials explaining how to do various tasks more clearly will be also available soon.

Anyway, if you're interested in this project, keep watching this thread and optimally also the developer blog on the official website, as I'll inform you about any updates, including new versions of the tools and specification with new features and bugfixes and thus, I'll hopefully reach beta status soon. However, I'm now also focusing on another WPU, which is even more interesting (in my opinion) than this one, but I'm not ready to make it public yet, but when I will, you will know :-)

For now, I made only Windows versions of the tools available, but Linux binaries are coming soon too, as well as more tools, like the custassembler, attodisassembler, CLI simulator and package maker. The simulator is also quite slow for now, but it will get more optimized simulation core later, which will be able to simulate the AttoWPU at much higher speeds than now :-)

There are some few AttoASM source code examples in the file, but mostly they are just files I used to test the simulator. Most notable is the AttoPong, which is basically old classic game Pong written fully in AttoASM and it's fairly commented, so perhaps it will be a nice source of information, or at least proof, that it all works together nicely ;-)

Well I guess that's enough for now, so don't forget to comment, experiment and hopefully subscribe to the RSS on the official website, or at least peek again sometime in the future, to look what's new :-)

Game Pong written in the AttoASM (by me obviously)
You can test it by downloading the package with the simulator. Also, this is an unoptimized version, it's basically first serious (relatively speaking :D ) code ever created for the AttoWPU.

Code: Select all

// Register Memory Allocation
PADDLE0_Y { 0 }
PADDLE1_Y { 1 }
BALL_X { 2 }
BALL_Y { 3 }
SCORE0 { 4 }
SCORE1 { 5 }
BALL_XSPD { 6 }
BALL_YSPD { 7 }
TEMP { 8 }

// For passing an argument to a symbol
ARG0 { 0 }
ARG1 { 0 }
ARG2 { 0 }
ARG3 { 0 }

// Auxiliary

EXE { CTRL+7(2) ! }
WriteTEMP
{
	ADDR [02, 8]
	CTRL [03, 7]
	EXE
}

// Output value from the Register memory at address given by ARG
OutputRegister
{
	ADDR [03, 8]
	DATA [ARG0]
	CTRL [01, 7]	// write address
	EXE
	CTRL [0DH, 7]	// output data
	EXE
	DATA 1(32)
}

// stop register output
StopRegister
{
  ADDR [03, 8]
  CTRL [0, 7]
  EXE
}

OUT2TEMP
{
   DATA 1(32)
   ADDR [05, 8] CTRL [01, 7] EXE // output OUT
   WriteTEMP
   ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
}

// signed add two values together and store the result back
// ARG1 - first value
// ARG2 - second value
// ARG3 - result (where to write)
SADDStoreBack
{
	
	ARG0 {! ARG1 }
	OutputRegister
	WriteTemp
	ADDR [03, 8] CTRL [0, 7] EXE // stop the register output
	ARG0 {! ARG2 }
	OutputRegister
	
	// add them together
	ADDR [04, 8]
	CTRL [09, 7]
	EXE
	
	// store the result back
	ADDR [03, 8] CTRL [0, 7] EXE // stop the register output
	ADDR [03, 8] DATA [ARG3] CTRL [01, 7] EXE // address the proper location in the register memory
	DATA 1(32)
	ADDR [05, 8] CTRL [1, 7] EXE // output the out
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the value
	ADDR [05, 8] CTRL [0, 7] EXE // stop the out output	
}

// **** KEYBOARD READ ****

ReadKey
{
	DATA 1(32)	// prepare for data exchange
	ADDR [0DH, 8]	// address the input controller
	CTRL [08, 7]	// read the key
	EXE
}

StopKey
{
	ADDR [0DH, 8]	// address the input controller
	CTRL [0, 7]	// read the key
	EXE
}

ProcessAllKeys
{
	ARG0 {! PADDLE0_Y }
	ARG1 {! 22 }	// the W key
	ARG2 {! 02 }	// subtraction
	ProcessKey
	ARG0 {! PADDLE0_Y }
	ARG1 {! 18 }	// the S key
	ARG2 {! 01 }	// addition
	ProcessKey	
	
	// second paddle
	ARG0 {! PADDLE1_Y }
	ARG1 {! 4 }	// the E key
	ARG2 {! 02 }	// subtraction
	ProcessKey
	ARG0 {! PADDLE1_Y }
	ARG1 {! 3 }	// the D key
	ARG2 {! 01 }	// addition
	ProcessKey
}

/*
		ARGUMENTS:
		ARG0 = address at the register memory to process
		ARG1 = code of the key
		ARG2 = command code for the ALU to calculate new value
*/

ProcessKey
{
	// Read the W key
	ReadKey
	WriteTEMP
	StopKey
	
	DATA [ARG1] // code of the W key
	// compare them using the ALU
	ADDR [04, 8]
	CTRL [28H, 7] // test for equality
	EXE
	
	// output result from the OUT
	ADDR [05, 8]
	CTRL [01, 7]
	EXE
	DATA 1(32)
	WriteTEMP	// and store it in the temp register
	// multiply by two, so it moves by two pixels
	ADDR [04, 8]
	CTRL [01, 7]
	EXE EXE
	WriteTEMP
	
	ADDR [05, 8]
	CTRL [0, 7]
	EXE // stop OUT output
	
	
	// load the value from the Register memory
	
	// address is prepared in the ARG0
	OutputRegister
	
	// calculate new value
	ADDR [04, 8]
	CTRL [ARG2, 7]
	EXE
	
	ADDR [03, 8]
	CTRL [0, 7]
	EXE // stop register memory outputting
	
	// ---- limit value to min 0, max 127 ----
	// copy it from the OUT to the TEMP
	DATA 1(32)
	ADDR [05, 8]	
	CTRL [1, 7]
	EXE
	WriteTemp
	ADDR [05, 8]
	CTRL [0, 7]
	EXE
	
	// maximum
	DATA [128-18]
	ADDR [04, 8]
	CTRL [26H, 7]
	EXE
	
	// copy it from the OUT to the TEMP
	DATA 1(32)
	ADDR [05, 8]	
	CTRL [1, 7]
	EXE
	WriteTemp
	ADDR [05, 8]
	CTRL [0, 7]
	EXE	
	
	// minimum
	DATA [0]
	ADDR [04, 8]
	CTRL [24H, 7]
	EXE
	
	// new position is calculated, now store the value back
	DATA 1(32)
	ADDR [05, 8]
	CTRL [1, 7]
	EXE // output calculated value
	ADDR [03, 8] // register memory
	CTRL [0EH, 7]
	EXE // modified value is now written back
	
	// cleanup
	ADDR [05, 8]
	CTRL [0, 7]
	EXE // stop OUT output
}

// DRAWING

// draws the ball at current position - it's calculated automatically
DrawBall
{
	// ball is 6x6 px
	
	// get the Y position first and calculate proper address for the LCD
	ARG0 {! BALL_Y }
	OutputRegister
	// write it to the temp
	ADDR [02, 8]
	CTRL [03, 7]
	EXE

	// stop register output
	ADDR [03, 8]
	CTRL [0, 7]
	EXE

	// multiply by 128
	DATA [128]
	ADDR [04, 8]
	CTRL [03, 7]
	EXE

	// output the OUT
	ADDR [05, 8]
	CTRL [01, 7]
	EXE
	DATA 1(32)
	
	// write it to the temp
	WriteTEMP
	
	// stop the OUT output
	ADDR [05, 8]
	CTRL [0, 7]
	EXE
	
	// add the paddle X position to the address
	ARG0 {! BALL_X }
	OutputRegister
	
	ADDR [04, 8]
	CTRL [01, 7]
	EXE	// add the BALL_X to the address
	// OUT now contains the address, where drawing of the ball should start
	
	// stop register output
	ADDR [03, 8]
	CTRL [0, 7]
	EXE
	
	// output the OUT
	ADDR [05, 8]
	CTRL [01, 7]
	EXE
	
	// write the address to the LCD
	ADDR [0CH, 8]
	CTRL [01, 7]
	EXE		// write the new address
	
	// write it to the temp too (DrawRowNext requires it)
	WriteTEMP
	
	// stop the out output
	ADDR [05, 8]
	CTRL [0, 7]
	EXE
	
	ARG0 {! 00FF0000H }
	
	// draw 6 rows
	DrawRowNext DrawRowNext DrawRowNext
	DrawRowNext DrawRowNext DrawRowNext
}

// draws paddle at the current position - it needs to be set before this symbol is used
DrawPaddle
{
	// paddle is 6x18 px
	DATA 1(32)
	// store the starting value in the TEMP first
	ADDR [0CH, 8]
	CTRL [06, 7]
	EXE
	WriteTemp
	
	// start writing pixels
	ADDR [0CH, 8]
	CTRL [0, 7]
	EXE		// stop the data output first
	
	ARG0 {! 00FFFF00H }
	
	DrawRowNext DrawRowNext DrawRowNext DrawRowNext
	DrawRowNext DrawRowNext DrawRowNext DrawRowNext
	DrawRowNext DrawRowNext DrawRowNext DrawRowNext
	DrawRowNext DrawRowNext DrawRowNext DrawRowNext
	DrawRowNext DrawRowNext	
}

// draw a row of pixels and move to the next one
// color is stored in ARG0
DrawRowNext
{
	DATA+8 [ARG0, 24]
	// write 6 pixels
	ADDR [0CH, 8]
	CTRL [03, 7]
	CTRL+7(12) !
	
	// move to the next row
	DATA [128]	
	ADDR [04, 8]
	CTRL [01, 7]
	EXE		// add 128 to the value
	
	DATA 1(32)
	ADDR [05, 8]
	EXE		// output it
	WriteTemp
	ADDR [0CH, 8]
	CTRL [01, 7]
	EXE		// write the new address
	ADDR [05, 8]
	CTRL [0, 7]
	EXE		// stop the output from the OUT
}

// write LCD paddle start position
// ARG0 - register address containing the position
// ARG1 - number to add to the start address (used to determine side)
LCDPaddleStart
{
	// output the start position from the register memory
	OutputRegister

	// write it to the temp
	ADDR [02, 8]
	CTRL [03, 7]
	EXE

	// stop register output
	ADDR [03, 8]
	CTRL [0, 7]
	EXE

	// multiply by 128
	DATA [128]
	ADDR [04, 8]
	CTRL [03, 7]
	EXE

	// output the OUT
	ADDR [05, 8]
	CTRL [01, 7]
	EXE
	DATA 1(32)
	
	// write it to the temp
	WriteTEMP
	
	// stop the OUT output
	ADDR [05, 8]
	CTRL [0, 7]
	EXE
	
	// now add the value in ARG1 (horizontal shift)
	DATA [ARG1]
	ADDR [04, 8]
	CTRL [01, 7]
	EXE
	
	// output the OUT
	ADDR [05, 8]
	CTRL [01, 7]
	EXE
	DATA 1(32)	

	// write the address to the LCD
	ADDR [0CH, 8]
	CTRL [01, 7]
	EXE

}

UpdateBall
{
	// increment/decrement
	// add BALL_XSPD to the BALL_X
	ARG1 {! BALL_X }
	ARG2 {! BALL_XSPD }
	ARG3 {! ARG1 }
	SADDStoreBack
	
	// add BALL_YSPD to the BALL_Y
	ARG1 {! BALL_Y }
	ARG2 {! BALL_YSPD }
	ARG3 {! ARG1 }
	SADDStoreBack
	
	/* **********************
			VERTICAL COLLISION
	   ********************** */
	   
	DATA [0]
	WriteTEMP	// temp contains minimal value
	ARG0 {! BALL_Y }
	OutputRegister
	// now compare them 
	ADDR [04, 8]  
	CTRL [25H, 7]
	EXE		// if value in TEMP is 150r than BALL_Y, then one will be outputed to the OUT
	
	ADDR [03, 8] CTRL [0, 7] EXE // stop register output
	CTRL [01, 7] DATA [TEMP] EXE	// address the cell for temporary data
	DATA 1(32) ADDR [05, 8] CTRL [01, 7] EXE // output the out
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the value
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	

	DATA [128-6]
	WriteTEMP
	ARG0 {! BALL_Y }
	OutputRegister
	// now compare them 
	ADDR [04, 8]
	CTRL [27H, 7]
	EXE		// if value in TEMP is smaller than BALL_X, then one will be outputed to the OUT
	
	ADDR [03, 8] CTRL [0, 7] EXE // stop register output
	
	// copy OUT to the TEMP
	DATA 1(32)
	ADDR [05, 8] CTRL [1, 7] EXE // output the OUT
	WriteTEMP
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	
	// output the first value on the bus
	ARG0 {! TEMP }
	OutputRegister
	// now OR them, so 1 is outputted if at one of them is 1, otherwise zero
	ADDR [04, 8] CTRL [18H, 7] EXE
	ADDR [03, 8] CTRL [0, 7] EXE // stop the register output
	
	// now multiply by -1, so -1 is outputted, when position overflows, zero otherwise
	DATA [-1]
	WriteTEMP
	DATA 1(32)
	ADDR [05, 8] CTRL [01, 7] EXE // output the OUT
	ADDR [04, 8] CTRL [0BH, 7] EXE // signed multiply
	
	WriteTEMP
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	DATA [1]
	ADDR [04, 8] CTRL [29H, 7] EXE // copy 1 to the OUT only if TEMP is zero (so OUT now contains either -1 or 1)
	
	// write back to the TEMP
	DATA 1(32)
	ADDR [05, 8] CTRL [1, 7] EXE // output the OUT
	WriteTEMP
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	// multiply it with the BALL_YSPD
	ARG0 {! BALL_YSPD }
	OutputRegister
	ADDR [04, 8] CTRL [0BH, 7] EXE // multiply them

	// store the result back
	ADDR [03, 8] CTRL [0, 7] EXE // stop the register output
	CTRL [01, 7] DATA [BALL_YSPD] EXE // address the cell with BALL_YSPD, because the new value will be written there
	DATA 1(32)
	ADDR [05, 8] CTRL [1, 7] EXE // output the OUT, contaning the new value
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the value
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	
		// left paddle detection
		 
		 ARG1 {! PADDLE0_Y }
		 ARG2 {! 
		 		DATA [6]
				ADDR [04, 8]
				CTRL [27H, 7]
				EXE
				}
		ARG3 {! 1 }
		PaddleBounce
		
		// right paddle detection
		
		 ARG1 {! PADDLE1_Y }
		 ARG2 {! 
		 		DATA [128-6-6]
				ADDR [04, 8]
				CTRL [25H, 7]
				EXE
				}
		ARG3 {! -1 }
		PaddleBounce
		
		DetectOutside
}

// detect if the ball left the area
DetectOutside
{
	// detect left outside
	ARG0 {! BALL_X }
	OutputRegister
	WriteTEMP
	StopRegister
	DATA [0]
	ADDR [04, 8] CTRL [27H, 7] EXE	// if ball left on the left, then OUT is 1
	OUT2TEMP
	
	// conditional jump
	DATA [LEFTLOSE%]
	ADDR [04, 8] CTRL [2AH, 7] EXE // if OUT is 1 then OUT will contain address of the LEFTLOSE
	DATA [LEFTNORMAL%]
	ADDR [04, 8] CTRL [29H, 7] EXE // if OUT is 0 then OUT will contain address of the LEFTNORMAL
	
	// output out
	DATA 1(32)
	ADDR [05, 8] CTRL [01, 7] EXE // output OUT
	ADDR [00, 8] CTRL [01, 7] EXE // write the new address
		
	LEFTLOSE%:
	CTRL+7 0 // to be safe
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	ResetBall
	LeftLoseCode
	AJMP [END%, 15]
	AJMP+15(2) !
	
	LEFTNORMAL%:
	CTRL+7 0 // to be safe
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	
	// detect right outside
	ARG0 {! BALL_X }
	OutputRegister
	WriteTEMP
	StopRegister
	DATA [128-6]
	ADDR [04, 8] CTRL [25H, 7] EXE	// if ball left on the right, then OUT is 1
	OUT2TEMP
		
	// conditional jump
	DATA [RIGHTLOSE%]
	ADDR [04, 8] CTRL [2AH, 7] EXE // if OUT is 1 then OUT will contain address of the RIGHTLOSE
	DATA [END%]
	ADDR [04, 8] CTRL [29H, 7] EXE // if OUT is 0 then OUT will contain address of the END
	
	// output out
	DATA 1(32)
	ADDR [05, 8] CTRL [01, 7] EXE // output OUT
	ADDR [00, 8] CTRL [01, 7] EXE // write the new address
	
	RIGHTLOSE%:
	CTRL+7 0 // to be safe
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	ResetBall
	RightLoseCode
	
	END%:	
	CTRL+7 0 // to be safe
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
}

LeftLoseCode
{
	// increment right score
	ARG0 {! SCORE1 }
	OutputRegister
	WriteTEMP
	StopRegister
	DATA [1] ADDR [04, 8] CTRL [01, 7] EXE // add one
	DATA [SCORE1] ADDR [03, 8] CTRL [01, 7] EXE // write the address
	ADDR [05, 8] DATA 1(32) CTRL [01, 7] EXE // output OUT
	ADDR [03, 8] CTRL [0EH, 7] EXE // write data
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	UpdateText
}

RightLoseCode
{
	// increment right score
	ARG0 {! SCORE0 }
	OutputRegister
	WriteTEMP
	StopRegister
	DATA [1] ADDR [04, 8] CTRL [01, 7] EXE // add one
	DATA [SCORE0] ADDR [03, 8] CTRL [01, 7] EXE // write the address
	ADDR [05, 8] DATA 1(32) CTRL [01, 7] EXE // output OUT
	ADDR [03, 8] CTRL [0EH, 7] EXE // write data
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	UpdateText
} 

UpdateText
{
	ADDR [0BH, 8] CTRL [09, 7] EXE // address the text display and reset it first
	ARG0 {! strInfo}
	CopyStr
	ARG0 {! strScore0 }
	CopyStr	
	ARG0 {! SCORE0 }
	TwoDigitsFromReg
	ARG0 {! endLine }
	CopyStr	
	ARG0 {! strScore1 }
	CopyStr	
	ARG0 {! SCORE1 }
	TwoDigitsFromReg
	ARG0 {! endLine }
	CopyStr
	ARG0 {! strInfo2 }
	CopyStr
}

// write two digits to the text display from the register memory at address in ARG0
TwoDigitsFromReg
{
	// first digit
	DATA [10]
	WriteTEMP
	OutputRegister
	ADDR [04, 8] CTRL [05, 7] EXE // divide it by 10
	StopRegister
	OUT2TEMP
	ADDR [04, 8] DATA [30H] CTRL [01, 7] EXE // add the value of '0' to it to produce a digit character
	ADDR [05, 8] DATA 1(32) CTRL [01, 7] EXE // output out
	ADDR [0BH, 8] CTRL [03, 7] EXE // write the character
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	// second digit
	DATA [10]
	WriteTEMP
	OutputRegister
	ADDR [04, 8] CTRL [06, 7] EXE // module it by 10
	StopRegister
	OUT2TEMP
	ADDR [04, 8] DATA [30H] CTRL [01, 7] EXE // add the value of '0' to it to produce a digit character
	ADDR [05, 8] DATA 1(32) CTRL [01, 7] EXE // output out
	ADDR [0BH, 8] CTRL [03, 7] EXE // write the character
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
}

// copy zero terminated string to the display
// ARG0 - start address in the attocode memory
CopyStr
{
	ADDR [01, 8] DATA [ARG0] CTRL [01, 7] EXE // address start of the string
		
	LOOP%:
	DATA 0(24)1(8)
	ADDR [01, 8] CTRL [03, 7] EXE // output character
	// determine if it's a zero - then end the loop
	WriteTEMP
	ADDR [01, 8] CTRL [0, 7] EXE // stop output
	DATA 1(24)
	ADDR [04, 8]
	DATA [END%] CTRL [29H, 7] EXE // copy the END address if TEMP is zero (zero terminated string)
	DATA [CONTINUE%] CTRL [2AH, 7] EXE // copy when TEMP is non-zero (contains character)
	
	// write the address
	DATA 1(32)
	ADDR [05, 8] CTRL [01, 7] EXE // output the OUT
	ADDR [0, 8] CTRL [01, 7] EXE // write new address
	
	CONTINUE%:
	CTRL+7 0
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	// copy the character to the text memory
	ADDR [02, 8] CTRL [04, 7] EXE	// output value from the TEMP (the character)
	ADDR [0BH, 8] CTRL [03, 7] EXE // write the character and move to the next one
	ADDR [02, 8] CTRL [0, 7] EXE // stop the TEMP output
	
	ADDR [01, 8] CTRL [07, 7] EXE // move to the next character
	
	AJMP [LOOP%, 15] AJMP+15(2) !	// maintain the cycle
		
	END%:	
	CTRL+7 0
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
}

ResetBall
{
	ADDR [03, 8]
	CTRL [01, 7] DATA [BALL_X] EXE DATA [64] CTRL [0EH, 7] EXE
	
	ARG0 {! BALL_Y }
	OutputRegister
	WriteTEMP
	StopRegister
	
	ADDR [03, 8] CTRL [01, 7] DATA [BALL_XSPD] EXE // address BALL_XSPD
	ADDR [02, 8] CTRL [04, 7] EXE // output TEMP
	ADDR [03, 8] DATA 0(31)1 CTRL [0EH, 7] EXE	// write the value
	ADDR [02, 8] CTRL [0, 7] EXE // stop TEMP output
	
	ADDR [03, 8] CTRL [01, 7] DATA [BALL_YSPD] EXE // address BALL_YSPD
	ADDR [02, 8] CTRL [04, 7] EXE // output TEMP
	ADDR [03, 8] DATA 0(30)10 CTRL [0EH, 7] EXE	// write data
	ADDR [02, 8] CTRL [0, 7] EXE // stop TEMP output
	
	ADDR [03, 8] CTRL [01, 7] DATA [BALL_Y] EXE  // address BALL_Y
	ADDR [02, 8] CTRL [04, 7] EXE // output TEMP
	ADDR [03, 8] DATA 1(32) CTRL [0EH, 7] EXE
	ADDR [02, 8] CTRL [0, 7] EXE // stop TEMP output	
	
	// now alter the BALL_XSPD and BALL_YSPD
	ARG0 {! BALL_XSPD }
	OutputRegister
	WriteTEMP
	StopRegister
	// copy either 1 or -1
	ADDR [04, 8] DATA [1] CTRL [29H, 7] EXE
	ADDR [04, 8] DATA [-1] CTRL [2AH, 7] EXE
	DATA [BALL_XSPD] ADDR [03, 8] CTRL [01, 7] EXE // address register
	ADDR [05, 8] DATA 1(32) CTRL [1, 7] EXE // output out
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the new value
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	ARG0 {! BALL_YSPD }
	OutputRegister
	WriteTEMP
	StopRegister
	// copy either 1 or -1
	ADDR [04, 8] DATA [1] CTRL [29H, 7] EXE
	ADDR [04, 8] DATA [-1] CTRL [2AH, 7] EXE
	DATA [BALL_YSPD] ADDR [03, 8] CTRL [01, 7] EXE // address register
	ADDR [05, 8] DATA 1(32) CTRL [1, 7] EXE // output out
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the new value
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
}

// handle boucing from either paddle
// ARG1 - which paddle
// ARG2 - X axis detect code (only set DATA and do ALU stuff, TEMP contains ball X)
// ARG3 - new direction
PaddleBounce
{
	// first, calculate if it's in the range of the paddle (below and above paddle's size)
	ARG0 {! ARG1 }
	OutputRegister
	WriteTEMP
	StopRegister
	DATA [-5]
	ADDR [04, 8] CTRL [09H, 7] EXE // subtract 5 from the paddle Y (so it can bounce from the edge)
	OUT2TEMP
	// TEMP now contains the upper position, now check if it's above ball position
	ARG0 {! BALL_Y }				
	OutputRegister
	ADDR [04, 8] CTRL [27H, 7] EXE // check if the BALL_Y is below PADDLE_Y
	StopRegister
	
	// store it in TEMP location in the register memory
	ADDR [03, 8] DATA [TEMP] CTRL [01, 7] EXE // write the address
	DATA 1(32) ADDR [05, 8] CTRL [01, 7] EXE // output OUT
	ADDR [03, 8] CTRL [0EH, 7] EXE	// the result is now stored
	ADDR [05, 8] CTRL [0, 7] EXE // stop OUT output
	
	// BOTTOM OF THE PADDLE
	ARG0 {! ARG1 }
	OutputRegister
	WriteTEMP
	StopRegister
	DATA [18]
	ADDR [04, 8] CTRL [09H, 7] EXE // add 18 to the value (paddle is 18 pixels tall)
	OUT2TEMP
	// TEMP now contains the bottrom possition, now check if it's below ball position
	ARG0 {! BALL_Y }
	OutputRegister
	ADDR [04, 8] CTRL [25H, 7] EXE
	StopRegister
	OUT2TEMP
	
	// now AND both these together - they both must be true
	ARG0 {! TEMP }
	OutputRegister
	ADDR [04, 8] CTRL [17H, 7] EXE // Logical AND
	StopRegister
	
	// store the result in TEMP location once again, because it will be needed soon
	ADDR [03, 8] DATA [TEMP] CTRL [01, 7] EXE // write the address
	ADDR [05, 8] CTRL [1, 7] EXE // output out
	DATA 1(32)
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the value
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output
	
	// now detect, if the ball is touching the paddle on the X axis
	ARG0 {! BALL_X }
	OutputRegister
	WriteTemp
	StopRegister
	ARG2 // detection is handled by an external code
	OUT2TEMP
	
	// now AND it with the value in the TEMP, to produce final value, determining whether or not to bounce
	ARG0 {! TEMP }
	OutputRegister
	ADDR [04, 8] CTRL [17H, 7] EXE	// AND
	StopRegister
	OUT2TEMP
	
	// now calculate new BALL_XSPD based on the calculated conditional value
	DATA [ARG3]
	ADDR [04, 8] CTRL [2AH, 7] EXE // if TEMP is nonzero, copy value from DATA to the OUT
	ARG0 {! BALL_XSPD }
	OutputRegister
	ADDR [04, 8] CTRL [29H, 7] EXE // copy current speed if TEMP is zero (no collision - maintain regular speed)
	StopRegister
	
	// write the calculated speed to the BALL_XSPD
	ADDR [03, 8] CTRL [1, 7] DATA [BALL_XSPD] EXE // address the propel cell
	DATA 1(32) ADDR [05, 8] CTRL [1, 7] EXE // output the OUT
	ADDR [03, 8] CTRL [0EH, 7] EXE // write the value
	ADDR [05, 8] CTRL [0, 7] EXE // stop the OUT output	
}

/*	************************************
				PROGRAM START
	************************************ */

// INITIALIZE EVERYTHING

0 0(64)
	
// enable double buffering
ADDR [0CH, 8]
CTRL [0BH, 7]
EXE

ADDR [03, 8] CTRL [01, 7] DATA [PADDLE0_Y] EXE DATA [64-9] CTRL [0EH, 7] EXE
ADDR [03, 8] CTRL [01, 7] DATA [PADDLE1_Y] EXE DATA [64-9] CTRL [0EH, 7] EXE
ADDR [03, 8] CTRL [01, 7] DATA [SCORE0] EXE DATA [0] CTRL [0EH, 7] EXE
ADDR [03, 8] CTRL [01, 7] DATA [SCORE1] EXE DATA [0] CTRL [0EH, 7] EXE

ResetBall
UpdateText

LOOP:
// cleanup after jump
CTRL+7 0
ADDR [0, 8] CTRL [0, 7] EXE

// game logic
UpdateBall
ProcessAllKeys
ARG0 {! PADDLE0_Y }
ARG1 {! 0 }
LCDPaddleStart
DrawPaddle
ARG0 {! PADDLE1_Y }
ARG1 {! 128-6 }
LCDPaddleStart
DrawPaddle
DrawBall

// switch buffer
ADDR [0CH, 8]
CTRL [0CH, 7]
EXE
CTRL [09, 7]
EXE

// long jump
DATA [LOOP]
ADDR [0, 8] CTRL [01, 7] EXE

strInfo:
"              attoPong 1.0              " $00
strInfo2:
"Programmed by Tomas \"Frooxius\" Mariancik" $00
strScore0:
"           Player 0 score: " $00
strScore1:
"           Player 1 score: " $00
endLine:
"           " $00
Last edited by Frooxius on Thu Oct 20, 2011 7:14 pm, edited 3 times in total.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Dylan
Box Fox
Posts: 2275
Joined: Fri Jul 10, 2009 12:31 am
Location: Austin, Texas

Re: AttoWPU - my own processor and programming language :3

Post by Dylan »

weird...gonna give a try once it finishes downloading.
Image
Make Pasta not war.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Yes. This is weird in purpose.

Anyway, I'm probably going to please and horrify most memebers of the furry fandom here at the same time. One of the WPU's (processors) I'm planning, will make every furry want to learn assembly programming. Image Just head on to the http://wpu.solirax.org and look at the second planned WPU (processor). That's right! We'll do science with fur! Quite literally actually. Image
Yes, I am serious, there will be such processor in the near future. Well... as much as serious as crazy computer scientist can get. Image
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Sleet
Bringing Foxy Back
Posts: 17291
Joined: Thu Apr 29, 2010 1:32 am
Location: Nephelokokkygia
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Sleet »

Furry processor? That is the most awesomely superfluous thing I have ever heard. ^_^
Image
Questions? Comments? Concerns? Friendly banter? Feel free to click the "PM" button below!
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Well actually, it will be somewhat useful... well the stuff that you'll produce by programming it. Well sort of useful, basically, it will be on similar level (or kind) of usefulness as some nice drawing is.

But don't expect it in a few weeks. Processor architecture and programming language (there will be two actually, one furry low level assembly programming language and another high level furry programming language) are not something you (well I) can design in a few days or a few weeks. The basic idea took some time to form, then I have to design architecture, programming language, check if everything makes sense, write documentation, start programming several apps (assembler, compiler, emulator), then program some examples in that language to test the tools and show others how to program for it, create website, write down presentation, publish it on various places, write some tutorials and that's just one of a few dozen projects I have in my head gurhl Image (well not only head, it's a figure of speech, since there is already some work done on some of them)
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Dylan
Box Fox
Posts: 2275
Joined: Fri Jul 10, 2009 12:31 am
Location: Austin, Texas

Re: AttoWPU - my own processor and programming language :3

Post by Dylan »

I noticed that my netbook screen is too small to get the whole window. :o
Image
Make Pasta not war.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Yeah, for now, you need at least 1280x800 px, but the GUI isn't tuned for now, because the project is still under development and I rather focus on internal stuff for now. I'll tune it later, so it works also on lower resolutions.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Dylan
Box Fox
Posts: 2275
Joined: Fri Jul 10, 2009 12:31 am
Location: Austin, Texas

Re: AttoWPU - my own processor and programming language :3

Post by Dylan »

Frooxius wrote:Yeah, for now, you need at least 1280x800 px, but the GUI isn't tuned for now, because the project is still under development and I rather focus on internal stuff for now. I'll tune it later, so it works also on lower resolutions.
ah well, I'll use it on my main computer then.
Image
Make Pasta not war.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

I've got some good news regarding the project. Today, I won a programming competition with it today Image Which means, that I don't have to do entrance exams for the university I am going to, they'll take me without them Image Actually, I was told by quite a lot people already, that it surpasses even many dissertations and it's on a scientific level Image
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Sleet
Bringing Foxy Back
Posts: 17291
Joined: Thu Apr 29, 2010 1:32 am
Location: Nephelokokkygia
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Sleet »

That's so cool! You're amazing!
Image
Questions? Comments? Concerns? Friendly banter? Feel free to click the "PM" button below!
Daggy
Posts: 776
Joined: Thu May 12, 2011 9:31 pm

Re: AttoWPU - my own processor and programming language :3

Post by Daggy »

That's actually really cool. Congrats on that!

Couldn't imagine making my own programming language. I've only dabbled in programming, and only really simple Java applications. Nothing nearly this involved.
User avatar
RandomGeekNamedBrent
laughing maniacally
Posts: 21032
Joined: Mon Jan 24, 2011 10:42 pm
Location: an invisible, flying volcano over Virginia

Re: AttoWPU - my own processor and programming language :3

Post by RandomGeekNamedBrent »

Daggy wrote:That's actually really cool. Congrats on that!

Couldn't imagine making my own programming language. I've only dabbled in programming, and only really simple Java applications. Nothing nearly this involved.
I wish to express this exact same sentiment.
Paradigm Shift by me
I do not actually believe any of what I'm saying.
RP character sheets
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Congrats Frooxius! :D
I may play around with this. That data bus format looks quite useful.
Image
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Thanks, but "the data bus format"? No offense, but that doesn't make much sense. Can you reword/elaborate?
But if you write some code (or anyone else) in my programming language, then post it :3

I still can't wait till somebody else actually writes some code in my language for my processor, even if it's a simple one, although I guess only geeks would be able to do that :geek: well, basically, one of it's purposes is to be a fun toy for computer geeks, which brings me to question: are any here? I would appreciate any feedback and commentary on this processor and programming language Image
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Challenger01
Posts: 537
Joined: Wed Sep 08, 2010 11:29 am
Location: Not an igloo

Re: AttoWPU - my own processor and programming language :3

Post by Challenger01 »

Why aren't you getting paid for something like this?! That's freaking cool!
Image
I'm going to go to a Furry Convention wearing a shirt that says "I'm a Furry. All I do I Pawrty" Please tell me you get that joke.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Because this particular project isn't created as end product for the marketplace, it's rather computer-scientific research... well... actually that doesn't answer the question, because people get paid for doing research...
However, as the matter of fact, I already got some job offer (basically creating some solution for IT universities for students to study assembly programming and processors... it's funny, I haven't even finished secondary school and I might (if I take the offer) already design and implement something, that will be used to teach IT college students Image ) based on this project and I was told that I'll probably get more of them soon, possibly some grants for the research.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
ReCreate
Posts: 1415
Joined: Sun Mar 28, 2010 6:09 pm
Location: http://bordomirc.co.cc
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by ReCreate »

Wow. It's neat to finally see this (near) completion.(well.. relatively?) I think I recall back to when you first started talking about the idea of this.(or something along those lines) :P I always knew you were a genius. Unfortunately I don't(and probably will never <_<) have such extensive knowledge and understanding to.. understand this. D: It's so intriguing. Oh well.
Don't let others define you, Only you can determine your fate
no longer active, sorry
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

ReCreate: yes, I even showed it in the IRC, which reminds me, that I told some people that I'll tell them when it's done...

Anyway, somebody recently (a few dozen minutes ago) attempted to write Hello World code for my processor. In case anybody here tried to do same thing as the first app... well I don't recommend it, because it's a little bit more difficult for a first app, I recommend trying to light up a LED or something like that. For illustration, I wrote the Hello World in my language myself:

Hello World in AttoASM (my programming language) for AttoWPU (my processor architecture)

Code: Select all

/* Hello World in AttoASM by Frooxius, slightly optimized, 5/20/2011, www.attowpu.solirax.org */

EXE { CTRL+7(2) ! }		// execute command

ADDR+4 [01H, 4]		// attocode memory
CTRL+3 [01H, 4]		// write new address
DATA [TEXT]
EXE

DATA+24 1(8)	// prepare for data exchange

LOOP:

// cleanup after jump
CTRL+7 0
ADDR+4 [05H, 4]		// out register
CTRL+3 [00H, 4]		// stop the output
EXE

// Write the character
ADDR+4 [01H, 4]		// attocode memory
CTRL+3 [03H, 4]		// output addressed data
EXE

ADDR+4 [0BH, 4]		// address text display
CTRL+3 [03H, 4]		// write character and increment address
EXE

// Maintain the loop if end of string wasn't reached yet

ADDR+4 [01H, 4]		// address attocode memory
CTRL+3 [07H, 4]		// move to the next element
EXE

ADDR+4 [02H, 4]		// address TEMP register
CTRL+3 [03H, 4]		// write value without mask from the databus
EXE

ADDR+4 [01H, 4]		// attocode memory
CTRL+3 [00H, 4]		// stop data output
EXE

ADDR+4 [04H, 4]		// address ALU
CTRL [29H, 7]		// ZeroSet
DATA [ENDLOOP]
EXE
CTRL [2AH, 7]		// NotZeroSet
DATA [LOOP]
EXE

CTRL 000	// clear three MSB

DATA+24 1(8)	// prepare for data exchange

ADDR+4 [05H, 4]		// OUT register
CTRL+3 [01H, 4]		// output its contents
EXE

ADDR+4 [00H, 4]	// aPC
CTRL+3 [01H, 4]	// write new address from the databus
EXE

ENDLOOP:

// cleanup after jump
CTRL+7 0
ADDR+4 [05H, 4]		// out register
CTRL+3 [00H, 4]		// stop the output
EXE

// infinite loop to stop the program from executing following (nonexistent - gibberish) code
AJMP [INFLOOP, 15]
INFLOOP:
AJMP+15(2) !

text:
"Hello world" $00
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

*pokes Obbl* Image

Soo... have you tried writing anything? (you still didn't answer my previous question about the bus too). Would you mind showing it? Also any commentary, feedback? No? Image
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Hmm, you're right, I should probably try actually writing some of my own code instead of just reading over yours. I'll just do something simple like some math formula. Yeah, that sounds like fun actually. I'll get on that. :)

What I meant with the "bus format" was just the way it gives a lot of control over how things get executed. Sometimes I like the abstraction from execution that higher level languages provide, but sometimes I like to be real close to the hardware (so to speak) where I can say what happens and how it happens (as much as I can, since the lower levels can still choose to optimize my code, but I can't do much about that ;) ) So it's nice to feel like I'm a bit more in control of the code :D
Image
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Just something that's being brought to my attention as I work on a factorial calculator, Temp (ADDR 02) is not very useful as a temp register because it is one of the operands for the ALU. It has to remain free in ALU intensive programs (i.e. calculating the factorial). So I create a "temp" in the actual registers, but it is harder to access (which is why, I assume, you made Temp in the first place :lol: ). Just an observation I've made (which is about to become something of a pain, as I realize I need to shuttle things from mem to reg and back -_- ).

Edit: although, I will say it's forcing me to be rather creative ;)
Image
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Cool, factorial calculator :3

Well it's obvious that you'll need more than one registers for most of the code, so TEMP won't suffice, that's why is there register memory - you can allocate it the way you want, instead of me providing some set of standalone registers (keep in mind, that it tries to create "hardcore programming" enviroment, so you have to do may things by yourself).

But I don't know, what's "Temp (ADDR 02) is not very useful as a temp register" supposed to mean, because it's quite heavily used for various sorts of things. TEMP means, temporary, so it holds various temporary values (that exist only shortly, unless you store them in some actual memory) - either for calculations or when you need to transfer a value from one location to another and you need to temporarily store the value somewhere (because you must change the value on the data bus to some address for example) and so on - it all depends on what you're coding and you said it yourself - you do heavy arithmetic code, so you use it most (or all) the time to store the operand (which is temporary value too, isn't it?), but if you were coding something else, you would use it differently.

Yes, you need to shuffle things a lot around, but yes - be creative and find the best way to either make the programming easier, or minimize the amount of operations - sometimes, it's better to try to reorder some operations (but not always possible of course). For example, you might use the symbols in the AttoASM language to create some commonly used patterns (you can even use symbol redefinition to pass an argument to another symbol, as I did in the AttoPong).

But I'm glad you're playing with it, thanks Image
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Well, It's just that I would like to be able to dump a value into Temp when I need to, but every other command is for the ALU. Since the ALU requires the use of Temp, I can't just hold random values there when I need to. I have to leave it open for values I'm about to add or multiply. So I can't really use it as a Temp register as I would like to.

I'm coming up with ways to work around this, but I think it would be nice if Temp wasn't required for the ALU.

Edit: It's like having a temp for my Temp :lol:
Image
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Well TEMP was created to be really very temporary - the value will change all the time. If you want to store some values permanently, you have to create your own registers.
You know, TEMP is not usual register as you might know it (for storing various variables), but rather for temporarily holding value from the bus, only to release it quickly after and replace if another one.

Remember, that philosophy of AttoWPU is absurd minimization, so even the TEMP is more temporary, than you might expect and the TEMP you want, is actually more permanent, for which you have the register memory.

If I added another standalone register, one for ALU/FPU and one for values, I would go against the philosophy of the AttoWPU - I intentionally made it this way, so programmers have to come up with a way to overcome it's obstacle.

So yes, it would be nice (for the programmer) if the register wasn't required for ALU and there was another one, but AttoWPU is trying to achieve actually the opposite (extreme programming), so I didn't make it nice on purpose (there are tons of other things that could be changed too, to make it nice). Remember that WPU's also go beyond conventions - things that are normal and usual, for example, being nice to programmers. But only by being stripped of that, you may realize what the conventional architectures actually offer you (things you took for granted) and you'll be forced to work your own way around that.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

O-o my head hurts

I know some HTML and CSS but those have nothing to do with programming, I have learned a little bit of actionscript though and I have to say, this is way to complicated for me =S
Sent from my conifer.
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Frooxius wrote:Remember, that philosophy of AttoWPU is absurd minimization, so even the TEMP is more temporary, than you might expect and the TEMP you want, is actually more permanent, for which you have the register memory.

If I added another standalone register, one for ALU/FPU and one for values, I would go against the philosophy of the AttoWPU - I intentionally made it this way, so programmers have to come up with a way to overcome it's obstacle.
You, sir, are ingeniously evil. :twisted:
However, I have finished the formula part, and now must do the user input/output and extra memory handling parts. Whee. :lol:
yehoshua wrote:O-o my head hurts

I know some HTML and CSS but those have nothing to do with programming, I have learned a little bit of actionscript though and I have to say, this is way to complicated for me =S
You know, the funny thing is that this is probably what I would have said just last year (maybe even last semseter). :D
Image
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

Seriousley, normally I can sort of understand what a script is saying even if I don't really know how to write it but this is just gibberish to me.
Sent from my conifer.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Obbl wrote:You, sir, are ingeniously evil. :twisted:
Thanks Image Muha ha ha ha ha Image

Anyway, are you studying computing at the university then? That's what's waiting for me the next school year, I'm still at secondary school (next week is last graduating exam), and mostly self taught. Image

yehoshua: well it requires some knowledge about assembly programming (and also digital circuits), which is low level programming language and according to many people, very difficult one, although I myself don't see anything complex on it, rather tedious, but the concept is quite simple, in my opinion.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

Ok, well I'm sure that in the future it won't be too challenging for me, I'm only 14 though :)

ps. how are you putting in those smileys?
Sent from my conifer.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Well, it might not be challenging in the future, but there is plenty of professional programmers, who don't know assembly programming and stick to high level languages, because they're much easier (apparently, I don't know myself, it's all the same to me).

Smileys are from the Housepets Emoticon Pack I created
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

Frooxius wrote:Well, it might not be challenging in the future, but there is plenty of professional programmers, who don't know assembly programming and stick to high level languages, because they're much easier (apparently, I don't know myself, it's all the same to me).

Smileys are from the Housepets Emoticon Pack I created

Wow, that's very impressive, kudos.
Sent from my conifer.
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Frooxius wrote:
Obbl wrote:You, sir, are ingeniously evil. :twisted:
Thanks Image Muha ha ha ha ha Image

Anyway, are you studying computing at the university then? That's what's waiting for me the next school year, I'm still at secondary school (next week is last graduating exam), and mostly self taught. Image

yehoshua: well it requires some knowledge about assembly programming (and also digital circuits), which is low level programming language and according to many people, very difficult one, although I myself don't see anything complex on it, rather tedious, but the concept is quite simple, in my opinion.
Yes, I am studying programming. I'm finally starting to get into the science behind it all (instead of just how to program) which has been most interesting :geek:

Question: When reading in user input, what character does each switch map to? Also, when I execute the Read key command, does it wait for the user to press a key or do I have to poll until I receive input?
Image
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Switches are not mapped to characters, you click them with the mouse. For now, the keyboard controller returns only the current state of the keyboard (at the time you execute that command), similarly to a primitive keyboard you might use with some MCU's, so currently there's no other way, than to check every cycle, because there are no interrupts (but I'm working on a interrupt unit, this is one of the unfinished parts I'm afraid (remember that it's in the alpha state, so there are some more units coming, including a sound generator and probably simple graphic accelerator/chip/blitter)).
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
Obbl
Smiley McSmiles
Posts: 3234
Joined: Tue Apr 27, 2010 1:56 pm
Location: The Housepets Forum ^^

Re: AttoWPU - my own processor and programming language :3

Post by Obbl »

Ah! That makes a bit more sense :D
So then, what are the keyboard key scan codes (You have the numeric key codes, but not the keyboard)
Image
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Sorry, alphanumeric keyboard scancodes aren't decided yet, so they're not in the specification, for now, they're aligned to alphabet starting with a = 0 (but that means, you cannot detect a for now actually), b = 1, c = 2 ...
You can actually find them out yourself easily - simply write a code, that will constantly copy the ReadKey value to the LEDs and then run it fast enough (1 Mhz for example) and press various keys and it will show on the LEDs, as well as on the region containing info about the bus.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

I have been thinking and I want to start learning a programming language outside of AS3, what do you say? Should I try my hand at AttoWPU or learn Python first? Are they in any way similar?
Sent from my conifer.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Image They're completely different. Go for Python if you want, good scripting language, it's syntax enforces good code formatting (mandatory indents that are part of the syntax for example), which is certainly very good thing for beginner to learn.

But you should aim on learning programming in general and thinking algorithmically and use the language to create stuff, so you get into it and understand how it really works and how you transfer various problems and their solutions into a code.

Experienced programmers don't bond with a specific language, because languages are rather tools and you have to know how to use tools to create something. For example, I can learn a new programming language very quickly (a few days for complex ones), but you should probably focus on one. There are other languages besides Python, it depends on what your current skill is and what do you actually want to do.

AttoASM would be certainly a horrible choice for a beginner, because it's difficult and experimental, more like a interesting thing and a toy of more experienced programmers who also have some knowledge in digital electronics and assembly programming.
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

Oh, ok I see. Someday I swear I will learn AttoWPU!!! (or at least come to understand it)

I also want to become a programmer :)
Sent from my conifer.
User avatar
Frooxius
Posts: 311
Joined: Tue Jul 28, 2009 6:00 pm
Contact:

Re: AttoWPU - my own processor and programming language :3

Post by Frooxius »

Good, but keep in mind, that by that time, I'll have more own programming languages (most of them experimental, but I'm also beginning to work on one, that will have very practical use in game development... well it won't be exactly programming language) and much more interesting than AttoASM Image AttoASM is just the start and the next one, which I'm currently working on, is really making me excited Image, because it will change the usual program flow and introduce interesting new constructs. Image I'm working on it whenever I can, for example, I had written graduating exams today and during the breaks, I was working on the processor and the language Image (classmates made funny remarks, how everybody is focusing and preparing on the exams, while I do "my programming stuff" x3 ).

Also, regarding this community, the FluffyWPU I have planned will be very interesting, along with the Fluffsembler (FluffASM) language (low level language) and higher level language for the FluffyWPU, which I don't know how to name yet. Image
Image
hug_overflow.asm wrote: LOOP: HUG #Peanut, #Grape
PUSH ACC
JMP LOOP
User avatar
yehoshua
Posts: 1984
Joined: Wed May 25, 2011 7:32 pm
Location: Canananada

Re: AttoWPU - my own processor and programming language :3

Post by yehoshua »

Fluffy? I would like to see that :)
Sent from my conifer.
Post Reply