;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; testmot.asm - Test program for motor controllers ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;----------------------------------------------------; ; Application Header. ; ;----------------------------------------------------; use32 org 0x400000 jmp initialise db 'DEX2' ;----------------------------------------------------; ; Initialised Data. ; ;----------------------------------------------------; Copyright db '(C) Steve Bromley',0 Program_name db 'Motor Controller test',0 StringMenu db ' ESC=Quit 1,2,3=Port d=dir-1 D=dir+1 s=step-1 S=step+1 +-=index /*=run',0 String1 db 'motor test Port.: ',0 String2 db 'motor Step Pin..: ',0 String3 db 'motor Dir Pin...: ',0 wait_string db 'Good Bye',0 lpt dw 03bch step db 00001000b dir db 10000000b ;----------------------------------------------------; ; Code Section. ; ;----------------------------------------------------; initialise: mov ax,0x18 ; Setup the segment registers mov ds,ax mov es,ax mov edi,Functions ; This is the interrupt we use mov al,0 ; we use to load the DexFunction.inc mov ah,0x0a ; with the address to dex4u functions. int 40h introscreen: mov ax,0101h ; Overwrite Dex title block mov esi,Program_name call [SetCursorPos] call [PrintString] mov ax,0039h mov esi,Copyright call [SetCursorPos] call [PrintString] mov ax,0300h mov esi,StringMenu call [SetCursorPos] call [PrintString] mov ch,00110000b ; kill cursor mov cl,00010000b mov ah,01h call [RealModeInt10h] main_loop: call [Clstext] mov ax,0617h ; Display Menu mov esi,String1 call [SetCursorPos] call [PrintString] mov bx,[lpt] mov al,bh call [WriteHex16] mov al,bl call [WriteHex16] mov ax,0817h mov esi,String2 call [SetCursorPos] call [PrintString] mov al,[step] call pin_id mov ax,0a17h mov esi,String3 call [SetCursorPos] call [PrintString] mov al,[dir] call pin_id mov ax,0c20h ; motor icon call [SetCursorPos] mov al,'+' call [PrintChar] call [WaitForKeyPress] ; Get function to preform ESC: cmp al,27 ; escape key jne opt1 jmp quit_app opt1: cmp al,'1' ; check opt1 jne opt2 ; not opt1 try opt2 mov [lpt], 0378h ; set port address jmp main_loop ; go back into loop opt2: cmp al,'2' ; check opt2 jne opt3 ; not opt2 try opt3 mov [lpt], 03bch ; set port address jmp main_loop ; go back into loop opt3: cmp al,'3' ; check opt3 jne opt4 ; not opt1 try opt4 mov [lpt], 0278h ; set port address jmp main_loop ; go back into loop opt4: cmp al,'d' ; check opt4 jne opt5 ; not opt4 try opt5 cmp [dir],01h ; check if can be lower je main_loop shr [dir],1 ; lower pin number jmp main_loop opt5: cmp al,'D' ; check opt5 jne opt6 ; not opt5 try opt6 cmp [dir],80h ; check if can be higher je main_loop shl [dir],1 ; raise pin number jmp main_loop opt6: cmp al,'s' ; check opt6 jne opt7 ; not opt6 try opt7 cmp [step],01h ; check if can be lower je main_loop shr [step],1 ; lower pin number jmp main_loop opt7: cmp al,'S' ; check opt7 jne opt8 ; not opt7 try opt8 cmp [step],80h ; check if can be higher je main_loop shl [step],1 ; raise pin number jmp main_loop opt8: cmp al,'+' ; check opt8 jne opt9 ; not opt8 try opt9 mov ax,0c20h ; move motor icon call [SetCursorPos] mov al,'X' call [PrintChar] mov al,[step] ; load step mov dx,[lpt] ; load port address or al,[dir] ; overlay dir onto step out dx,al ; start step pulse mov ax,1 call [SetDelay] ; wait a moment mov al,[dir] out dx,al ; end step pulse jmp main_loop opt9: cmp al,'-' ; check opt9 jne opt10 ; not opt9 try opt10 mov ax,0c20h ; move motor icon call [SetCursorPos] mov al,'X' call [PrintChar] mov al,[step] ; load step mov dx,[lpt] ; load port address out dx,al ; start step pulse mov ax,1 call [SetDelay] ; wait a moment mov al,0 out dx,al ; end step pulse jmp main_loop opt10: cmp al,'*' ; check opt10 jne opt11 ; not opt10 try opt11 mov bl,[step] ; load step mov bh,[dir] ; load dir mov dx,[lpt] ; load port address or bl,bh ; overlay dir onto step mov cx,200 ; number of motor steps loop9: mov ax,0c20h ; move motor icon call [SetCursorPos] mov al,'X' call [PrintChar] mov al,bl out dx,al ; start step pulse mov ax,1 call [SetDelay] ; wait a moment mov ax,0c20h ; move motor icon call [SetCursorPos] mov al,'+' call [PrintChar] mov al,bh out dx,al ; end step pulse mov ax,1 call [SetDelay] ; wait a moment dec cx ; knock one off the loop count cmp cx,0 jne loop9 ; loop not zero go again jmp main_loop opt11: cmp al,'/' ; check opt11 jne main_loop ; not opt11 give up mov bl,[step] ; load step mov bh,0 ; load dir mov dx,[lpt] ; load port address mov cx,200 ; number of motor steps loop10: mov ax,0c20h ; move motor icon call [SetCursorPos] mov al,'X' call [PrintChar] mov al,bl out dx,al ; start step pulse mov ax,1 call [SetDelay] ; wait a moment mov ax,0c20h ; move motor icon call [SetCursorPos] mov al,'+' call [PrintChar] mov al,bh out dx,al ; end step pulse mov ax,1 call [SetDelay] ; wait a moment dec cx ; knock one off the loop count cmp cx,0 jne loop10 ; loop not zero go again jmp main_loop optbad: ; oops invalid option jmp main_loop ; go back into loop(just in case) pin_id: cmp al,00000001b ; check pin addressed jne pin3 ; not this one go to next mov al,'2' ; set pin name in al jmp pinp ; goto the print command pin3: ; same thing for next 7 pins cmp al,00000010b jne pin4 mov al,'3' jmp pinp pin4: cmp al,00000100b jne pin5 mov al,'4' jmp pinp pin5: cmp al,00001000b jne pin6 mov al,'5' jmp pinp pin6: cmp al,00010000b jne pin7 mov al,'6' jmp pinp pin7: cmp al,00100000b jne pin8 mov al,'7' jmp pinp pin8: cmp al,01000000b jne pin9 mov al,'8' jmp pinp pin9: cmp al,10000000b jne pine mov al,'9' jmp pinp pine: mov al,'E' ; error in pin setting pinp: call [PrintChar] ; print pin name ret quit_app: call [Clstext] mov ax,1a20h mov esi,wait_string call [SetCursorPos] call [PrintString] mov ax,0020h call [SetDelay] mov ch,00010000b ; unkill cursor mov cl,00010000b mov ah,01h call [RealModeInt10h] ret ; End application ;----------------------------------------------------; ; Uninitialised Data. ; ;----------------------------------------------------; include "DexFun.inc" ; Call-table include file