simulate with 1024 byte local mem
merged Sahar's changes with mine