{"id":16706,"date":"2023-06-19T07:41:00","date_gmt":"2023-06-19T07:41:00","guid":{"rendered":"https:\/\/bryceautomation.com\/?p=16706"},"modified":"2023-06-30T04:09:57","modified_gmt":"2023-06-30T04:09:57","slug":"stopwatch-program-for-the-southern-cross","status":"publish","type":"post","link":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/","title":{"rendered":"Stopwatch Program for the Southern Cross"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction to my Stopwatch Program for the Southern Cross (Z80)<\/h2>\n\n\n\n<p>My Stopwatch Program for the Southern Cross is a very simple program.  In reality, it&#8217;s just one step above a &#8220;Hello World&#8221; program.  Once you get your Southern Cross Computer up and running, you will want to continue learning.  For example, you will want to display values on the display, and read from the keypad.  <\/p><div id=\"bryce-651690699\" class=\"bryce-afterfirst bryce-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-8316758073402323\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-8316758073402323\" \ndata-ad-slot=\"7728240895\" \ndata-ad-format=\"auto\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n\n<p>This is a simple program I put together to help others out.  It will demonstrate some of the most basic Z80 instructions.  Additionally, it will demonstrate how to perform some common system calls.<\/p>\n\n\n\n<p><em>** Note:  This was my first attempt at writing a program for the Z80 processor.  Since this program, I&#8217;ve learned that there are better programming practices.  These better practices reduce memory usage, and the number of machine cycles.   For example: OR A does the same as CP 0.  RST $30 will perform the same action as  CALL $30, using fewer resources.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"613\" height=\"329\" data-src=\"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/sccwholesmall.png\" alt=\"Stopwatch Program for the Southern Cross\" class=\"wp-image-16730 lazyload\" data-srcset=\"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/sccwholesmall.png 613w, https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/sccwholesmall-300x161.png 300w\" data-sizes=\"(max-width: 613px) 100vw, 613px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 613px; --smush-placeholder-aspect-ratio: 613\/329;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Overview of the Southern Cross<\/h2>\n\n\n\n<p>Basically, once you get the program into the SCC, you just press Function +0 to start your program.  The ROM lives in low memory, up to $1FFF.  (The $ indicates Hexadecimal) Your programs will start at $2000.  You can always enter a program through the keypad on the machine.  However, it&#8217;s much easier to write the code on another machine, and use an assembler.  In this case, I&#8217;m using z80asm from <a href=\"https:\/\/www.nongnu.org\/z80asm\/\">this link<\/a> in Linux.  I believe there are several other assemblers with the same name, but operate a little differently.<\/p>\n\n\n\n<p>Basically, when you assemble your project, your output needs to be in Intel Hex format.  After that, you can press Fn+1 on the SCC.  Finally, you can send your project to the SCC at 4800bps.  After the upload, you can press Fn+0 to run your program.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Head of my Stopwatch Program for the Southern Cross<\/h2>\n\n\n\n<p>In the heading I&#8217;ve put some notes that will help you out if you are running the same assembler in Linux.  Additionally, I&#8217;ve added some notes on how you might use other registers.  The ORG statement tells the assembler the memory location in which your project originates.  On the SCC, this will be $2000.  It&#8217;s important to realize that your commands cannot start on the very left of your editor.  Otherwise, the assembler will interpret the commands as a label.  Always leave an indent for commands.  Anything after a &#8220;;&#8221; is considered a comment.  In other words, the assembler ignores what&#8217;s after the semicolon.<\/p>\n\n\n\n<p>As you can see, I&#8217;ve created some labels for the delay times.  Since the stop watch is scan-based, you may need to adjust these if you change the program.  The first two delay times are nested (course adjust).  The third delay time is not (for fine tuning).  For example, if you remove the system call to beep the speaker each second, you will need to modify these delay times.<\/p>\n\n\n\n<p>If you are not familiar with Hexadecimal and Binary, read up on <a href=\"https:\/\/bryceautomation.com\/index.php\/2023\/04\/25\/how-numbering-systems-work\/\">How Numbering Systems Work<\/a> before you continue.<\/p>\n\n\n\n<p>You can save this code as &#8220;StopWatch6.z80&#8221; to follow the examples.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; STOPWATCH PROGRAM FOR SOUTHERN CROSS COMPUTER (Z80)\n; V 1.0 -- USING Z80ASM ASSEMBLER (LINUX)\n; https:\/\/www.nongnu.org\/z80asm\/\n; -- RICKY BRYCE\n\n\n; TO SET BAUD RATE IN LINUX FOR FIRST SERIAL DEVICE:\n; stty -F \/dev\/ttyUSB0 ispeed 4800\n\n; TO UPLOAD TO SOUTHERN CROSS:\n; cat stopwatch6.hex &gt; \/dev\/ttyUSB0\n\n; TO ASSEMBLE, CREATE INTEL HEX FILE, AND UPLOAD ALL AT ONCE, \n; CREATE EXECUTABLE SHELL CALLED INTELHEX:\n\n; .\/z80asm -i $1.z80 -o $1.bin\n; srec_cat $1.bin -binary -offset 0x2000 -output $1.hex -intel -address-length=2\n; cat $1.hex &gt; \/dev\/ttyUSB0\n\n; AFTER CREATING EXECUTABLE SHELL, JUST TYPE .\/INTELHEX STOPWATCH6\n; Z80 EXTENSION IS ASSUEMED AND IS PASSED TO SHELL FILE AS $1\n\n    ORG $2000\n; DEFINE PRESETS FOR NESTED DELAY LOOPS \n; THE COMBINATION OF THESE DELAYS SHOULD CAUSE THE DISPLAY COUNTER\n; TO INCREMENT EVERY SECOND (TRIAL AND ERROR)\n\n; ** BEGIN HEAD **\nDELAYTIME1: EQU $20 ; OUTER LOOP (NESTED LOOP)  NOBEEP $20\nDELAYTIME2: EQU $10 ; MIDDLE LOOP (NESTED LOOP) NOBEEP $12 WITHBEEP $10\nDELAYTIME3: EQU $78 ; INNER LOOP (NESTED LOOP)  NOBEEP $73 WITHBEEP $78\n\n; ** END HEAD **<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Initialize Registers and Memory<\/h2>\n\n\n\n<p>At this point, we&#8217;re just initializing the values of registers, and memory.  For the most part, we are setting everything to zero, except for the delay times.  Obviously, these will come from the presets above.  IX is an index register.  We use this for indexed addressing.  IX provides a base address, and then we can simply add or subtract an offset to reference a specific memory location.  Some of the labels reference Data Bytes (DB&#8217;s) at the end of this program.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ** BEGIN INITIALIZE **    \nINIT: ; INITIALIZE REGISTERS AND MEMORY\n    ; A IS THE 8 BIT ACCUMULATOR. THE AF REGISTER IS A PAIR,\n    ; BUT NOT USED AS A PAIR BECAUSE F CONTAINS STATUS FLAGS\n    ; IN OTHER WORDS A AND F ARE USED SEPARATELY AS BYTES\n    LD A,0 ; ACCUMULATOR\n    LD DE,0 ; NOT USED HERE (CAN HOLD 16 BIT ADDRESSES)\n    LD HL,0 ; 16 BIT REGISTER (FOR MEMORY ADDRESSES)\n    LD BC,0 ; NOT USED HERE (16 BIT BYTE COUNTER)\n    LD IX,COUNTER ; IX AND IY ARE INDEX REGISTERS\n    LD (IX+0),A ; FIRST DIGIT\n    LD (IX+1),A ; SECOND DIGIT\n    LD (IX+2),A ; THIRD DIGIT\n    LD (IX+3),A ; FOURTH DIGIT\n    LD IX,DELAYTIME ; IX AND IY ARE INDEX REGISTERS\n    LD (IX+0),DELAYTIME1 ; OUTER DELAY LOOP\n    LD (IX+1),DELAYTIME2 ; MIDDLE DELAY LOOP\n    LD (IX+2),DELAYTIME3 ; INNER DELAY LOOP (ALSO SCANS DISPLAY)\n    ; OTHER 8 BIT REGISTERS\n        ; I - INTERRUPT VECTOR (INTERRUPT 2 MODE)\n        ; R - REFRESH REGISTER FOR DRAM -- ALSO USED FOR RANDOM NUMBERS\n        ; IXL, IXH, IYL, IYH ARE LOW AND HIGH PORTIONS OF IX AND IY\n    ; OTHER 16 BIT REGISTERS\n        ; PC -- PROGRAM COUNTER\n        ; SP -- STACK POINTER\n    ; OTHER NOTES\n        ; BC CAN BE USED AS SEPARATE 8 BIT REGISTERS\n            ; B -- BYTE COUNTER\n            ; C -- PORT NUMBER FOR I\/O PORTS\n; ** END INITIALIZE **  <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">First System Calls in my Stopwatch Program for the Southern Cross<\/h2>\n\n\n\n<p>Here, we will wait for a keypress.  This can be any key.   First, we clear the display buffer.  The monitor entry point is $30.  We need to load a function into the C register to tell the monitor which function we wish to perform.  You will find the function calls in the Southern Cross user manual on <a href=\"https:\/\/github.com\/crsjones\/Southern-Cross-Computer-z80\/tree\/main\/Docs\">Craig Jones&#8217; Github Page.<\/a><\/p>\n\n\n\n<p>After clearing the display buffer, we simply load the memory address of our counter label into the HL register, and perform a DISADD function through the monitor.  This converts the counter&#8217;s memory to an LED bit pattern that your 7 segment displays need to show the proper number.  After that, we scan the display until the user presses then releases a key.  Finally, we perform a system call that causes your speaker to beep.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ** WAIT FOR KEYPRESS **   \nKEYWAIT:\nPRESS:\n    LD C,$04  ; CLEAR DISPLAY BUFFER (FUNCTION CODE 4)\n    CALL $30  ; SYSTEM CALL\n    LD A,0    ; NOW, WRITE ZEROS TO THE DISPLAY\n    LD HL,(COUNTER) ; LOAD THE COUNTER INTO HL\n    LD C,$02  ; FUNCTION CALL FOR DISADD (CONVERT ZEROS TO 7 SEGMENT DISPLAY PATTERN)\n    CALL $30  ; PERFORM SYSTEM CALL\n    LD C,$09  ; FUNCTION CODE FOR SKEYIN (WAIT FOR KEYPRESS)\n    CALL $30  ; PERFORM SYSTEM CALL\n    LD C,$0A            ; SKEYREL -- SCAN DISPLAY UNTIL KEY RELEASED\n    CALL $30            ; SYSCALL\n    LD C,$15  ; FUNCTION CODE FOR BEEP\n    CALL $30  ; SYSTEM CALL\n; ** END WAIT FOR KEYPRESS **\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Main Routine<\/h2>\n\n\n\n<p>I&#8217;ve chosen to divide this program into subroutines.  For me, this is easier to troubleshoot when I have a problem.  The following logic in the Main Routine performs most of the work as far as incrementing the value.  It will call other routines later on that scan the display.  Additionally, there is a subroutine to cause a delay so our clock only has one increment each second.<\/p>\n\n\n\n<p>By this time, you should be starting to get familiar with the code.  Try to decipher what is happening within the main routine.  The comments should help you out.  The term &#8220;Nybble&#8221;, or &#8220;Nibble&#8221; simply means 4 consecutive bits of information that make up a Hexadecimal digit. <\/p>\n\n\n\n<p>If you need some help with some of the instructions, check out the <a href=\"https:\/\/www.zilog.com\/docs\/z80\/um0080.pdf\">Z80 User Manual.<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ** BEGIN MAIN ROUTINE **\nBEGIN:\nFIRSTDIGIT:\n    CALL DELAY       ; DELAY TO CALIBRATE FOR SECONDS\n    LD A,(COUNTER)   ; LOAD ACCUMULATOR WITH LOWER BYTE INTENDED FOR DISPLAY\n    INC A            ; INCREMENT LOWER BYTE\n    LD (COUNTER),A   ; SAVE ACCUMULATOR TO LOWER BYTE\n    AND $0F          ; MASK OUT UPPER NYBBLE\n    CP $0A           ; Compare:  CHECK FOR $0A\n    JP NZ,BEGIN      ; IF NOT YET $0A, CONTINUE\n    LD A,(COUNTER)   ; RELOAD ACCUMULATOR WITH LOWER BYTE\n    ADD A,6          ; IF &gt; 9 THEN ADD 6 (COUNT IN DEC)\n    LD (COUNTER),A   ; STORE ACCUMULATOR TO LOWER BYTE\n    AND $F0          ; MASK OUT LOWER NYBBLE.  Each bit of A is ANDed with $F0\n    CP $A0           ; CHECK TO SEE IF HIGH NYBBLE IS A-F\n    JP NZ,BEGIN      ; IF NOT, THEN CONTINUE\n    LD A,0           ; LOAD ACCUMULATOR WITH ZERO\n    LD (COUNTER),A   ; RESET LOWER BYTE OF COUNTER (COUNTING SECONDS) TO ZERO\n    \nSECONDDIGIT:\n    LD A,(COUNTER+1) ; LOAD HIGH BYTE OF SECONDS COUNTER TO ACCUMUATOR\n    INC A            ; INCREMENT THE ACCUMULATOR\n    LD (COUNTER+1),A ; STORE THE INCREMENTED VALUE BACK TO THE HIGH BYTE\n    AND $0F          ; MASK OUT UPPER BITS\n    CP $0A           ; CHECK FOR HEX CHARACTER ($0A) ON LOWER NYBBLE\n    JP NZ,BEGIN      ; IF WE ARE STILL WITHIN RANGE, THEN CONTINUE\n    LD A, (COUNTER+1); RELOAD ACCUMULATOR WITH HIGH BYTE\n    ADD A,6          ; ADD 6 TO SKIP A-F IN HEX\n    LD (COUNTER+1),A ; STORE VALUE BACK TO HIGH BYTE\n    AND $F0          ; MASK OUT LOWER NYBBLE\n    CP $A0           ; CHECK TO SEE IF HIGH NYBBLE HAS REACHED $A0\n    JP NZ,BEGIN      ; IF NOT, THEN CONTINUE\n    LD A,0           ; LOAD 0 TO ACCUMULATOR\n    LD (COUNTER),A   ; RESET LOW NYBBLE TO ZERO\n    LD (COUNTER+1),A ; RESET HIGH NYBBLE TO ZERO\n    JP BEGIN         ; RESTART\n; ** END MAIN ROUTINE **<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Scan the Display<\/h2>\n\n\n\n<p>Periodically, we need to scan the display to keep it from going blank.  This routine performs the system calls to make this happen.  Once we finish executing this subroutine, we have a RET statement.  This will return back to the next instruction after the CALL SCANDS is performed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ** BEGIN SCAN DISPLAY ROUTINE **    \nSCANDS: ; SCAN THE DISPLAYS\n    ; PERFORM SYSTEM CALLS (MONITOR ENTRY POINT IS $30)\n    ; LOAD FUNCTION CODE TO C BEFORE PERFORMING SYSCALL\n    LD C,$04            ; CLRBUF CLEARS DISPLAY BUFFER (FUNCTION CODE $04)\n    CALL $30            ; SYSCALL (MONITOR ENTRY POINT)\n    LD C,$02            ; DISADD CONVERT AND ADD TO DISPLAY BUFFER -- FUNCTION CODE $02\n    LD HL,(COUNTER)     ; DATA TO BE DISPLAYED (2 BYTES)\n    CALL $30            ; SYSCALL (MONITOR ENTRY POINT)\n    LD C,$05            ; SCAN DISPLAY -- FUCNTION CODE $05\n    CALL $30            ; SYSCALL (MONITOR ENTRY POINT)\n    RET\n; ** END SCAN DISPLAY ROUTINE **<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Check for Key Presses<\/h2>\n\n\n\n<p>Here, we simply look at port $86.  We bring this data into the accumulator.  After that, we&#8217;ll check bit 5.  If bit 5 is still zero, then we return back to the main logic.  On the other hand, if the operator presses a button, then bit 5 goes true.  In this case, we will beep the speaker then wait for the operator to release the key.  Then, we will stay in a loop until the next key press.  In other words, we pause the timer.<\/p>\n\n\n\n<p>Notice the use of labels.  Labels simply identify a memory location that we can access, or loop back to.  Without the use of labels, you would have to know the memory location of the command you wish to jump to.  This can create a problem as you expand your project, because the location of instructions in logic will change.  When using labels, the compiler figures out the address for each label, and adjusts the references accordingly.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ** BEGIN CHECKKEY ROUTINE TO SEE IF A KEY IS PRESSED TO PAUSE COUNTING **\nCHECKKEY:\n    IN A,($86)          ; INPUT FROM KEYPAD AT PORT $86\n    BIT 5,A             ; CHECK STATUS BIT OF KEYPAD\n    JP NZ,CHECKKEYCNT1  ; RETURN IF NO KEY PRESSED\n    JP CHECKKEYRET\nCHECKKEYCNT1:           ; WAIT FOR SECOND KEYPRESS TO CONTINUE\n    LD C,$15  ; FUNCTION CODE FOR BEEP\n    CALL $30  ; SYSTEM CALL\n    LD C,$0A            ; SKEYREL -- SCAN DISPLAY UNTIL KEY RELEASED\n    CALL $30            ; SYSCALL\nCHECKKEYCNT2:\n    LD C,$05            ; SCAN DISPLAY -- FUCNTION CODE $05\n                        ; WITHOUT THIS, THE DISPLAY WOULD BLANK WHILE LOOPING\n    CALL $30            ; SYSCALL (MONITOR ENTRY POINT)\n    IN A,($86)          ; INPUT FROM KEYPAD AT PORT $86\n    BIT 5,A             ; CHECK STATUS BIT OF KEYPAD\n    JP Z, CHECKKEYCNT2  ; IF KEY NOT PRESSED SECOND TIME, STAY IN LOOP\n    LD C,$15  ; FUNCTION CODE FOR BEEP\n    CALL $30  ; SYSTEM CALL\n    LD C,$0A            ; SKEYREL -- SCAN DISPLAY UNTIL KEY RELEASED\n    CALL $30            ; SYSCALL\n\nCHECKKEYRET:\n    RET     ; RETURN TO NEXT INSTRUCTION AFTER THIS CALL UNDER FIRSTDIGIT LABEL\n; ** END CHECKKEY ROUTINE TO SEE IF A KEY IS PRESSED **\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Delay Routine<\/h2>\n\n\n\n<p>Here, we have a subroutine that we calibrate to create a 1 second delay.  Remember, we set the delay times at the beginning of the program.  Here, we are just using these delay times to keep the processor busy for 1 second.   Remember, we still need to scan the display, so it doesn&#8217;t go blank.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ** BEGIN DELAY ROUTINE\nDELAY: ; DELAY ROUTINE NESTED 2X\n    LD IX,DELAYTIME ; LOAD IX WITH BASE ADDRESS FOR DELAY TIMERS\n    \n    LD (IX+0),DELAYTIME1 ; RESET FINE TUNE LOOP COUNTER 1 TO CONSTANT DEFINED IN HEADER\n    \nDELAY1: ; \n    LD A,(IX+0)  ; LOAD ACCUMULATOR WITH FOURTH COUNTER\n    DEC A        ; DECREMENT ACCUMULATOR\n    LD (IX+0),A  ; STORE ACCUMULATOR BACK TO DELAY COUNTER 1\n    \n    LD (IX+1),DELAYTIME2  ; RELOAD DELAY COUNTER 2 WITH CONSTANT DEFINED IN THE HEADER\n    \nDELAY2: ; FINRE TUNE LOOP 2\n    ;CALL SCANDS ; SCAN THE DISPLAYS\n    CALL CHECKKEY ; CHECK TO SEE IF A KEY IS PRESSED TO STOP DISPLAY\n    CALL SCANDS\n\n    LD A,(IX+1)   ; LOAD A WITH SECOND COUNTER\n    DEC A         ; DECREMENT ACCUMULATOR\n    LD (IX+1),A   ; STORE A BACK TO SECOND COUNTER\n    CP 0          ; CHECK FOR ZERO\n    JP NZ,DELAY2  ; IF NOT YET ZERO, THEN RE-RUN DELAY2 LOOP\n    \n    \n    LD A,(IX+0)   ; RELOAD A WITH FIRST COUNTER\n    CP 0          ; COMPARE THIS TO ZERO\n    JP NZ,DELAY1  ; IF NOT YET ZERO, THEN CONTINUE WITH DELAY 1\n    \n    LD (IX+2),DELAYTIME3 ; RESET FINER TUNE LOOP COUNTER 3 TO CONSTANT DEFINED IN HEADER\n    \nDELAY3: ; FINEST TUNE LOOP 3\n    CALL CHECKKEY ; CHECK TO SEE IF A KEY IS PRESSED TO STOP DISPLAY\n    CALL SCANDS\n    LD A,(IX+2)   ; LOAD ACCUMULATOR WITH THIRD COUNTER\n    DEC A         ; DECREMENT ACCUMULATOR\n    LD (IX+2),A   ; STORE ACCUMULATOR BACK TO THIRD COUNTER\n    CP 0          ; CHECK FOR ZERO\n    JP NZ,DELAY3  ; IF NOT ZERO YET, RE-EXECUTE LOOP\n    \n    ; ADDITIONAL NOPS FOR MORE FINE TUNING\n;    NOP\n;    NOP\n    LD C,$15\n    CALL $30\n\n\n    RET ; ALL DONE WITH DELAY ROUTINE -- RETURN NEXT INSTRUCTION AFTER CALL UNDER FIRSTDIGIT LABEL\n; ** END DELAY ROUTINE ** <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">End of Program<\/h2>\n\n\n\n<p>Finally, we simply define some bytes that our program can use.  We have to be careful that the length of the above logic does not intrude on this memory space.  We&#8217;ll define these bytes at $2200.  Basically, these are just labels that we use as starting memory locations for the project.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n; ** BEGIN FOOTER (DEFINE BYTES (DB)) **\n    ORG $2200\n\nDELAYTIME: ; FOR DELAY LOOPS\n    DB $FF,$FF,$FF ; THESE WILL BE OVERWRITTEN WITH CONSTANTS DEFINED IN HEADER\n    \nCOUNTER: ; DIGITS TO DISPLAY\n    DB $00,$00,$00,$00 ; THESE WILL BE OVERWRITTEN BY COUNTER LOGIC \n                       ; (I'M ONLY USING THE FIRST TWO BYTES RIGHT NOW)\n                       \nKEYSET:                 ; AFTER KEY PRESSED, WE NEED TO WAIT UNTIL IT'S PRESSED AGAIN\n                        ; THIS IS JUST A WORKSPACE TO COUNT THE KEYPRESSES\n    DB $00\n                       \n; ** END FOOTER (DEFINE BYTES (DB)) **<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Summary of my Stopwatch Program for the Southern Cross (Z80)<\/h2>\n\n\n\n<p>In short, its easier to use an assembler on another machine than to enter the program through the keypad.  You just need to learn the instruction set, and remember the mnemonics rather than the opcode.  When your project is finished, generate an intel hex file with your assembler.  After that, you can press Fn+1, and send the program to the Southern Cross.  Fn+0 runs your project.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Intel Hex File:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>:202000003E00110000210000010000DD211322DD7700DD7701DD7702DD7703DD211022DDB9\n:20202000360020DD360110DD3602780E04CD30003E002A13220E02CD30000E09CD30000EBE\n:202040000ACD30000E15CD3000CDD4203A13223C321322E60FFE0AC249203A1322C60632F1\n:202060001322E6F0FEA0C249203E003213223A14223C321422E60FFE0AC249203A1422C675\n:2020800006321422E6F0FEA0C249203E00321322321422C349200E04CD30000E022A13227C\n:2020A000CD30000E05CD3000C9DB86CB6FC2B320C3D3200E15CD30000E0ACD30000E05CD4F\n:2020C0003000DB86CB6FCABD200E15CD30000E0ACD3000C9DD211022DD360020DD7E003D95\n:2020E000DD7700DD360110CDA920CD9620DD7E013DDD7701FE00C2E720DD7E00FE00C2DCA3\n:2021000020DD360278CDA920CD9620DD7E023DDD7702FE00C205210E15CD3000C93F065B9A\n:152120004F666D7D077F6F777C395E7971FFFFFF0000000000A5\n:00000001FF<\/code><\/pre>\n\n\n\n<p>For more information, visit the <a href=\"https:\/\/bryceautomation.com\/index.php\/category\/vintage-computers\/\">Vintage Computer Category Page!<\/a><\/p>\n\n\n\n<p>&#8212; Ricky Bryce<\/p>\n<div id=\"bryce-3838587383\" class=\"bryce-after-content bryce-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-8316758073402323\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-8316758073402323\" \ndata-ad-slot=\"4667596182\" \ndata-ad-format=\"auto\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Introduction to my Stopwatch Program for the Southern Cross (Z80) My Stopwatch Program for the Southern Cross is a very simple program. In reality, it&#8217;s just one step above a &#8220;Hello World&#8221; program. Once you get your Southern Cross Computer up and running, you will want to continue learning. For example, you will want to <a class=\"moretag btn btn-primary\" href=\"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/\">Read More \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":16737,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[727],"tags":[784,950,420,871],"class_list":{"0":"post-16706","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-vintage-computers","8":"tag-assembly","9":"tag-southern-cross","10":"tag-z80","11":"tag-z80asm","12":"czr-hentry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Stopwatch Program for the Southern Cross - Bryce Automation<\/title>\n<meta name=\"description\" content=\"How to create a Stopwatch Program for the Southern Cross. Generate an Intel Hex file with your assembler, then transfer your program.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Stopwatch Program for the Southern Cross - Bryce Automation\" \/>\n<meta property=\"og:description\" content=\"How to create a Stopwatch Program for the Southern Cross. Generate an Intel Hex file with your assembler, then transfer your program.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/\" \/>\n<meta property=\"og:site_name\" content=\"Bryce Automation\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ricky.bryce.7\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-19T07:41:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-30T04:09:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/scc.png\" \/>\n\t<meta property=\"og:image:width\" content=\"568\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ricky\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/\"},\"author\":{\"name\":\"Ricky\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/#\\\/schema\\\/person\\\/5d5b0f6f6ad768f1ee52968338e63af7\"},\"headline\":\"Stopwatch Program for the Southern Cross\",\"datePublished\":\"2023-06-19T07:41:00+00:00\",\"dateModified\":\"2023-06-30T04:09:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/\"},\"wordCount\":1299,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/scc.png\",\"keywords\":[\"Assembly\",\"Southern Cross\",\"z80\",\"z80asm\"],\"articleSection\":[\"Vintage Computers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/\",\"url\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/\",\"name\":\"Stopwatch Program for the Southern Cross - Bryce Automation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/scc.png\",\"datePublished\":\"2023-06-19T07:41:00+00:00\",\"dateModified\":\"2023-06-30T04:09:57+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/#\\\/schema\\\/person\\\/5d5b0f6f6ad768f1ee52968338e63af7\"},\"description\":\"How to create a Stopwatch Program for the Southern Cross. Generate an Intel Hex file with your assembler, then transfer your program.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#primaryimage\",\"url\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/scc.png\",\"contentUrl\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/scc.png\",\"width\":568,\"height\":512,\"caption\":\"Stopwatch Program for the Southern Cross\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/2023\\\/06\\\/19\\\/stopwatch-program-for-the-southern-cross\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/bryceautomation.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Stopwatch Program for the Southern Cross\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/#website\",\"url\":\"https:\\\/\\\/bryceautomation.com\\\/\",\"name\":\"Bryce Automation\",\"description\":\"Automating Home and Industry...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/bryceautomation.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/#\\\/schema\\\/person\\\/5d5b0f6f6ad768f1ee52968338e63af7\",\"name\":\"Ricky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/wphb-cache\\\/gravatar\\\/a8f\\\/a8fe6bf79d292b388ffee281ccb12488x96.jpg\",\"url\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/wphb-cache\\\/gravatar\\\/a8f\\\/a8fe6bf79d292b388ffee281ccb12488x96.jpg\",\"contentUrl\":\"https:\\\/\\\/bryceautomation.com\\\/wp-content\\\/wphb-cache\\\/gravatar\\\/a8f\\\/a8fe6bf79d292b388ffee281ccb12488x96.jpg\",\"caption\":\"Ricky\"},\"sameAs\":[\"http:\\\/\\\/bryceautomation.com\",\"https:\\\/\\\/www.facebook.com\\\/ricky.bryce.7\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/ricky-bryce-4367a416\\\/\"],\"url\":\"https:\\\/\\\/bryceautomation.com\\\/index.php\\\/author\\\/ricky\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Stopwatch Program for the Southern Cross - Bryce Automation","description":"How to create a Stopwatch Program for the Southern Cross. Generate an Intel Hex file with your assembler, then transfer your program.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/","og_locale":"en_US","og_type":"article","og_title":"Stopwatch Program for the Southern Cross - Bryce Automation","og_description":"How to create a Stopwatch Program for the Southern Cross. Generate an Intel Hex file with your assembler, then transfer your program.","og_url":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/","og_site_name":"Bryce Automation","article_author":"https:\/\/www.facebook.com\/ricky.bryce.7","article_published_time":"2023-06-19T07:41:00+00:00","article_modified_time":"2023-06-30T04:09:57+00:00","og_image":[{"width":568,"height":512,"url":"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/scc.png","type":"image\/png"}],"author":"Ricky","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#article","isPartOf":{"@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/"},"author":{"name":"Ricky","@id":"https:\/\/bryceautomation.com\/#\/schema\/person\/5d5b0f6f6ad768f1ee52968338e63af7"},"headline":"Stopwatch Program for the Southern Cross","datePublished":"2023-06-19T07:41:00+00:00","dateModified":"2023-06-30T04:09:57+00:00","mainEntityOfPage":{"@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/"},"wordCount":1299,"commentCount":0,"image":{"@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#primaryimage"},"thumbnailUrl":"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/scc.png","keywords":["Assembly","Southern Cross","z80","z80asm"],"articleSection":["Vintage Computers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/","url":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/","name":"Stopwatch Program for the Southern Cross - Bryce Automation","isPartOf":{"@id":"https:\/\/bryceautomation.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#primaryimage"},"image":{"@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#primaryimage"},"thumbnailUrl":"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/scc.png","datePublished":"2023-06-19T07:41:00+00:00","dateModified":"2023-06-30T04:09:57+00:00","author":{"@id":"https:\/\/bryceautomation.com\/#\/schema\/person\/5d5b0f6f6ad768f1ee52968338e63af7"},"description":"How to create a Stopwatch Program for the Southern Cross. Generate an Intel Hex file with your assembler, then transfer your program.","breadcrumb":{"@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#primaryimage","url":"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/scc.png","contentUrl":"https:\/\/bryceautomation.com\/wp-content\/uploads\/2023\/06\/scc.png","width":568,"height":512,"caption":"Stopwatch Program for the Southern Cross"},{"@type":"BreadcrumbList","@id":"https:\/\/bryceautomation.com\/index.php\/2023\/06\/19\/stopwatch-program-for-the-southern-cross\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bryceautomation.com\/"},{"@type":"ListItem","position":2,"name":"Stopwatch Program for the Southern Cross"}]},{"@type":"WebSite","@id":"https:\/\/bryceautomation.com\/#website","url":"https:\/\/bryceautomation.com\/","name":"Bryce Automation","description":"Automating Home and Industry...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bryceautomation.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bryceautomation.com\/#\/schema\/person\/5d5b0f6f6ad768f1ee52968338e63af7","name":"Ricky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bryceautomation.com\/wp-content\/wphb-cache\/gravatar\/a8f\/a8fe6bf79d292b388ffee281ccb12488x96.jpg","url":"https:\/\/bryceautomation.com\/wp-content\/wphb-cache\/gravatar\/a8f\/a8fe6bf79d292b388ffee281ccb12488x96.jpg","contentUrl":"https:\/\/bryceautomation.com\/wp-content\/wphb-cache\/gravatar\/a8f\/a8fe6bf79d292b388ffee281ccb12488x96.jpg","caption":"Ricky"},"sameAs":["http:\/\/bryceautomation.com","https:\/\/www.facebook.com\/ricky.bryce.7","https:\/\/www.linkedin.com\/in\/ricky-bryce-4367a416\/"],"url":"https:\/\/bryceautomation.com\/index.php\/author\/ricky\/"}]}},"_links":{"self":[{"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/posts\/16706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/comments?post=16706"}],"version-history":[{"count":0,"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/posts\/16706\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/media\/16737"}],"wp:attachment":[{"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/media?parent=16706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/categories?post=16706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bryceautomation.com\/index.php\/wp-json\/wp\/v2\/tags?post=16706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}