I would like some help with assembly language. I am trying to build a program in assembly language code that manipulate some LED's.
I have 9 LED's that range from LED 0-7 plus LED P (Power) and have 5 Push Buttons Switches (PBS). They are arranged in the following format:
LED's: P D0 D1 D2 D3 D4 D5 D6 D7
PBS's: PBS4 PBS3 PBS2 PBS1 PBS0
I have to make the LED's perform the following routines:
Subroutine 0: P(on) D0(on) D1(off) D2(on) D3(off) D4(on) D5(off) D6(on) D7(off)
then......... P(on) D0(off) D1(on) D2(off) D3(on) D4(off) D5(on) D6(off) D7(on)
until PBS 0 is Pressed
Subroutine 1: P(on) D0(on) D1(on) D2(off) D3(off) D4(on) D5(on) D6(off) D7(off)
then......... P(on) D0(off) D1(off) D2(on) D3(on) D4(off) D5(off) D6(on) D7(on)
until PBS 1 is Pressed
Subroutine 2: P(on) D0(on) D1(off) D2(off) D3(off) D4(off) D5(off) D6(off) D7(on)
then......... P(on) D0(off) D1(on) D2(off) D3(off) D4(off) D5(off) D6(on) D7(off)
then......... P(on) D0(off) D1(off) D2(on) D3(off) D4(off) D5(on) D6(off) D7(off)
then......... P(on) D0(off) D1(off) D2(off) D3(on) D4(on) D5(off) D6(off) D7(off)
then......... P(on) D0(off) D1(off) D2(on) D3(off) D4(off) D5(on) D6(off) D7(off)
then......... P(on) D0(off) D1(on) D2(off) D3(off) D4(off) D5(off) D6(on) D7(off)
until PBS 2 is Pressed
The time between the sequences of on and off of each LED's is 200msec and from subroutine to subroutine is 1 sec
The Pushbuttons switches (PBS) are debounced with an RC time constant of approx. 150msec
I have done some coding in Assembly code language but do not know if what I have is correct. Here is my code:
SSEG SEGMENT STACK 'STACK' ; Stack Segment: Static allocation
DW 64 DUP (?) ; of UNinitialized 64-byte stack
TOPOFSTK: ; Top of Stack
SSEG ENDS
;============================================================================
DSEG SEGMENT PUBLIC 'CONST' ; Data Segment
Port_Out DW 0378h ; Addr/ parallel port used f/output
Port_In DW 0379h ; Addr/ parallel port used f/input
DSEG ENDS
;============================================================================
CSEG SEGMENT 'CODE' ; Code Segment
;----------------------------------------------------------------------------
MAIN PROC FAR ; Entry point f/DOS must b FAR PROC
ASSUME CS:CSEG ; Associate segment name labels
ASSUME DS:DSEG ; with segment registers for
ASSUME SS:SSEG ; potential error checking.
MOV AX,DSEG ; DOS inits CS at program loading.
MOV DS,AX ; Prog must init DS to local space.
MOV AX,SSEG ; SS:SP points to system stack.
MOV SS,AX ; If NOT using system stack, prog
MOV SP,TOPOFSTK ; must init SS:SP to local space.
; -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
CALL Set_RED ; Called subroutine.
CALL Await_PRESS ;
CALL Read_PBS ;
; -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
MOV AH,4Ch ; Set up for return to DOS
INT 21h ; Do it.
MAIN ENDP
; ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
Set_RED PROC NEAR ; Entry point for subroutine.
MOV AH, 9
INT 021h
MOV DX, [Port_Out]
MOV AL, 1+32
OUT DX, AL
RETN
Set_RED ENDP
; ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
Await_Press PROC NEAR
MOV AH, 9
INT 021h
AP00: CALL Read_PBS
JZ AP00
RETN
Await_Press ENDP
; ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
Read_PBS PROC NEAR
MOV DX, [Port_Out]
INC DX
IN AL, DX
MOV CL, 7
SHR AL, CL
RETN
Read_PBS ENDP
;----------------------------------------------------------------------------
CSEG ENDS
;============================================================================
END MAIN
;============================================================================
Please HELP!!!!!! I will appreciate your help, time and effort. Thank you!