6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 7:23 pm

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: [129.1] Help me please!
PostPosted: Tue Oct 16, 2001 7:14 am 
Hi everybody,
I'm a total novice with 6502's so I was wandering if anyone could help me with a few questions.

1) A 6502 has 16 address lines. How many different memory locations can be accessed with these lines?

2) If it only had 10 address lines, how many different locations would it be possible to access?

3) For a 6502 how many bits can be stored in each memory location?

4) How many memory locations would be required to store the decimal number 76543?

Any help with these would be much appreciated!

Cheers

Reddevil1999


Report this post
Top
  
Reply with quote  
 Post subject: [129.2] Help me please!
PostPosted: Tue Oct 16, 2001 2:34 pm 
Offline

Joined: Fri Aug 30, 2002 3:06 pm
Posts: 124
Location: Colorado
>1) A 6502 has 16 address lines. How many different memory locations can be accessed with these lines?

2^16 (2 to the 16th power), which is 65,536 addresses. The addresses are usually expressed in hexadecimal notation (base 16), which means the possible address are 0000 to FFFF.

>2) If it only had 10 address lines, how many different locations would it be possible to access?

2^10, which is 1024 addresses. In hex, 0000 to 03FF.

>3) For a 6502 how many bits can be stored in each memory location?

Eight. When talking about processors, some examples of various "word lengths" are (most of these are old and obsolete):
4 bit - Intel 4004.
8 bit - 6502, 6800, 8080, 8085, Z80, and many others.
12 bit - PDP-8 (very old), and some PIC micros (new).
14 BIT - some PIC micros (new).
16 bit - 8086, DEC PDP-11, TI 9900, and many others.
18 bit - (some old minicomputers, I forget which).
32 bit - 68000 series, Intel Pentium, and many others.

>4) How many memory locations would be required to store the decimal number 76543?

With an 8-bit CPU such as the 6502, it takes 3 locations (3 bytes). Two bytes would only store up to 65535 (positive numbers only), 3 bytes gives you a range of values from 0 to 65536 X 256, which is about 16 million I think.

Pete


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [129.3] Help me please!
PostPosted: Wed Oct 17, 2001 2:44 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
> I'm a total novice with 6502's so I was wondering
> if anyone could help me with a few questions.

We're glad to help novices. If we don't, we'll have fewer experts later.

> 1) A 6502 has 16 address lines. How many different
> memory locations can be accessed with these lines?

I might add a little to Pete's answer here. If you determine that it's too confusing to handle at this point, just leave it for later. You'll get there soon.

Although the 16 lines give 65,536 locations (each one 8 bits, or one byte), you'll need a few of those for I/O. The 6502 family of microprocessors has what we call "memory-mapped I/O", meaning that the microprocessor (uP) accesses the I/O ICs through those ICs' own registers. To the uP, these registers look just like memory. The I/O could occupy as little as one or two of the 65,536 addresses, leaving the rest for actual memory. More realistically though, the I/O will often take up a few dozen memory locations, and simple address-decoding schemes will usually waste the rest of a block of possibly 8K (8,192) or 16K (16,384) bytes. I'm not being critical in putting it that way. Realize that for many projects, the hardware simplicity gained by doing the address decoding this way is far more important than the memory space lost. Your first home-made computer may only have 2K or 8K of RAM, and you may never use more than a few hundred bytes of that before your ambitions drive you to make version 2, a better computer.

I might also add that there are three parts of the 6502 memory map that have special jobs, which you'll learn about early in your study of this uP. The 65,536 memory locations are grouped in 256 pages of 256 bytes each. The first page is called "page zero" or "zero Page" (ZP). The uP can access these 256 memory locations faster than any of the other 63,280. The uP's instruction set also allows more ways to use ZP locations for various types of pointers, giving more flexibility.

Page 1, i.e. memory locations 100-1FF, is reserved for the uP stack. For the simplest example of stack usage, if your program calls a subroutine, the return address is automatically stored on the stack so the program can get back to your main routine after the subroutine is completed. The stack will virtually never need the entire page 1; so if you're really hard up for memory, you can use page 1 to store other stuff too as long as you know you're not putting it where it will interfere with the stack.

The other group of special addresses is the last six, at the opposite end of memory from ZP. These six are almost always ROM, and are called "vectors". When you first start up the uP, it looks at addresses FFFC & FFFD (the reset vector). The 16-bit number stored there is the address of the first byte of the routine with which you want the uP to begin execution.

Similarly, addresses FFFA-FFFB point to the beginning of the routine to service non-maskable interrupts (NMI), and FFFE-FFFF point to the beginning of the routine to service normal (maskable) interrupt requests (IRQ).

Since the reset vector and the reset routine in simple systems are always in ROM and pages 0 and 1 need RAM, you can see why the ROM in a 6502 system normally goes at address FFFF and down, whereas RAM starts at 0000 (or close to it) and goes up. You won't have ROM at address 0000 like you do on some other systems.

Well, I see I got carried away again, and this forum is not particularly intended for tutorials, but what the heck-- somebody else will be wondering the same things but be too embarrassed to ask and won't know yet about the many good books that have the same info. Do check out the book listings at http://6502.org/documents/books/ and at http://wilsonminesco.com/links.html#brands (and the rest of that page).

Edit, many years later: See also my 6502 primer at http://wilsonminesco.com/6502primer/ which has 22 logically organized chapters (html pages) on building your own 6502 computer.

[Edit, 12/22/21: I added some tips on how to get forum help, in the second half of the 6502 primer's page about general steps for a successful project, at http://wilsonminesco.com/6502primer/steps.html, after the heading "Getting help on the 6502.org forum:"]

Garth

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [129.4] Help me please!
PostPosted: Wed Oct 17, 2001 9:18 am 
Hi Pete, thanks very much for answering those questions for me, it was a great help. As I said before, I'm a complete novice with 6502's. We've just started a module on microprocessors in my engineering degree so hopefully I'll learn a bit more about 6502's.

James


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: