6802 assembly help please.

Thread Starter

Danno.

Joined Apr 6, 2015
39
Hi,
Could somebody please help me understand what's going on in this subroutine, processor is a 6802.


7198 ldx #$2000
719B clr x0006
719E tst $00, x
71A0 bpl L71A5
71A2 inc X0006
71A5 inx
71A6 cpx #$2005
71A9 bne L719E
71AB rts


Is it some kind of timer circuit???

Thanks in advance.
 
Last edited:

MrChips

Joined Oct 2, 2009
30,824
I can, but there is an error in the code at line (address) 71A6.
Perhaps you recorded the line incorrectly.

Edit: incorrect code at address 71A6 was cpx #$2000
 

Thread Starter

Danno.

Joined Apr 6, 2015
39
No, it's a hobby. I have a machine which is 36 years old and I am playing about with whilst trying to work out assembly coding at the same time.

Never to old to learn but to old for school now LOL.
 

MrChips

Joined Oct 2, 2009
30,824
Start by drawing a flow chart.

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.
 

Thread Starter

Danno.

Joined Apr 6, 2015
39
Thanks Mr Chips, it all makes sense now and it does serve a purpose.

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.

One quick question, the tst $00,x instruction means test index accumulator without adding anything to the address?

Cheers
 

Thread Starter

Danno.

Joined Apr 6, 2015
39

MrChips

Joined Oct 2, 2009
30,824
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.:eek: 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.
 
Top