assembly version of drawing algorithm