Changeset 79b018f


Ignore:
Timestamp:
Mar 19, 2019, 4:30:42 PM (3 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
aa22c60
Parents:
8f936bf (diff), 81a05ca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
6 added
1 edited

Legend:

Unmodified
Added
Removed
  • tests/coroutine/devicedriver.cfa

    r8f936bf r79b018f  
    1010// Created On       : Sat Mar 16 15:30:34 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 18 08:29:20 2019
    13 // Update Count     : 79
     12// Last Modified On : Tue Mar 19 15:59:06 2019
     13// Update Count     : 87
    1414//
    1515
     
    2828} // next
    2929
     30void checkCRC( Driver & d, unsigned int sum ) with( d ) {
     31        suspend();
     32        unsigned short int crc = byte << 8;                                     // sign extension over written
     33        suspend();
     34        // prevent sign extension for signed char
     35        status = (crc | (unsigned char)byte) == sum ? MSG : ECRC;
     36} // checkCRC
     37
    3038void main( Driver & d ) with( d ) {
    3139        enum { STX = '\002', ESC = '\033', ETX = '\003', MaxMsg = 64 };
    32         unsigned short int crc;                                                         // error checking
    3340  msg: for () {                                                                                 // parse message
    3441                status = CONT;
     
    5259                } // for
    5360                msg[lnth] = '\0';                                                               // terminate string
    54                 suspend();
    55                 crc = (unsigned char)byte << 8; // prevent sign extension for signed char
    56                 suspend();
    57                 status = (crc | (unsigned char)byte) == sum ? MSG : ECRC;
     61                checkCRC( d, sum );                                                             // refactor CRC check
    5862                suspend();
    5963        } // for
Note: See TracChangeset for help on using the changeset viewer.