--The program acquires a 10bit TDC timestamp and computes the 256 bin coarse histogram
--	the encoded output is in the RAM starting with RAM(1) in byte0 and byte1

#define timestamp 0				--register R0 is used for holding the timestamp
#define b0_incrementAmount 1	--register R1 is used for holding constant 1 for RAM byte 0
#define b1_incrementAmount 2	--register R2 is used for holding constant 1 for RAM byte 1
#define bitMask 3				--register R3 is used for holding the mask to check bit8
#define R4 4

#define CtrlOut 0b10000			--address for external trigger signal


0: LOAD b0_incrementAmount, $0, 1
1: LOAD b0_incrementAmount, $1, 0
2: LOAD b1_incrementAmount, $0, 1
3: LOAD b1_incrementAmount, $256, 0
4: LOAD bitMask, $0, 1
5: LOAD bitMask, $128, 0

6: GETP 5, 1, 0 				--get pixel data and store it in R0 (timestamp) 

7: SR0 timestamp, timestamp  	--truncate to 9bits 
8: SR0 timestamp, timestamp		--truncate to 8bits

9: AND timestamp, bitMask, R4	--check the 8th bit
10: JUMPZ 14					--if 0, process using byte0 of RAM, else use byte1
11: ADD (timestamp), b1_incrementAmount, (timestamp) --increment histogram bin
12: TELL CtrlOut, 0				--strobe CtrlOut
13: JUMP 6						--new timestamp

14: ADD (timestamp), b0_incrementAmount, (timestamp) --increment histogram bin
15: TELL CtrlOut, 0				--strobe CtrlOut
16: JUMP 6						--new timestamp
