📄 steppermotorcontrol.asm
字号:
; step motor control
; ASM for 8086/8088
mode equ 082h
ctl equ 08000h
contrl equ 08003h
Astep equ 01h
Bstep equ 02h
Cstep equ 04h
Dstep equ 08h
data segment
dly_c dw 0
data ends
code segment
assume cs:code, ds:data
start proc near
mov ax, data
mov ds, ax
mov dx, contrl
mov al, mode
out dx, al
mov dx, ctl
mov al,0
out dx,al
mov dly_c,1000h
jmp step4
; 单/双八拍工作方式
step8:
mov dx, ctl
mov al,Astep
out dx,al
call delay
mov al,Astep+Bstep
out dx,al
call delay
mov al,Bstep
out dx,al
call delay
mov al,Bstep+Cstep
out dx,al
call delay
mov al,Cstep
out dx,al
call delay
mov al,Cstep+Dstep
out dx,al
call delay
mov al,Dstep
out dx,al
call delay
mov al,Dstep+Astep
out dx,al
call delay
mov ax, dly_c
dec ah
cmp ax, 100h ; 提高转速
jne nn1 ; 最快速度
inc ah
nn1: mov dly_c,ax
jmp step8
; 双四拍工作方式
step4:
mov dx, ctl
mov al,Astep+Bstep
out dx,al
call delay
mov al,Bstep+Cstep
out dx,al
call delay
mov al,Cstep+Dstep
out dx,al
call delay
mov al,Dstep+Astep
out dx,al
call delay
mov ax, dly_c
dec ah
cmp ax, 200h
jne nn2
inc ah
nn2: mov dly_c,ax
jmp step4
; 单四拍工作方式
step41:
mov dx,ctl
mov al,Dstep
out dx,al
call delay
mov al,Cstep
out dx,al
call delay
mov al,Bstep
out dx,al
call delay
mov al,Astep
out dx,al
call delay
mov ax, dly_c
dec ah
cmp ax, 300h
jne nn3
inc ah
nn3: mov dly_c,ax
jmp step41
start endp
delay proc near
push cx
mov cx, dly_c
dd1:
;nop
loop dd1
pop cx
ret
delay endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -