Well, this is a problem

mask = Lookupl digit,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18], digit

Try this instead ...

Lookup digit,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18], mask

HTH

P.S. You'll need to speed up the loop for it to display properly.