65EL02

Bookmark this on Digg
Bookmark this on Delicious
Share on reddit

Useful information related to 65EL02 used in Redpower Control

!Under Construction!

Changes

Redpower 5p2

Operation Code Chart for 65EL02

Link to interactive table

  • the TXI instruction is a new addition by Eloraam as like the “I” register, which means “index” or something similar… It transfers the content of the X register to the I and changes the N and Z flags. (it’s like STX I if you define I as a variable)
  • the NXA instruction gets a byte or word into register A (depends on the M flag) from the memory position I and increments the I by 1 or 2. Example about how it works:

I = $02 ; whatever
LDA (I)
INC I
.if flagM = 1 ; 16-bit mode
INC I
.fi
									

The new instructions is made to accelerate the emulation in certain cases.

 

Comparison and Branching
These rules apply to all the comparison instructions (CMP, CPX, and CPY)

Flag Registers N Z C
A, X, or Y = Memory 0 1 1
A, X, or Y > Memory 0 0 1
A, X, or Y < Memory 1 0 0

If the Z flag is 0, then A <> NUM and BNE will branch
If the Z flag is 1, then A = NUM and BEQ will branch
If the C flag is 0, then A (unsigned) < NUM (unsigned) and BCC will branch
If the C flag is 1, then A (unsigned) >= NUM (unsigned) and BCS will branch

Addressing Modes

A chart explaining each addressing mode (the way 6502 references memory)
Inst. is short for instruction
D8 is short for 8bit value
AL || AH are two 8bit values combined to make a 16 bit value

Addressing Mode Command Structure Explanation
Accumulator Inst. commands/instructions that use the data in accumulator. e.g. ASL(0x0A)
Implied Inst. instructions that do not need any data. e.g. TAX(0xAA)
Immediate Inst. D8 D8 refers to raw data. e.g. LDA #$FF (0xA9 0xFF)
Zero Page Inst. D8 D8 points to addresses in the zero page. LDA $FF (0xA5 0xFF)
Zero Page Index X Inst. D8 D8+X points to addresses in the zero page
Zero Page Index Y Inst. D8 D8+X points to addresses in the zero page
Absolute Inst. AL AH AH || AL points to the effective address
Absolute Index X Inst. AL AH AH || AL+X points to the effective address
Absolute Index Y Inst. AL AH AH || AL+Y points to the effective address
Indirect Inst. AL AH AH || AL points to the effective address stored in the address referenced
Index Indirect Inst. D8 D8+X points to the effective address stored in the zero page address referenced
Indirect Index Inst. D8 D8 points to the effective address stored in the zero page address (+Y) referenced
Relative Inst. D8 D8 is a signed 8bit value (-128 <= D8 <= 127), and PC+D8 points to the jump address

Bootloader
Here is the 0×0400 bootloader code that runs when the system starts, before the actual disk contents. If you want to replace the boot code you need to modify the /eloraam/control/rpcboot.bin file in the RedPowerControl-2.0 file. The maximum allowed size for this file is 256 bytes.

38 FB A5 00 EF 00 C2 30 A9 00 03 EF 01 EF 02 64
02 A9 00 05 85 04 A5 02 8D 80 03 E2 20 A9 04 8D
82 03 CB CD 82 03 F0 FA AD 82 03 F0 09 EF 82 E2
30 18 FB 4C 00 05 C2 20 A2 00 03 5C A0 40 00 42
92 04 E6 04 E6 04 88 D0 F6 E6 02 4C 16 04

  SEC
  XCE    ; Set emulation flag

  LDA 0
  MMU #0    ; Map disk drive

  REP #$30
  !al    ; 16-bit mode

  LDA #$300
  MMU #1    ; Set redbus window to $300
  MMU #2    ; Enable redbus

  STZ 2    ; Set 2 to zero

  LDA #$500
  STA 4    ; Put $500 in 4

  LDA 2
  STA $380  ; Set sector number to (2)

  SEP #$20
  !as    ; 8-bit mode for acc

  LDA #4
  STA $382  ; Read disk sector

-  WAI    ; Wait a tick

  CMP $382  ;           Why compare it to A instead of #0?
  BEQ -    ; not ready yet, jump back

  LDA $382
  BEQ +    ;          This makes absolutely no sense

  MMU $82    ; Disable Redbus

  SEP #$30
  !al    ; 8-bit for all

  CLC
  XCE    ; Clear emulation flag

  JMP $500  ; Execute loaded code

+  REP #$20
  !al

  LDX #$300
  TXI    ; WTF?

  LDY #$40
  NXA

  STA (4)
  INC 4
-  INC 4

  DEY

  BNE -

  INC 2

  JMP $416
									

http://pastebin.com/BF4Dp0FA

Another note is that when trying to read from disks with images over 64kb, the system seems to hang until you halt/reset and remove the disk

If you want to boot a bigger disk then the “original” boot loader overflows because it’s always jumps back to next sector read at 044b. A bne $0416 instead of the jump and then a jmp $042d should solve the problem.

2 thoughts on “65EL02

  1. It’s maybe noteworthy to say that Zp Indexed addresses can leave the Zero Page, for example with a command that uses Zp,X giving it 00 as Zp address makes it use an absolute X address. Atleast if X is 16 bit or more.

    No idea if that’s common, broadly known or a little secret, just wanted to mention it.

  2. I also decompiled the boot loader by hand and I noticed that your decompile dose not match mine. I compiled mine with acme and did a diff with the original rpcboot.bin so it should be correct.

    !cpu 65EL02
    !to “rpcboot.bin”, plain

    default_disk=$00
    sector=$02
    mem_ptr=$04
    program_start=$500

    *=$400
    SEC ;set carry flag
    XCE ;set emulation flag

    LDA default_disk ;map default disk drive 1 to redbus window
    MMU #$0

    REP #$30 ;set to 16bit mode
    !al
    !rl

    LDA #$300 ;set redbus window offset to 0×300
    MMU #$1
    MMU #$2 ;enable redbus

    STZ sector ;init current sector

    LDA #program_start
    STA mem_ptr

    load_sector
    LDA sector
    STA $380

    SEP #$20 ;set to 8bit mode
    !as

    LDA #$04 ;Read Disk Sector
    STA $382
    - WAI ;Wait for the disk status to change
    CMP $382
    BEQ -

    LDA $382 ;if disk status is 0 copy_sector;
    BEQ copy_sector

    ;if disk status is not 0 load the code
    MMU #$82 ;disable redbus
    SEP #$30 ;set to 8bit mode
    !as
    !rs

    CLC ;clear carry flag
    XCE ;clear emulation flag
    JMP program_start

    copy_sector
    REP #$20 ;set to 16bit mode
    !al
    !rl

    LDX #$300
    TXI
    LDY #$40

    - NXA
    STA (mem_ptr)
    INC mem_ptr
    INC mem_ptr
    DEY
    BNE -
    INC sector

    JMP load_sector

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by sweetCaptcha