[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with confirmation on a small bit of assembly?



Hi everyone.
I was just after a little help. It's not 100% apple2 related, but it is 6502
related.
It's for my uC based USB card. I finally nailed hopefully all the hardware
problems. But now I'm back at the problem of it getting stuck during
initialisation.
I've ported the code to C but there still seem to be a few bugs.

The code below is the original MicroUSB assembly.

03420          LDY #8
03430 .3       TYA
03440          CLC
03450          ADC #$F
03460          TAX
03470          LDA SETCONF-1,Y
03480          JSR REGSTORE
03490          DEY
03500          BNE .3


This is my rough interpretation of that small block.
Please note the 0x10 is what truly bothers me. If I understand the asm
correctly I should have the value 0x11 there to ensure it starts off at
0x18

   for( tmp = 7; tmp >= 0 ; --tmp )
      regStore( SETCONF[ tmp ] , ( tmp + 0x10 ) );


The below code is why it bothers me so. Note: BUFADR and BUFLEN are address
values for on the USB IC. BUFADR is 0x01 and BUFLEN is 0x02, not that it's
really important anyway.

02880          LDA #$10    ; $10 ADDR
02890          LDX #BUFADR ; DATABUF
02900          JSR REGSTORE
02910 ;
02920          LDA #$8     ; 8 BYTE
02930          LDX #BUFLEN ; DATABUF
02940          JSR REGSTORE

C equivalent:

regStore(0x10, BUFADR); //databuf base location?
regStore(0x08, BUFLEN); //setting an 8 byte buffer

To me that says that there is an 8 byte buffer set up with a base address of
0x10 on chip. This would mean that the buffer is from 0x10 to 0x17, not
0x11 to 0x18 as the assembly suggests to me.

The original source works fine from what I can understand. So the problem
must be my misinterpretation. I think.

Is my top little fragment of C correct?, and if so with 0x10 or 0x11 as the
value. I'm leaning toward 0x11.

The code up to that point seems to be okay though. When running it can
successfully discriminate between having a normal USB device and a lowspeed
(HID) device connected. It just gets jammed waiting for right after that
little bit of code waiting for a reply from the USB device.

Any help would be appreciated. Especially because my C version of the
MicroUSB code once cleaned up could be really useful to people.

Thanks,
Tristan.

-- 
-----> http://members.dodo.com.au/~izabellion1/tristan/index.html <-----
=====       It's not pretty, it's not great, but it is mine.       =====