Guest User

Untitled

a guest
Jan 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 2.89 KB | None | 0 0
  1. MAIN            call                MIDIIn                  ;wait for MIDI status byte
  2.  
  3.                 movlw               0xC0                    ;is it a program change message on MIDI
  4.                 xorwf               DAT,W                   ;channel 1?
  5.                 btfss               STATUS,Z                
  6.                 goto                MAIN                    ;no, wait for next byte
  7.  
  8.                 call                MIDIIn                  ;yes, wait for MIDI data value byte
  9.  
  10.                 incf                DAT,W                   ;offset MIDI data value by 1
  11.                 movwf               TEMP                    ;place data value into TEMP
  12.  
  13.                 clrf                SUBCOUNT                ;init subtract counter
  14.                
  15. D2              movlw               100                     ;subtract 100 from original value
  16.                 subwf               TEMP,F
  17.                 btfsc               STATUS,C                ;carry flag low?
  18.                 goto                $+2                     ;no
  19.                 goto                $+3                     ;yes
  20.                 incf                SUBCOUNT,F             ;increment digit 2 counter
  21.                 goto                D2                      ;continue until carry flag = 0
  22.                 movfw               SUBCOUNT               ;fetch 100's place digit from table
  23.                 call                TABLE
  24.                 movwf               DIGIT2                  ;place 100's place digit segment data in DIGIT2
  25.                 movlw               100                     ;add 100 back to the original value
  26.                 addwf               TEMP,F
  27.  
  28. D3              movlw               10                      ;subtract 10 from the original value
  29.                 subwf               TEMP,F
  30.                 btfsc               STATUS,C                ;carry flag low?
  31.                 goto                $+2                     ;no
  32.                 goto                $+3                     ;yes
  33.                 incf                SUBCOUNT,F             ;increment digit 3 counter
  34.                 goto                D3                      ;continue subtracting 10 until carry flag = 0
  35.                 movfw               SUBCOUNT               ;carry = 0, fetch 10's place digit from table
  36.                 call                TABLE
  37.                 movwf               DIGIT3                  ;place 10's place digit segment data into DIGIT3
  38.                 movfw               TEMP                    ;add 10 back to TEMP
  39.                 addlw               10
  40.                 call                TABLE                   ;fetch 1's place digit segment data from table
  41.                 movwf               DIGIT4                  ;place 1's place digit segment data into DIGIT3
  42.  
  43.                 goto                MAIN                    ;go back and wait for next MIDI data value
Add Comment
Please, Sign In to add comment