• Please review our updated Terms and Rules here

Apple II Assembly Questions

Mister_Al

Member
Joined
Jul 16, 2011
Messages
26
Been a long time since I've posted here.

I have been studying 6502 assembly for several months and now feel comfortable about trying some simple programming. Unfortunately I am having trouble getting an assembler that will work properly (more on that another time) so have been trying some POKES and Shape Tables in BASIC to get accustomed to working with bytes.
There are plenty of questions I'd like to ask, but I'll stick with these for now:

1. Some program listings have POKES for 'negative' addresses. -1024, -4320, for example. How is this possible if address start at zero?

2. Is plotting pixels in either resolution via POKE faster than PLOT/HPLOT?

3. I am able to move a lo-res pixel around the screen via POKES. To advance another row, all you have to do is increase the POKE value by 128, but the middle of the screen's locations are actually LOWER:

Top: $780/1920
Middle: $428/1064
Bottom: $7A8/1960

How do I go about handling this? I imagine it will come up again when I get into full-fledged assembly programming.
 
1. Some program listings have POKES for 'negative' addresses. -1024, -4320, for example. How is this possible if address start at zero?

16-bit two's complement values range from -32,768 to 32,767.
Decimal values 0 through 32,767 have hex values 0000 through 7FFF
Decimal values -32,768 through -1 have hex values 8000 through FFFF
 
I still don't understand. why not use positive 32,768 to get $8000, instead? I tried several decimal/binary converters and they don't return anything for negative values.
 
In BASIC *all* numeric data types are signed which means they can be negative as well as positive (as opposed to unsigned data types available in other languages that can only be positive). The most significant bit, called the sign bit, is used to differentiate between the two. This means that with 16 bits (for example) only the range of numbers between -32768 to 32767 can be used. Trying to use (ie do some kind of operation on) a number higher than or equal to 32768 will cause an overflow error.

When people use negative numbers like this it is just to circumvent the limitations of BASIC. If you want to POKE an address higher than 32767 you must use a negative number. Your example above with -4320 is really just another way to represent the number 61216.

Hope this helps!
 
In BASIC *all* numeric data types are signed which means they can be negative as well as positive (as opposed to unsigned data types available in other languages that can only be positive). The most significant bit, called the sign bit, is used to differentiate between the two. This means that with 16 bits (for example) only the range of numbers between -32768 to 32767 can be used. Trying to use (ie do some kind of operation on) a number higher than or equal to 32768 will cause an overflow error.

When people use negative numbers like this it is just to circumvent the limitations of BASIC. If you want to POKE an address higher than 32767 you must use a negative number. Your example above with -4320 is really just another way to represent the number 61216.

Hope this helps!

Actually, in Applesoft, you can poke numbers over 32768, I used to modify DOS 3.3 this way all the time. The negative poke mechanism may have been left in place to be compatible with Integer basic, which may have the 32768 limitation.

Also, "call -151" is a lot easier to remember than "call 65385"
 
Back
Top