Shop OBEX P1 Docs P2 Docs Learn Events
how can 8 bit PC access 512byte of ROM — Parallax Forums

how can 8 bit PC access 512byte of ROM

eehobbyeehobby Posts: 4
edited 2007-07-27 18:59 in General Discussion
In SX28, the program memory is divided into 4 pages, each page is 512bytes. PA2, PA1, PA0 is for page selection. In the data sheet,

PA2:PA0 = 000 page 0
·············· 001 page 1
·············· 010 page 2
·············· 011 page 3

The MSB is essentially not used, so how can 8 bit PC can access 512 ROM? Thanks for help.

Comments

  • BeanBean Posts: 8,129
    edited 2007-07-24 02:14
    First program memory is in 12 bit words, not bytes. But that's not important here.

    When a JMP instruction is executed address·bits 0 to 8 (9 bits) come from the instruction itself, bits 9-10 come from PA0 and PA1.

    When a CALL or MOV PC,x is executed address bits 0 to 7 (8 bits) come from the instruction, bit 8 is always 0, bits 9-10 come from PA0 and PA1

    This is why a subroutine must be in the first half of any code page (because bit 8 is always set to 0).
    And why a MOV PC,x location must be in the first half of any code page (same reason).

    I hope this make sense, it's kinda hard to explain...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Teacher: What is the difference between ignorance and apathy ?
    Student: I don't know and I don't care
    Teacher: Correct !
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2007-07-24 08:11
    Actually, the SXes do have an "internal" program counter that is 11 bits wide (12 bits in the SX48/52 devices) used to address any word cell in program memory. Mapped to the "outside", i.e. into RAM address $02 are the lower eight bits only.

    As Bean explained, for a jump or call instruction, the target address is composed by the lower 9 bits in the instruction (or 8 bits for calls with the 9th bit always 0), and by the upper two bits PA1 and PA0 in the status register (for the SX48/52, three bits PA2...0 are used).

    As long as program code is "linear", it is no problem when such code crosses page boundaries. Let's assume there is an instruction at program memory address $2FF. After this has been executed, the instruction at address $300 will be executed next because the "internal" program counter simply increments into the next page.

    Be aware that it can cause much PIA when you perform a jmp instruction after such a "silent" page boundary crossing. You might assume it would not be a problem jumping to a target in page $300, following the example above. As the target address for a jmp is composed as mentioned before, you must make sure that the PA bits in the status register are set to page $300 prior to the jump. Otherwise, the jump will land in page $200.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • John CoutureJohn Couture Posts: 370
    edited 2007-07-27 18:59
    (grin) actually the subject suggests an answer of:

    "one byte at a time"

    Just teasing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
Sign In or Register to comment.