PEEK & POKE math (?? +256 ??)

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
vwbz80a
Posts: 31
Joined: Wed Nov 29, 2017 2:35 pm

PEEK & POKE math (?? +256 ??)

Post by vwbz80a »

This must be really Obvious!!!!! But it is NOT computing between the ears. (or on paper). :oops:

Problem: why do you add 256 to the low byte decimal before multiplying by the high order decimal? :roll: :roll:
using a hex calculator there is no need for any additon.

and it is not that i can't get the right values to poke in, or peek at...........[here is where we loose everyone]....because i can.

It is that i just wish to use the simple calculator, manually. and follow the process. make sense ?

Okay. Why do you add 256 (ZX81 Basic add 256)? :geek: :geek:
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: PEEK & POKE math (?? +256 ??)

Post by Andy Rea »

We are not adding 256 to the low byte... when we do something like

Code: Select all

PRINT PEEK 16388 + 256 * PEEK 16389
To display the current value of ramtop you have to remeber the order of processing.

the computer will do both PEEKS then it will multiple the second PEEK [highbyte] value by 256 and finally add on the first PEEK [lowbyte] value.

hth Andy
what's that Smell.... smells like fresh flux and solder fumes...
vwbz80a
Posts: 31
Joined: Wed Nov 29, 2017 2:35 pm

Re: PEEK & POKE math (?? +256 ??)

Post by vwbz80a »

Andy Rea wrote: Mon Jan 15, 2018 6:12 pm We are not adding 256 to the low byte... when we do something like

Code: Select all

PRINT PEEK 16388 + 256 * PEEK 16389
To display the current value of ramtop you have to remeber the order of processing.

the computer will do both PEEKS then it will multiple the second PEEK [highbyte] value by 256 and finally add on the first PEEK [lowbyte] value.

hth Andy
thanks, Andy.
Post Reply