Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !bool MessageStream_isComplete(MessageStream* stream)
- !{
- ! Message* message = &(stream->message);
- 0x1C4: MOVF state, W //state = 0x1
- 0x1C5: CLRF dst // dst = 0x0
- 0x1C6: ADDWF dst, F // dst = 0x1
- 0x1C7: MOVF p1, W // W = 0x34
- 0x1C8: CLRF p // p = 0x0
- 0x1C9: ADDWF p, F // p = 0x34
- ! unsigned short message_size = sizeof(MessageHeader);
- 0x1CA: MOVLW 0x8 // W = 0x08
- 0x1CB: MOVWF message // message = 0x08
- 0x1CC: MOVLW 0x0 // W = 0x0
- 0x1CD: MOVWF message // message = 0x0 ?
- ! if(stream->position < message_size) {
- 0x1CE: MOVF p1, W // W = 0x34
- 0x1CF: MOVWF FSR1 // FSR1 = 0x34
- 0x1D0: MOVF state, W // W = 0x01
- 0x1D1: MOVWF FSR1H // FSR1H = 0x01 (FSR = 0x134)
- 0x1D2: ADDFSR 1, 18 // FSR = 0x14C
- 0x1D3: MOVIW [0]FSR1 // W = 0x08
- 0x1D4: MOVWF c // c = 0x08
- 0x1D5: MOVIW [1]FSR1 // W = 0x00
- 0x1D6: MOVWF state // state = 0x0
- 0x1D7: MOVF message, W // W = 0x0
- 0x1D8: SUBWF state, W // W = 0x0 (Z=1, DC=1, C=1)
- 0x1D9: BTFSS STATUS, 0x2 // Z=1, therefore skip
- 0x1DA: GOTO 0x1DD
- 0x1DB: MOVF message, W // W = 0x08
- 0x1DC: SUBWF c, W // W = 0x00 (Z=1, DC=1, C=1)
- 0x1DD: BTFSC STATUS, 0x0 // C=1, therefore do not skip
- 0x1DE: GOTO 0x1E1
- ! return 0;
- 0x1DF: MOVLW 0x0
- 0x1E0: RETURN
- ! }
- ! // The header is complete - check whether any data is expected.
- ! unsigned short message_type = message->header.message_type;
- 0x1E1: MOVF p, W // W = 0x34
- 0x1E2: ADDLW 0x5 // W = 0x39
- 0x1E3: MOVWF FSR1 // FSR1 = 0x39
- 0x1E4: CLRF FSR1H // FSR1H = 0x00 <--- BUG, this should be 0x01, giving an FSR value of 0x139, which is the address of "message->header.message_type"
- 0x1E5: MOVIW [0]FSR1 // W = 0xFF (Taken from RANDOM memory location)
- 0x1E6: MOVWF n // n = 0xFF
- 0x1E7: MOVIW [1]FSR1 // W = 0x00
- 0x1E8: MOVWF counter // counter = 0x00
- ! if(message_type & 0b1) {
- 0x1E9: BTFSS n, 0x0 // n = 0xFF, so skip next line, and incorrectly enter the if(){} body
Advertisement
Add Comment
Please, Sign In to add comment