📄 asm_tutorial_12.html
字号:
<!doctype HTML public "-//W3O//DTD W3 HTML 3.0//EN"><HTML><HEAD><TITLE>8086 Assembler Tutorial for Beginners (Part 12)</TITLE><META name="description" content="Controlling External Devices"><META name="keywords" content="external, devices, 8086, traffic lights, stepper motor, robot"><META name="robots" content="nofollow"></HEAD><BODY bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#007099" alink="#FF0000"><TABLE WIDTH=80%><TR><TD><FONT FACE="Verdana" SIZE=3><FONT SIZE=+1><B>8086 Assembler Tutorial for Beginners (Part 12)</B></FONT><BR><BR><FONT SIZE=+2><B>Controlling External Devices</B></FONT><BR><BR><BR>There are 3 devices attached to the emulator: Traffic Lights, Stepper-Motor andRobot. You can view devices using "<B>Virtual Devices</B>" menu of the emulator.<BR><BR>For technical information see <A HREF="io.html"><B>I/O ports</B></A> section of Emu8086reference.<BR><BR>In general, it is possible to use any x86 family CPU to control all kind of devices,the difference maybe in base I/O port number, this can be altered using some trickyelectronic equipment. Usually the "<B>.bin</B>" file is written into the Read OnlyMemory (ROM) chip, the system reads program from that chip, loads it in RAM moduleand runs the program. This principle is used for many modern devices suchas micro-wave ovens and etc...<BR><BR><HR><BR><B>Traffic Lights</B><BR><BR><IMG SRC="traffic.gif" WIDTH=233 HEIGHT=276><BR><BR>Usually to control the traffic lights an array (table) of values is used. Incertain periods of time the value is read from the array and sent to a port.For example: <BR><BR><TABLE BORDER=1 CELLPADDING=10 WIDTH=70%><TR><TD><PRE><FONT FACE="Fixedsys">; directive to create BIN file:#MAKE_BIN##CS=500##DS=500##SS=500##SP=FFFF##IP=0#; skip the data table:JMP starttable DW 100001100001b DW 110011110011b DW 001100001100b DW 011110011110bstart:MOV SI, 0; set loop counter to number; of elements in table:MOV CX, 4next_value:; get value from table:MOV AX, table[SI]; set value to I/O port; of traffic lights:OUT 4, AX; next word:ADD SI, 2CALL PAUSELOOP next_value; start from over from; the first valueJMP start; ==========================PAUSE PROC; store registers:PUSH CXPUSH DXPUSH AX; set interval (1 million; microseconds - 1 second):MOV CX, 0FhMOV DX, 4240hMOV AH, 86hINT 15h; restore registers:POP AXPOP DXPOP CXRETPAUSE ENDP; ==========================</FONT></PRE></TD></TR></TABLE><BR><BR><HR><BR><B>Stepper-Motor</B><BR><BR><IMG SRC="stepper.gif" WIDTH=237 HEIGHT=215><BR><BR>The motor can be half stepped by turning on pair ofmagnets, followed by a single and so on.<BR><BR>The motor can be full stepped by turning on pair of magnets, followedby another pair of magnets and in the end followed by a single magnet and so on.The best way to make full step is to make two half steps.<BR><BR>Half step is equal to <B>11.25</B> degrees.<BR>Full step is equal to <B>22.5</B> degrees.<BR><BR>The motor can be turned both clock-wise and counter-clock-wise.<BR><BR>See <A HREF="../Samples/stepper_motor.asm"><B>stepper_motor.asm</B></A>in Samples folder.<BR><BR>See also <A HREF="io.html"><B>I/O ports</B></A> section of Emu8086reference.<BR><BR><BR><BR><HR><BR><B>Robot</B><BR><BR><IMG SRC="robot.gif" WIDTH=530 HEIGHT=352><BR><BR>Complete list of robot instruction set is given in<A HREF="io.html"><B>I/O ports</B></A> section of Emu8086reference.<BR><BR>To control the robot a complex algorithm should be used to achievemaximum efficiency. The simplest, yet very inefficient, is random movingalgorithm, see <A HREF="../Samples/robot.asm"><B>robot.asm</B></A> in Samples folder.<BR><BR>It is also possible to use a data table (just like for Traffic Lights), thiscan be good if robot always works in the same surroundings.<BR><BR><BR><BR><BR><HR><CENTER><A HREF="asm_tutorial_11.html"><B> <<< Previous Part <<< </B></A> <A HREF="asm_tutorial_13.html"><B> >>> Next Part >>> </B></A></CENTER><HR><BR></FONT></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -