HALT NOP SPEED COPYLR COPYLA COPYAR COPYRR ADDLA ADDRA SUBLA SUBRA ANDLA ANDRA ORLA ORRA XORLA XORRA DECR INCR DECRJZ INCRJZ SHIFTRL SHIFTRR CBR SBR BCRSC BCRSS JUMP CALL RETLA RETURN ADDRPC INITSP RANDA
// Some handy constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 speed 135 // make things slow enough so that humans can play // ball starts on right :ballStartsOnRight copylr 1 dataLedRegister // ball goes left :ballGoesLeft shiftrl dataLedRegister // is the ball at the left player? :ballAtLeftPlayer bcrss 7 dataLedRegister jump ballAlmostAtLeftPlayer // nope. Not yet. // Did the player hit the ball? bcrss 7 buttonRegister jump leftPlayerMissed // nope. left player misses. jump ballStartsOnLeft // yes. Start sending the ball back. // is the ball almost at the left player? :ballAlmostAtLeftPlayer bcrss 6 dataLedRegister //nope. not yet. jump ballGoesLeft // Did the player swing and miss at the ball? bcrss 7 buttonRegister jump ballGoesLeft // nope. Ball continues on. jump leftPlayerMissed // yep. Left player misses. :leftPlayerMissed halt // ball starts on left :ballStartsOnLeft copylr 128 dataLedRegister // ball goes right :ballGoesRight shiftrr dataLedRegister // is the ball at the right player? :ballAtRightPlayer bcrss 0 dataLedRegister jump ballAlmostAtRightPlayer // nope. Not yet. // Did the player hit the ball? bcrss 0 buttonRegister jump rightPlayerMissed // nope. left player misses. jump ballStartsOnRight // yes. Start sending the ball back. // is the ball almost at the right player? :ballAlmostAtRightPlayer bcrss 1 dataLedRegister //nope. not yet. jump ballGoesRight // Did the player swing and miss at the ball? bcrss 0 buttonRegister jump ballGoesRight // nope. Ball continues on. jump rightPlayerMissed // yep. Left player misses. :rightPlayerMissed halt
// This game starts with a single bit (LED) lit and continually shifts left. // The aim of the game is to press any of the data input buttons, when the // corresponding LED is lit to turn it off. Once all LED's are off - you have won // the game. If you press the button when the LED is off - the LED will turn on // and you will have more LED's to now 'kill'. // Constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) speed 32 copylr 1 dataLEDRegister // Main loop (this code runs repeatedly until power is removed) :Loop shiftrl dataLEDRegister copyra buttonRegister xorra dataLEDRegister copyar dataLEDRegister jump loop
// This program will scroll through a sequence of 8 bytes which contains // the information to draw an 8x8 smiley face. The information is sent to the // 8 data LED's and when the Digirule is waved in the air (in a dark - or // semi-dark room) you will see a smiley face been drawn in the air. // NOTE: when you run the program, you will need to turn the address LED's off // by pressing the 'goto' button. // Constants %define numberToAddToProgramCounter 240 %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) initsp speed 1 copylr 0 numberToAddToProgramCounter // Main loop (this code runs repeatedly until power is removed) :Loop call SmileyFaceData copyar dataLEDRegister copyra numberToAddToProgramCounter addla 2 copyar numberToAddToProgramCounter jump loop // Padding 0 0 0 0 0 0 0 0 0 0 0 0 0 0 :SmileyFaceData addrpc numberToAddToProgramCounter retla 126 retla 129 retla 165 retla 129 retla 165 retla 153 retla 129 retla 126 nop copylr 0 numberToAddToProgramCounter jump SmileyFaceData
// This program is a simple 8 bit counter that starts at 00000000 // and counts all the way up to 11111111, then starts again. // Constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) speed 130 copylr 0 dataLEDRegister // Main loop (this code runs repeatedly until power is removed) :Loop incr dataLEDRegister jump loop
// This program is a simple 16 bit counter that starts at 0000000000000000 // and counts all the way up to 1111111111111111, then starts again. The upper // 8 bits are shown on the address LED's, while the lower 8 bits are shown on // the data LED's // Constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) speed 13 sbr 2 statusRegister copylr 0 dataLEDRegister copylr 0 addressLEDRegister // Main loop (this code runs repeatedly until power is removed) :Loop incrjz dataLEDRegister jump Loop incr addressLEDRegister jump Loop
// For those old enough to remember programming in binary should also remember // the TV series 'Knightrider'. The car (called KITT) had a row of lights // on the front which cycled back and forth. This program does the same sort // of thing using the 8 data LED's on the Digirule2. // Constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) speed 20 copylr 1 dataLEDRegister // Main loop (this code runs repeatedly until power is removed) :Loop shiftrl dataLEDRegister bcrss 7 dataLEDRegister jump Loop :ShiftRightLoop shiftrr dataLEDRegister bcrss 0 dataLEDRegister jump ShiftRightLoop jump Loop
// This program continually sends the state of the 8 data buttons // to the data LED's, so when a button is pressed - the corresponding LED // will light up. // Constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) speed 1 // Main loop (this code runs repeatedly until power is removed) :Loop copyrr buttonRegister dataLEDRegister jump Loop
// This is a simple game whereby a single LED will cycle back and forth. // Your task is to 'shoot' the lit LED by pressing a data button that // corresponds with the lit LED. if you get a 'hit' you will get a point. // The points are tallied on the address LED's in binary. If you shoot and // miss, you will lose all of your points. // Some handy constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) initsp speed 17 sbr 2 statusRegister copylr 0 addressLEDRegister copylr 1 dataLEDRegister // Main loop (this code runs repeatedly until power is removed) :Loop shiftrl dataLEDRegister call CheckButtons bcrss 7 dataLEDRegister jump Loop :ShiftRightLoop shiftrr dataLEDRegister call CheckButtons bcrss 0 dataLEDRegister jump ShiftRightLoop jump Loop :CheckButtons copyra buttonRegister addla 0 bcrsc 0 statusRegister return //padding 0 andra dataLEDRegister bcrsc 0 statusRegister jump 0 incr addressLEDRegister return
// This program flashes groups of four LED's in th address and data LED // rows, to (sort of) make it look like police lights. // Some handy constants %define statusRegister 252 %define buttonRegister 253 %define addressLEDRegister 254 %define dataLEDRegister 255 // Setup (this code runs once) speed 162 sbr 2 statusRegister // Main loop (this code runs repeatedly until power is removed) :Loop copylr 15 dataLEDRegister copylr 240 dataLEDRegister nop // For loop symmetry copylr 15 addressLEDRegister copylr 240 addressLEDregister jump Loop
All trademarks, service marks, trade names, trade dress, product names and logos appearing on the site are the property of their respective owners.
Any code you enter remains yours.
Page constructed by lzcd.
Upgrades by Andrew Yeomans.