+1 (315) 557-6473 

Simulating an automatic room light controller in x86 assembly assignment help

The assignment deals with implementing a program to simulate an automatic room light controller with a visitor counter. Our x86 assembly assignment help doer create a program that simulates a room with an entrance and exit. The visitors are generated randomly and depending on the number of visitors inside the room it turns the light on and counts the number of visitors.
Table Of Contents
  • Room Light Controller Simulation

Room Light Controller Simulation

INCLUDE Irvine32.inc .data door1msg BYTE 'Enter door has opened.',10,13,0 door2msg BYTE 'Exit door has opened.',10,13,0 nodoormsg BYTE 'The doors remain closed.',10,13,0 lightmsg BYTE 'Number of lights on: ',0 prompt BYTE 'Press enter to open a random door, escape to exit...',10,13,0 .code main PROC call Randomize ; seeds the random generator mov ecx,0 ; number of lights on will be saved in ecx, initialize to zero mainloop: mov edx,OFFSET lightmsg ; get the address of the message to print in edx call WriteString ; print the number of lights on message mov eax,ecx ; move the current count of lights on to eax for printing call WriteDec ; print the number call CrLf ; print a new line mov edx,OFFSET prompt ; get the address of the message to print in edx call WriteString ; print a prompt message call ReadChar ; wait for the user to press enter cmp al,27 ; see if the user pressed escape je endprog ; if so, end program call Random32 ; generate a random number and eax,1 ; see if the number was odd je door2open ; if it was even, assume door 2 (exit) was open door1open: ; else, door 1 (enter) was open mov edx,OFFSET door1msg ; indicate that the enter door was open call WriteString ; by printing the enter door message call CrLf ; print a new line inc ecx ; increment the number of lights by one jmp mainloop ; repeat the cycle door2open: cmp ecx,0 ; if there was no people inside, ignore je nodoor ; go to no door mov edx,OFFSET door2msg ; else, indicate that the exit door was open call WriteString ; by printing the exit door message call CrLf ; print a new line dec ecx ; decrement the number of lights on jmp mainloop ; repeat the cycle nodoor: mov edx,OFFSET nodoormsg ; indicate that no door was open call WriteString ; print the message call CrLf ; print a new line jmp mainloop ; repeat the cycle endprog: call WaitMsg exit ; exit the program main ENDP ; end of main procedure END main ; end of the program set main as the start