One of the SITCOM training computer prototypes
 SITCOM 85 Training Computer
 
 

Lesson 5

So far only outputs are used. Now it's time to introduce inputs

 
 

Let's start simple for it will get complicated soon enough

Light a LED when a push button is pressed

 
   

;------------------------------------------------------------------------
;
; LESSON5A.ASM
;
; Light a LED when a button is pressed
;
;------------------------------------------------------------------------

            .IN   INIT02           Initialize the assembler

;------------------------------------------------------------------------

            MVI   A,11111111B      Switch all port B LEDs off
            OUT   PORTB

INPUT       IN    PORTC            Read status of the push buttons
            OUT   PORTA             and copy it to port A
            JMP   INPUT            That's all folks!
 
 

This one is easy enough to explain.

 
 

Another, fairly easy example

Show 8, 7, 6, 5, 4, 3, 2, 1 or 0 LEDs, depending of the button that is pressed.
Objective of this example is to teach how to determine what key is pressed. No new instructions have been introduced in this example.

 
   

;------------------------------------------------------------------------
;
; LESSON5B.ASM
;
; Light some LEDs, depending on the button pressed
;
;------------------------------------------------------------------------

            .IN   INIT02           Initialize the assembler

;------------------------------------------------------------------------

            MVI   A,11111111B      Switch all port B LEDs off
            OUT   PORTB

INPUT       IN    PORTC            Get the keys
            MVI   B,0              By default all LEDs are on

LOOP        RLC                    Most significant button to Carry
            JNC   DONE             Stop shifting if this button is down!
            MOV   C,A              Save modified input byte
            MOV   A,B              Roll this Carry into result
            RAR
            MOV   B,A
            MOV   A,C              Get modified input byte back in A
            JNC   LOOP             Not all 8 bits checked yet!

DONE        MOV   A,B              Output the result			
            OUT   PORTA

            JMP   INPUT            Repeat endlessly
 
 

Try to explain this one :-) Also explain how the loop knows when all 8 keys are processed.

 
  Continue With Lesson 5 - More input.
 
  [Home] [Latest News] [Essentials] [Hardware] [The Build] [Programs] [Projects] [Downloads]
 
  Made in the UK