在emu8086中混合led_display和stepper_motor

时间:2014-01-10 13:55:43

标签: x86 x86-16

这是emu8086中的程序,使用stepper_motor.exe和led_display.exe。

该计划的目的是:

当我在屏幕上输入数字1时,踏板电机顺时针旋转,这会增加LED的数量,当我进入2步进电机逆时针旋转时,这会减少LED的数量。

 mov ax, 0

mov [00000h],ax


c dw 4 
r macro data

; this is an example of out instruction.
; it writes values to virtual i/o port
; that controls the stepper-motor.
; c:\emu8086\devices\stepper_motor.exe is on port 7


steps_before_direction_change = 8h
jmp start


start:
mov bx, offset data ; start from clock-wise half-step.
mov si, 0
mov cx, 0 ; step counter

next_step:
; motor sets top bit when it's ready to accept new command
wait:   in al, 7     
    test al, 10000000b
    jz wait

mov al, [bx][si]
out 7, al

inc si

cmp si, 4
jb next_step
mov si, 0

inc cx
cmp cx, steps_before_direction_change
jb  next_step

ret
endm  



r1 macro data 

; this is an example of out instruction.
; it writes values to virtual i/o port
; that controls the stepper-motor.
; c:\emu8086\devices\stepper_motor.exe is on port 7     

    steps_before_direction_change1 = 8h

    ;#start=stepper_motor.exe#

;#make_bin#
; 32 (decimal)

jmp start1


start1:
mov bx, offset data ; start from clock-wise half-step.
mov si, 0
mov cx, 0 ; step counter

next_step1:
; motor sets top bit when it's ready to accept new command
wait1:   in al, 7     
    test al, 10000000b
    jz wait1

mov al, [bx][si]
out 7, al

inc si

cmp si, 4
jb next_step1
mov si, 0

   inc cx
   cmp cx, steps_before_direction_change1
   jb  next_step1

   ret
   endm






s:mov ah,01h
int 21h

cmp al,'1' 
je l1  
jne l11

l11:cmp al,'2'
je l2 
jne l12

l12:jmp s  





l1:call init
SUB AX,AX  
mov ax,c
inc ax
mov c,ax
out 199, ax  
r datcw


l2:call init
SUB AX,AX  
mov ax,c
dec ax
mov c,ax
out 199, ax  
r1 datccw

jmp s  



datccw   db 0000_0011b
         db 0000_0001b    
         db 0000_0110b
         db 0000_0010b


datcw    db 0000_0110b
         db 0000_0100b    
         db 0000_0011b
         db 0000_0010b








init proc    
#start=led_display.exe#
#make_bin#
name led 
#start=stepper_motor.exe# 
#make_bin# 
name "stepper"   
ret
init endp


>    

但是当我输入1然后是2时它会陷入循环中,当我输入1然后1时,它无法正常工作。

请指导我如何处理它?<​​/ p>

0 个答案:

没有答案