The code begins by setting the x-register to $2000 and clearing memory location 6, used as a counter.
The code scans memory locations $2000 to $2004 inclusive and counts the number of times it finds a negative value (signed 8-bit number) i.e. bit-7 is 1.

This code serves no useful purpose as far as I can see. That is why I would expect this to be a piece of homework exercise.

The machine has 6 coin switches memory mapped to addresses 0x2000 - 0x2005, what this subroutine appears to do is scan the switches when the machine is switched on to check if any are stuck. Immediately on returning from this subroutine the code checks the status of memory location 0x0006 and either branches to continue with program or branches to another subroutine that causes an alarm.

Originally I was just not getting that it was pointing to those memory locations, your explanation made everything fall into place, thanks.

Depends on the specific chip. Most chips of that era were simply CPUs; they had no internal memory.
Hence the standard practice was to program a UV-EPROM.
I used a programmer on a S100-Bus system running CP/M. Yikes! Turn around time to reprogram the UV-EPROM was 45 minutes. That's how long it took to erase the UV-EPROM. You made sure that there weren't too many mistakes in your code.

There were no fancy IDE then. You used a text editor to write your ASM code followed by an assembler to produce hex code. Then you used the programmer program to flash the UV-EPROM.

Next, you remove the UV-EPROM from the programmer and plug it into your proto board... apply power and then hope for the best.

My first code for a micro was assembled by hand for an RCA 1802 and then programmed into the UV-EPROM. No editor or assembler involved.