Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#start = robot.exe# name robot #make _ bin# #cs = 5 0 0 # #ds = 5 0 0 # #ss = 5 0 0
#startrobot.exe#
name "robot"
#makebin#
#cs #
#ds #
#ss # ; stack
#sp ffff#
#ip #
; this is an example of contoling the robot.
; this code randomly moves the robot,
; and makes it to switch the lamps on and off.
; robot is a mechanical creature and it takes
; some time for it to complete a task.
; status register is used to see if robot is busy or not.
; c:emudevicesrobotexe uses ports and
; source code of the robot and other devices is in:
; c:emudevicesdevelopersources
; robot is programmed in visual basic
; robot base io port:
rport equ
;
eternalloop:
; wait until robot
; is ready:
call waitrobot
; examine the area
; in front of the robot:
mov al
out rport, al
call waitexam
; get result from
; data register:
in al rport
; nothing found?
cmp al
je cont ; yes, so continue.
; wall?
cmp al
je cont ; yes, so continue.
; switchedon lamp?
cmp al
jne lampoff ; no so skip.
; yes, so switch it off,
; and turn:
call switchofflamp
jmp cont ; continue
lampoff: nop
; if gets here, then we have
; switchedoff lamp, because
; all other situations checked
; already:
call switchonlamp
cont:
call randomturn
call waitrobot
; try to step forward:
mov al
out rport, al
call waitrobot
; try to step forward again:
mov al
out rport, al
jmp eternalloop ; go again!
;
; this procedure does not
; return until robot is ready
; to receive next command:
waitrobot proc
; check if robot busy:
busy: in al rport
test alb
jnz busy ; busy, so wait.
ret
waitrobot endp
;
; this procedure does not
; return until robot completes
; the examination:
waitexam proc
; check if has new data:
busy: in al rport
test alb
jz busy ; no new data, so wait.
ret
waitexam endp
;
; switch off the lamp:
switchofflamp proc
mov al
out rport, al
ret
switchofflamp endp
;
; switch on the lamp:
switchonlamp proc
mov al
out rport, al
ret
switchonlamp endp
;
; generates a random turn using
; system timer:
randomturn proc
; get number of clock
; ticks since midnight
; in cx:dx
mov ah
int ah
; randomize using xor:
xor dh dl
xor ch cl
xor ch dh
test ch
jz noturn
test ch
jnz turnright
; turn left:
mov al
out rport, al
; exit from procedure:
ret
turnright:
mov al
out rport, al
noturn:
ret
randomturn endp
;
in this code there is a problem that the robot moves randomly which take a long time to turn all the lamps on so can you please make some changes on the code so the robot can turn on all the lamps as fast as possible with a regular movment
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started