Bahasa Assembler :|
Control External Device
There are 3 devices attached to
the emulator: Traffic Lights, Stepper-Motor and Robot. You can view
devices using "Virtual Devices" menu of the emulator.
technical information see I/O ports section of
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 tricky electronic equipment.
Usually the ".bin" file is written into the Read Only Memory (ROM)
chip, the system reads program from that chip, loads it in RAM module and
runs the program. This principle is used for many modern devices such as
micro-wave ovens and etc...
control the traffic lights an array (table) of values is used. In certain
periods of time the value is read from the array and sent to a port. For
; directive to create BIN file:
; skip the data table:
table DW 100001100001b
MOV SI, 0
; set loop counter to number
; of elements in table:
MOV CX, 4
; get value from table:
MOV AX, table[SI]
; set value to I/O port
; of traffic lights:
OUT 4, AX
; next word:
ADD SI, 2
; start from over from
; the first value
; store registers:
; set interval (1 million
; microseconds - 1 second):
MOV CX, 0Fh
MOV DX, 4240h
MOV AH, 86h
; restore registers:
The motor can
be half stepped by turning on pair of magnets, followed by a single and so
The motor can be full stepped by turning on pair of magnets,
followed by 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
Half step is equal to 11.25 degrees.
Full step is
equal to 22.5 degrees.
The motor can be turned both
clock-wise and counter-clock-wise.
See stepper_motor.asm in
See also I/O ports section of
Complete list of
robot instruction set is given in I/O ports section of
To control the robot a complex algorithm should
be used to achieve maximum efficiency. The simplest, yet very inefficient,
is random moving algorithm, see robot.asm in Samples folder.
It is also possible to use a data table (just like for Traffic
Lights), this can be good if robot always works in the same surroundings.