hi guys , what am i doing wrong here, i have instigated several approaches, in assembly 8086 using borland/turbo 7.0 pascal on win 98se (so i can communicate easily to parallel port and stipulation of assignment)
my issue lies with being able to allow execution of a looped routine but keep a constant listen out for a keypress from the keyboard, at the point of the keypress the routine should jump to a call which then runs and returns back to the main routines loop.
i have done as much as i can using interrupts but alas , even with the "Advanced ms-dos programming bible" i seem to lack the knowledge to search for or instigate the all encompassing int that will handle my needs. (i am aware of using int 9 to create my own interrupt etc , but again maybe out of my initial grasp)
please view the code below and if poss give me a direction to take :)
Any reply is welcome but. i also really need the help of someone capable of explaining where i may have gone wrong, so that i may learn to put it right. (maybe a dummy code example , that i can identify simalarities with my own code problem) just a thought, if you want to tell me straight out what to do it will probably save me time, but can one learn from an answer without knowing the right question ?
(....................FOR NOOBS, LIKE ME........................................)
THE SYNTAX HIGHLIGHTING MAKES IT A BIT DIFFICULT TO READ I THINK, BUT HOPE IT ALL STILLS MAKES SENSE, WHERE THERE IS A {}, THIS HOLDS A COMMENT SO IGNORE ANY
HIGHLIGHTING IN THESE CURLY BRACES. THAKN AGAIN ANY HELPERS OUT THERE :)
(..............................................................................)
PROGRAM light_interrupt;
{******gruffy321 2011**********}
{prog designed to loop through a sequence sent to the parallel port...}
{and continually listen for keyboard press ("p" or "P" in this case) during the loop}
{upon the keypress of "p" or "P" it should je(jump if equal) to a sub routine, if the keypress....}
{is nt equal to "p"or"P" then it should return to the main program loop}
LABEL {these are labels attached to jumps and calls}
loop_1,
loop_2,
loop_3,
loop_4,
loop_5,
listen,
keypress,
wait,
state_1,
state_2,
state_3;
BEGIN
ASM
mov dx, $378 {put $378 (parallel port address) into register dx}
{used to send signal to binary led display}
{*********start main routine here**********}
call listen {call the listen sub-routine to check for a keypress}
state_1:
{below is just a noob way of ensuring reg`s are all at zero...}
{i know i know, but it works for right now}
mov ax, 0000h {fill ax with 0`s}
mov bx, 0000h {fill bx with 0`s}
mov cx, 0000h {fill cx with 0`s}
mov ax, $81 {mov $81 TO ax}
out dx, ax {send out to parallel port}
call wait {call the wait sub-routine}
call listen {call the listen sub-routine to check for a keypress}
state_2:
mov ax, 0000h {fill ax with 0`s}
mov bx, 0000h {fill bx with 0`s}
mov cx, 0000h {fill cx with 0`s}
mov ax, $18 {mov $18 TO ax}
out dx, ax {send out to parallel port}
call wait {call the wait sub-routine}
call listen {call the listen sub-routine to check for a keypress}
state_3:
mov ax, 0000h {fill ax with 0`s}
mov bx, 0000h {fill bx with 0`s}
mov cx, 0000h {fill cx with 0`s}
mov ax, $2C {mov $2C TO ax}
out dx, ax {send out to parallel port}
call wait {call the wait sub-routine}
{**********lissten sub routine**********}
listen:
push ax {push registers ax, bx , cx, si , sp to stack}
push bx
push cx
push si
push sp
mov ah, 01 {initialise int 21}
INT 21H {***THIS PLACES 70 INTO AL*********}
mov bh, "p" {i move "p" into reg bh}
cmp al, bh {compre thesse two values}
je keypress {if equal go to keypress sub-routine zero flag should =0}
jnz state_1 {if zero flag not set = 0 then return to main loop at this point)}
mov ch, "P" {same as above , but for "P"}
cmp al, ch
je keypress
jnz state_1
pop ax {pop all values ax, bx, cx, si, sp back from stack}
pop bx
pop cx
pop si
pop sp
ret {return to main routine}
{********countdown delay sub routine***********}
wait: {a decrement loop to nake a time delay}
mov ah, $1 {currently very small due to debug and stepping through}
{change to larger hex value for more realistic time countdown}
loop_3:
mov bx,$1 {currently very small due to debug and stepping through}
{change to larger hex value for more realistic time countdown}
loop_2:
mov cx, $1 {currently very small due to debug and stepping through}
{change to larger hex value for more realistic time countdown}
loop_1:
dec cx {decrement reg cx}
jnz loop_1 {return to loop until register in cx holds 0}
dec bx {decrement reg bx}
jnz loop_2 {return to loop until register in bx holds 0}
dec ah {decrement reg ax}
jnz loop_3 {return to loop until register in ah holds 0}
call state_1 {return to main routine loop}
{************keypress routine**********}
keypress: {sub-routine that occurs due to keypress of "p" or "P"from keyboard}
push ax {push registers ax, bx , cx, to stack}
push bx
push cx
mov ax, $A1
out dx, ax {send out to parallel port}
mov cx, $F
loop_5: {loop label}
mov bx, $F
loop_4:
dec bx
jnz loop_4
dec cx
jnz loop_5
pop ax {pop all values ax, bx, cx, back from stack}
pop bx
pop cx
ret
{**********************}
END;
END.
thanks again for any helps peeps
Gruffy 321