Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAIN call MIDIIn ;wait for MIDI status byte
- movlw 0xC0 ;is it a program change message on MIDI
- xorwf DAT,W ;channel 1?
- btfss STATUS,Z
- goto MAIN ;no, wait for next byte
- call MIDIIn ;yes, wait for MIDI data value byte
- incf DAT,W ;offset MIDI data value by 1
- movwf TEMP ;place data value into TEMP
- clrf SUBCOUNT ;init subtract counter
- D2 movlw 100 ;subtract 100 from original value
- subwf TEMP,F
- btfsc STATUS,C ;carry flag low?
- goto $+2 ;no
- goto $+3 ;yes
- incf SUBCOUNT,F ;increment digit 2 counter
- goto D2 ;continue until carry flag = 0
- movfw SUBCOUNT ;fetch 100's place digit from table
- call TABLE
- movwf DIGIT2 ;place 100's place digit segment data in DIGIT2
- movlw 100 ;add 100 back to the original value
- addwf TEMP,F
- D3 movlw 10 ;subtract 10 from the original value
- subwf TEMP,F
- btfsc STATUS,C ;carry flag low?
- goto $+2 ;no
- goto $+3 ;yes
- incf SUBCOUNT,F ;increment digit 3 counter
- goto D3 ;continue subtracting 10 until carry flag = 0
- movfw SUBCOUNT ;carry = 0, fetch 10's place digit from table
- call TABLE
- movwf DIGIT3 ;place 10's place digit segment data into DIGIT3
- movfw TEMP ;add 10 back to TEMP
- addlw 10
- call TABLE ;fetch 1's place digit segment data from table
- movwf DIGIT4 ;place 1's place digit segment data into DIGIT3
- goto MAIN ;go back and wait for next MIDI data value
Add Comment
Please, Sign In to add comment