;; Emacs Mode Selection Info: -*-mode: ASM; coding: iso-latin-1-dos;-*- * ;; ******************************************************************************************** ;; File Name: Four_2.asm ;; Auther: John L. Weinrich ;; Date: 01/31/03 ;; Useage 4004 TIC-TAC-TOE Game ;; Description: ;; ;; This routine is used for testing the hardware on the 4004 TIC-TAC-TOE Game. ;; ;; Assumptions: ;; This assembly code and all the included files assume the following: ;; ;; RAM Memory: 2048 X 4 (8 RAM banks, 4 RAMs/bank, 4 registers/RAM, 16 Char/Reg) ;; 256 status characters. ;; 2 I/O Port ;; RAM1: SPEAKER PITCH/write ;; RAM2: SPEAKER LEVEL/write ;; ;; ROM Memory: 4096 X 8 (16 ROMs @ 256 locations ;; 11 I/O Ports (3 - R/W, 4- Read, 4 - Write) ;; ROM0: MISC/read ;; ROM0: MISC/write ;; ROM3: DISPLAY HIGH IN/read ;; ROM3: DISPLAY HIGH OUT/write ;; ROM4: DISPLAY LOW IN/read ;; ROM4: DISPLAY LOW OUT/write ;; ROM5: KEYBOARD HIGH INPUT/read ;; ROM6: KEYBOARD LOW INPUT/read ;; ROM7: MISC2/write ;; ROM8: PAGE/write ;; ROM9: RANDOM NUMBER GENERATOR/read ;; ROM10: FPGA VERSION/read ;; ;; See "4004 FPGA Design" and "4004 Software Design " documents for more detail information. ;; ;; Registers used: ;; Memory used: ;; Entrance parameters: ;; Exit parameters: ;; Labels used: ;; ******************************************************************************************** ;; ******************************************************************************************** ;; Here are the assembler directives ;; What CPU to assemble for and where in memory to start ;; Also there is the all the include files ;; except subroutines. include "four_ALL.equ" ; Get all equates include "bitfuncs.inc" ; Include bit functions so that fin can be ; loaded from a label (upper 4 bits of address ; are loped off) include "four_02.equ" ; Get Page #2 equates cpu 4004 ; Tell assembler that the processor is a 4004 org CODE_LOCATION ; Set code start location in memory ;; ******************************************************************************************** ;; This is the begining of the test routine ;; ******************************************************************************************** ;; Run Built In Test on RAM RunBIT jms BIT ; Call BIT ;; Initialize hardware and software SoftStart jms InitSWHW ; Call initialize software routine ;; Next, initialize the display and get it ready for data jms DisplayModeCMND ; Set the display to command mode jms InitDisplay ; Initialize display jms SetCGRAM ; Set display to CG RAM jms DisplayModeData ; Set the display to data mode jms LoadCGRAM ; Load display CD RAM with special charactors jms DisplayModeCMND ; Set the display to command mode jms SetDDRAM ; Set display back to DD RAM jms DisplayModeData ; Set the display to data mode ;; Initialize keyboard jms InitKYBD ; clear out any key presses ;; Initialize the speaker to a mid tone and turn off jms InitSpeaker ; Initialize speaker ;; turn off the DONE LED PresetLED jms DoneLEDOff ; Turn done LED off ;; ******************************************************************************************** ;; Display state of BIT ;; ;; Clear display jms DisplayModeCMND ; Put the display into command mode jms ClearDisplay ; Clear the display jms DisplayModeData ; Put the display back to data mode ;; Display BIT header jms DisBIT ; Display the BIT message ;; Turn on green done LED jms DoneLEDOn ; Turn done LED on jms DoneLEDGreen ; and make it green to show PASS ;; Check display status clb ; Make sure accumulator is clear ld UTILITY_0_L ; Get BIT result rar ; Select the display status bit jcn NC,DisIsGood ; Check for pass/fail of memory test jms DoneLEDOn ; Turn done LED on jms DoneLEDRed ; If fail, set done LED to red jms DisDisFail ; Display is bad, display FAIL jun CheckMem ; Go onto next test DisIsGood jms DisDisPass ; Display is good, display PASS ;; Check memory status CheckMem clb ; Make sure accumulator is clear ld UTILITY_0_L ; Get BIT result rar ; Select the RAM test status bit rar ; " " jcn NC,MemGood ; Check for pass/fail of memory test jms DisMemFail ; Memory is bad, display FAIL jms DoneLEDOn ; Turn done LED on jms DoneLEDRed ; If fail, set done LED to red jun DisplayRNGStat ; Go onto next test MemGood jms DisMemPass ; Display the RAM PASS message ;; Check memory status DisplayRNGStat clb ; Make sure accumulator is clear ld UTILITY_0_L ; Get BIT result rar ; Select the RAM test status bit rar ; " " rar ; " " jcn NC,RNGGood ; Check for pass/fail of memory test jms DisRNGFail ; Memory is bad, display FAIL jms DoneLEDOn ; Turn done LED on jms DoneLEDRed ; If fail, set done LED to red jun DisOpt ; Go onto next test RNGGood jms DisRNGPass ; Display the RAM PASS message ;; ******************************************************************************************** ;; Display state of option switches ;; DisOpt jms DisOptSw ;; Set the RAM bank ldm RAM_BANK_0 ; Move RAM bank pointer to ACC dcl ; Select RAM bank ;; Check option 2 switch fim SRC_P,OPTION_2_RAM ; Get pointer to option awitch RAM src SRC_P ; Select RAM, RAM REG, & RAM CHAR clb ; Make sure accumulator is clear rdm ; Get option switch settings from RAM jcn NZ,Switch2Set ; Test option switch #2 jms DisOptSw0_ ; Switch #2 is zero, display it jun CheckSw1 ; Jump to check switch #1 Switch2Set jms DisOptSw1_ ; Else, switch #2 is one ;; Check option 1 switch CheckSw1 fim SRC_P,OPTION_1_RAM ; Get pointer to option awitch RAM src SRC_P ; Select RAM, RAM REG, & RAM CHAR clb ; Make sure accumulator is clear rdm ; Get option switch settings from RAM jcn NZ,Switch1Set ; Test option switch #1 jms DisOptSw_0 ; Switch #1 is zero, display it jun DisVer ; Jump to display S/W & H/W versions Switch1Set jms DisOptSw_1 ; Else, switch #1 is one ;; ******************************************************************************************** ;; Display software version ;; DisVer jms DisSWVer ; Display software version ;; ******************************************************************************************** ;; Display hardware version ;; jms DisHWVer ; Display H/W version fim UTILITY_1_P,L4C6 ; Set the display to line 4 & column 7 jms DisSetLineCol ; Call the routine to set the display cursor ldm RAM_BANK_0 ; Move RAM bank pointer to ACC dcl ; Select RAM bank fim SRC_P,FPGA_VERSION_RAM ; Get pointer to FPGA version RAM src SRC_P ; Select RAM, RAM REG, & RAM CHAR rdm ; Get FPGA version jms DisNibble2Hex ; Display the H/W version as hex ;; ******************************************************************************************** ;; Wait for prompt to continue ;; Prompt1 jms DisKeyPress ; Prompt user to press any key to continue ;; Turn off display cursor jms DisplayModeCMND ; Put the display into command mode jms OffCurDisplay ; Turn off display cursor jms CurBlinkOffDis ; Turn off display cursor blink jms DisplayModeData ; Put the display back to data mode jms Level5 ; Set level to "5" jms Pitch1116HZ ; Set pitch to "happy" jms Beep ; Tell user that key was pressed ;; Wait for key press jms GetChar ; Get charactor from keyboard jms Level5 ; Set level to "5" jms Pitch1116HZ ; Set pitch to "happy" jms Beep ; Tell user that key was pressed ;; Initialize keyboard jms InitKYBD ; clear out any key presses jun BITDone ; Go home