I’m trying to porting a MIOS application wrote in C to ASM. All work just done but i need an help on this:
In my hardware I’m using a 2 position switch on an AIN unmuxed and it is working good with C allowing it to assume only value 0 or 127.
I’m not able to translate in ASM.
My C code ( in pot section ) is:
{
// Only allow value 0 or 127
this_value = this_value < 63 ? 0 : 127;
// If valid, send CC out
MIOS_MIDI_TxBufferPut(0xb0);
MIOS_MIDI_TxBufferPut(53);
MIOS_MIDI_TxBufferPut(this_value);
}
Any help to make the same thing in ASM under the section USER_AIN_NotifyChange?
In this moment I’m using the mios_table.inc for specify the midimessages of the pots.
considered that bit #6 will be set on values >= 64, you could write:
movlw 0xb0
call MIOS_MIDI_TxBufferPut
movlw 0x53
call MIOS_MIDI_TxBufferPut
movlw 127
btfss this_value, 6 ; bit 6 is set on values >= 64
movlw 0
call MIOS_MIDI_TxBufferPut
[/code]
Btw.: you split the range between 0..62 and 63..127, but it's better to split it at 64, since it's exactly the half of the value range.
Best Regards, Thorsten.
MAIN.ASM 289 : Symbol not previously defined (this_value)
something like the “this_value” not recognize…
I can’t understand where’s the error…
The assembler tells you exactly what the problem is: It doesn’t know what “this_value” is supposed to be, as it’s not defined anywhere (in the C code it must be defined somewhere). Instead of “this_value” you have to use the address(es) where the AIN values are stored.