Loading ...
Sorry, an error occurred while loading the content.

1330Re: Programming Help

Expand Messages
  • sbirdasn
    Sep 1, 2003
    • 0 Attachment
      Will,

      Here's a little something I hammered out that will do the job nicely.
      It even does some rudimentry user input checking, patterned after the
      original elf. If your elf hardware has different input hardware,
      you'll have to adjust this code to match.

      I'm too lazy to really put it into a form that will assemble with one
      of the cross assemblers, but it is so simple you can just hand code
      it if you want to. That's your cost for getting "free code".

      One note, the RCA assembler uses the A(symbol) format to supply as
      the parameter a 16-bit address value. Therefore, seeing A.0(symbol)
      is like supplying the LSB of the word address to the assembler for
      use in the instruction. It's really like the official data sheets
      when they describe instruction behavior.

      Have fun.

      Tony Naef.

      ;test memory move routine
      ;
      ;assumptions: R0 is PC (jump to routine from 0000 long branch),
      ;OR -- any PC other than R2, RC, RD, RE, RF
      ;Use your own judgement on how to call this simple routine.
      ;R2 is stack, this code as written places it at the end of 16K
      ;uses 4 scratch pad registers,
      ;RC = Index table pointer
      ;RD = Source address
      ;RE = Destination address
      ;RF = total number of bytes to move.
      ;
      ;Routine is stupid, no checking for block overlap is done.
      ;
      ;There is even a copy verification check via checksum listed in table
      ;
      ;Note: Many of the notations are standard RCA style assembly format.
      ;Comments are a cross between the two.
      ;

      STACK EQU 03FFH

      ORG 0F400H

      MOVE_ENTRY:

      LDI A.1(STACK) ..initialize stack
      PHI R2
      LDI A.0(STACK)
      PLO R2

      LDI A.1(TBL_BASE) ..set lookup table base address
      PHI RB
      LDI A.0(TBL_BASE)
      PLO RC

      SEX R2

      WAIT:
      BN4 WAIT ..elf style I/O for a two-digit entry of
      table index

      IN 4
      OUT 4 ..show what was typed to user.
      DEC R2

      WAIT1:
      B4 WAIT1 ..wait for input switch released

      SHL ..index is entered as 0,1,2,3...
      SHL ..this adjusts for table entries taking 8
      bytes
      SHL ..for each program stored in ROM

      STR R2 ..put index on stack for doing math with.

      SDI A.0(TBL_END - TBL_BASE) ..check for value larger than
      table size
      BM WAIT ..get new index value if too big for table.
      ..max size is 256 bytes, or 32 entries.

      GLO RC
      ADD
      PLO RC
      GHI RC
      ADCI #0
      PHI RC

      LDA RC ..load source address from table
      PHA RD
      LDA RC
      PLO RD

      LDA RC ..load destination address from table
      PHA RE
      LDA RC
      PLO RE

      LDA RC ..load byte count to be moved.
      PHA RF
      LDN RC ..we will be rolling back on table later
      PLO RF

      MOVE:
      LDA RD ..copy block from source to destination
      STR RE
      INC RE
      DEC RF ..keep track of bytes moved

      GLO RF ..when count goes to zero, we're done
      BNZ MOVE
      GHI RF ..16-bit resolution, useful size is <16K
      BNZ MOVE ..You can put a branch forever here or
      something
      ..to return control to caller here.
      ..the rest is an optional checksum
      calculation.

      DEC RC ..re-point to destination, and size in table
      DEC RC
      DEC RC

      LDA RC ..now the destination address is the "source"
      PHI RD ..for the checksum calculations
      LDA RC
      PLO RD

      LDA RC ..get the block size moved to control the loop
      PHI RF
      LDA RC
      PLO RF

      SEX RD ..index to copied program bytes

      LDN #0 ..clear checksum
      PHI RE
      PLO RE

      ADD_BYTE:
      GLO RE ..calculate running 16-bit sum of all bytes,
      ADD
      INX
      PLO RE
      BNF NO_CARRY
      GHI RE ..carries increment high address too
      ADCI #0
      PHI RE

      NO_CARRY:
      DEC RF ..see if all bytes added yet

      GLO RF
      BNZ ADD_BYTE
      GHI RF
      BNZ ADD_BYTE

      SEX RC ..we left table pointer at the checksum,

      GHI RF ..logical operations use R(X) for one operand
      XOR
      BNZ BADCOPY ..a perfect match will be 0000h
      INX ..get LSB of result
      GLO RF
      XOR
      BNZ BADCOPY

      REQ ..make sure Q is off if good compare.

      SHOWBYTE:
      SEX R2 ..a perfect match will have 00h sent to display

      STR R2 ..any other value indicates bad checksum compare.
      OUT 4
      DEC R2

      STOP:
      BR STOP

      BADCOPY:
      SEQ ..a second indication that something's wrong.
      BR SHOWBYTE

      TBL_BASE: ..table format is 4 words, high order
      address first.
      DW A(PROG1) ..source address of program to be moved
      DW A(0000H) ..destination address
      DW A(PROG1END-PROG1) ..size of block to be moved.
      DW 1234H ..optional 16-bit checksum

      DW A(PROG2)
      DW 0100H
      DW A(PROG2END-PROG2)
      DW 4321H

      .. repeat for all programs that can be moved...

      TBL_END:

      ORG 9000H ..an arbitrary place to store the programs in
      ROM.

      PROG1:
      DB nn nn nn nn ..raw code listing assembled for desired
      target address.
      DB nn nn nn nn
      PROG1END:

      PROG2:
      DB nn nn nn nn ..raw code listing assembled for desired
      target address.
      DB nn nn nn nn
      PROG2END:

      ..Lather, rinse, repeat...



      --- In cosmacelf@yahoogroups.com, "William Waters" <engineer1@s...>
      wrote:
      > Tony,
      >
      > Your first guess is correct. I wish to locate many programs in
      EPROM, then
      > move any one of the images to location 0x0000 for execution. No
      changes are
      > to be made, this would be simpler and faster than using the tape
      interface.
      > And yes, I have 2 working Netronics ELF-II systems, One is an
      original and
      > working unit with 2 home-brew memory cards supporting 48K of mixed
      RAM/EPROM
      > and the other unit is homebrew but built to the Netronics design,
      sort-a,
      > with a 32K EPROM in the high half of address space and 16K of RAM...
      >
      > A full featured Relocation program would be the ultimate, but life
      does not
      > allow me the time to learn the 1802 and assembler to that level of
      > expertise, thus the quest to find an existing program that will
      work. The
      > referenced program does support a simple block move mode which is
      all I
      > need.
      >
      > Thanks
      >
      > Will
      >
    • Show all 13 messages in this topic