Beruflich Dokumente
Kultur Dokumente
db 0ah,0dh,"1.Clock Wise direction "; db 0ah,0dh,"2.AntiClock Wise direction "; db 0ah,0dh,"Enter your choice $" data ends
code segment assume ds:data,cs:code start : mov dx,data; initializing data segment mov ds,dx ;
lea dx,msg1;getting and printing offset of msg1 mov ah,09h int 21h
call read ;reads first digit of angle in BCD xor ah,ah ;converts into equivalent hexadecimal mov ch,100 mul ch mov di,ax ;angle stored in di register
call read ;reads second digit of angle in BCD xor ah,ah ;converts into equivalent hexadecimal
call read ;reads last digit of angle in BCD xor ah,ah add di,ax ;update angle in di register in hexadecimal
mov al,80h ;initialize all ports as output ports, mov dx,9403h ;or 9803h of back port, control word register out dx,al ;to configure
lea dx,msg2 ;getting and printing msg2 mov ah,09h int 21h
call read ;read for direction mov bh,al mov cl,11h ;for generating rotation sequence bak: cmp bh,01h ;for rotating in clock wise jne anti ror cl,01h jmp nxt anti: rol cl,01h ;for rotating in anti clock wise nxt: mov al,cl mov dx,9400h ;or 9800h of back port, Port A address out dx,al ;motor is connected to only Port A lower nibble call delay ;calling delay before next step dec di jnz bak ;decrement count if not zero ;above process get repeated
read proc near mov ah,01h ;read procedure to read 1 digit BCD number int 21h sub al,30h ret read endp ; don t give hexadecimal
mov bh,0ffh ;reduce count for less delay in BH to speed up motor bak2: mov dx,0ffffh ;give minimum delay in dx=0FFFFh bak1: dec dx jnz bak1 dec bh jnz bak2 ret code ends end start