robinfawell Posted December 11, 2005 Report Share Posted December 11, 2005 Dear ThorstenI am currently thinking about the next stage in the organ program. I need to be able to read the sysex files that are stored on 2 Banksticks.The information was stored at various starting addresses, previously in assembler using the following code.;;IN: Index (Midi_EVNT1 or canc) in WREG ;;OUT: Bankstick Address in MIOS_PARAMETER [12] ;; Count in TMP [12] ;; Bankstick # in TMP3 MIDIO_BANKSTICK_DUMP_GET Mullw 6 ;; the addresses jump in increments of 6 bytes ;; result of multiplication is in PROD[HL] ;; Add Offset to base address of table 16 bit addition) ;; copy result to TBLPTR[HL] movlw (BANKSTICK_DUMP_TABLE & 0xFF) addwf PRODL, W movwf TBLPTRL movlw (BANKSTICK_DUMP_TABLE >>8) & 0xFF addwfc PRODH, W movwf TBLPTRH ;; First Entry: Bankstick Number tblrd*+ movff TABLAT, TMP3 ;; Second Entry: dummy, not used tblrd*+ ;; Third & Fourth Entry: Bankstick Address tblrd*+ movff TABLAT, MIOS_PARAMETER1 tblrd*+ movff TABLAT, MIOS_PARAMETER2 ;; Fifth & Sixth Entry; Count tblrd*+ movff TABLAT, TMP1 tblrd*+ movff TABLAT, TMP2 movf TMP3, W call MIOS_BANKSTICK_CtrlSet call MIDIO_SYSEX_Send_Block return MIDIO_SYSEX_Send_Block MIDIO_SYSEX_Send_BlockLoop clrwdt;; used for Reset large file call MIOS_BANKSTICK_Read ;; Expects Addr in ;;MIOS_PARAMETER[12], Read byte from BS call MIOS_MIDI_TxBufferPut ;;Decrement 16 bit loop counter, loop until counter is zero decf TMP1, F skpc decf TMP2, F bc MIDIO_SYSEX_Send_BlockLoop return;; This may need changing BANKSTICK_DUMP_TABLE ;; BS No Addr Count dw 0x0000, 0x0000, 0x04D4 - 1 dw 0x0000, 0x04D4, 0x04D4 - 1 dw 0x0000, 0x09A8, 0x04D4 - 1 dw 0x0000, 0x0E7C, 0X09A8 - 1 dw 0x0000, 0x1824, 0X04D4 - 1 dw 0x0000, 0x1CF8, 0X04D4 - 1 dw 0x0000, 0x21CC, 0X04D4 - 1 dw 0x0000, 0x26A0, 0X03C0 - 1 dw 0x0000, 0x2A60, 0x04BC - 1 dw 0x0000, 0x2F1C, 0x04CA - 1 dw 0x0000, 0x33E6, 0x032C - 1 dw 0x0000, 0X3712, 0X0000 - 1 dw 0x0000, 0X3712, 0X0000 - 1 dw 0x0000, 0X3712, 0X0000 - 1 dw 0x0000, 0X3712, 0X0000 - 1 dw 0x0000, 0X3712, 0X0000 - 1 dw 0x0000, 0x3712, 0x02F4 - 1 dw 0x0000, 0x3A06, 0x02F4 - 1 dw 0x0000, 0x3CFA, 0x02F4 - 1 dw 0x0000, 0x3FEE, 0x01E0 - 1 dw 0x0000, 0X41CE, 0X0000 - 1 dw 0x0000, 0X41CE, 0X0000 - 1 dw 0x0000, 0X41CE, 0X0000 - 1 dw 0x0000, 0X41CE, 0X0000 - 1 dw 0x0000, 0x41CE, 0x0574 - 1 dw 0x0000, 0x4742, 0x028C - 1 dw 0x0000, 0X49CE, 0X0000 - 1 dw 0x0000, 0X49CE, 0X0000 - 1 dw 0x0000, 0X49CE, 0X0000 - 1 dw 0x0000, 0X49CE, 0X0000 - 1 dw 0x0000, 0X49CE, 0X0000 - 1 dw 0x0000, 0X49CE, 0X0000 - 1 dw 0x0001, 0x0000, 0x04CA - 1 dw 0x0001, 0x04CA, 0x04CA - 1 dw 0x0001, 0x0994, 0x04CA - 1 dw 0x0001, 0x0E5E, 0x04CA - 1 dw 0x0001, 0x1328, 0x04CA - 1 dw 0x0001, 0x17F2, 0x04CA - 1 dw 0x0001, 0x1CBC, 0x032C - 1 dw 0x0001, 0X1FE8, 0X0000 - 1 dw 0x0001, 0x1FE8, 0x02F4 - 1 dw 0x0001, 0x22DC, 0x01E0 - 1 dw 0x0001, 0X24BC, 0X0000 - 1 dw 0x0001, 0X24BC, 0X0000 - 1 dw 0x0001, 0X24BC, 0X0000 - 1 dw 0x0001, 0X24BC, 0X0000 - 1 dw 0x0001, 0X24BC, 0X0000 - 1 dw 0x0001, 0X24BC, 0X0000 - 1 dw 0x0001, 0x24BC, 0x0574 - 1 dw 0x0001, 0x2A30, 0x03A0 - 1 dw 0x0001, 0x2DD0, 0x03A0 - 1 dw 0x0001, 0x3170, 0x03A0 - 1 dw 0x0001, 0x3510, 0x03A0 - 1 dw 0x0001, 0x38B0, 0x0574 - 1 dw 0x0001, 0x3E24, 0x0574 - 1 dw 0x0001, 0x4398, 0x028C - 1 dw 0x0003, 0x0000, 0x4056 - 1 dw 0x0003, 0x4056, 0x0AC4 - 1 dw 0x0003, 0x4B1A, 0x0AC4 - 1 dw 0x0003, 0x55DE, 0x0000 - 1 dw 0x0003, 0x55DE, 0x0000 - 1 dw 0x0003, 0x55DE, 0X0000 - 1 dw 0x0003, 0x55DE, 0x0000 - 1 dw 0x0003, 0x55DE, 0x0000 - 1 I assume that using "C", the address and count will be located in an array associated with the" pin" variable. I may also, I think, need to include the clwdt in the loop for the large "reset" byte count.I think that the following is pertinent. MIOS functions (MIOS_*) can mostly be called from a C program without performance loss, so long it has only one input and/our output parameter. Functions with more parameters require some extra code which copies the C parameters (which are pushed into the stack) to MIOS_PARAMETER[123]Is it better to have an assembler routine or will the loop program be OK using loops in C program code. Your help will be appreciated.Regards Robin Quote Link to comment Share on other sites More sharing options...
TK. Posted December 11, 2005 Report Share Posted December 11, 2005 Hi Robin,it's better to re-write this in C, because this improves the flexibility.Yes, the long table is just an constant array, all the pointer calculation stuff will be done by the compiler. In general the code looks like this:const unsigned int dump_table[] = { // BS Addr Count 0x0000, 0x0000, 0x04d4 - 1, 0x0000, 0x04d4, 0x04d4 - 1, // etc...};void SendDump(unsigned char dump_index){ unsigned int addr = dump_table[dump_index*3 + 1]; unsigned int count = dump_table[dump_index*3 + 2]; MIOS_BANKSTICK_CtrlSet((unsigned char)dump_table[dump_index*3 + 0]); // converted int -> char do {__asm clrwdt__endasm; MIOS_MIDI_TxBufferPut(MIOS_BANKSTICK_Read(addr++)); } while( count-- );}[/code]As you can see, the special clrwdt instruction has to be inserted inside a __asm blockBest Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.