📄 cfunc.mod
字号:
break; case 1: *base = *base & 0xfff3; bit_value = bit_value << 2; break; case 2: *base = *base & 0xffcf; bit_value = bit_value << 4; break; case 3: *base = *base & 0xff3f; bit_value = bit_value << 6; break; case 4: *base = *base & 0xfcff; bit_value = bit_value << 8; break; case 5: *base = *base & 0xf3ff; bit_value = bit_value << 10; break; case 6: *base = *base & 0xcfff; bit_value = bit_value << 12; break; case 7: *base = *base & 0x3fff; bit_value = bit_value << 14; break; } *base = *base | bit_value;}/*==============================================================================FUNCTION cm_store_inputs_value()AUTHORS 23 Jul 1991 Jeffrey P. MurrayMODIFICATIONS 30 Sep 1991 Jeffrey P. MurraySUMMARY The following routine retrieves four-bit data from short integer array "bits". The integers are assumed to be at least two bytes each, so each will hold four four- bit values. INTERFACES FILE ROUTINE CALLED N/A N/ARETURNED VALUE NONEGLOBAL VARIABLES NONENON-STANDARD FEATURES NONE==============================================================================*/ /*=== Static CM_STORE_INPUTS_VALUE ROUTINE ===*//************************************************* The following routine retrieves four-bit ** data from short integer array "bits". The ** integers are assumed to be at least two ** bytes each, so each will hold four four- ** bit values. ** ** Created 7/23/91 J.P.Murray *************************************************/static void cm_store_inputs_value(State_Table_t *states,int index, int bit_number, int in_val){ int err, /* error index value */ int1, /* temp storage variable */ bit_index, /* bits base address at which word bits will be found */ bit_offset; /* offset from ram base address at which bit[0] of the required word can be found */ short base; /* variable to hold current base integer for comparison purposes. */ double double1, double2; /* holding variables for modf routine */ /* obtain offset value from word_number, word_width & bit_number */ int1 = index * states->num_inputs + bit_number; double1 = int1 / 8.0; modf(double1, &double2); bit_index = double2; bit_offset = int1 - (double2 * 8.0); /* retrieve entire base_address bits integer... */ base = states->inputs[bit_index]; /* for each offset, mask off the bits and store values */ cm_inputs_mask_and_store(&base,bit_offset,in_val); /* store modified base value */ states->inputs[bit_index] = base; }/*==============================================================================FUNCTION cm_bits_mask_and_store()AUTHORS 22 Jul 1991 Jeffrey P. MurrayMODIFICATIONS 30 Sep 1991 Jeffrey P. MurraySUMMARY The following routine masks and stores the value passed to it by the out value by masking the appropriate bits in the base integer. The particular bit affected is determined by the bit_offset value. This routine stores to the bits[] array. INTERFACES FILE ROUTINE CALLED N/A N/ARETURNED VALUE Returns a status integer.GLOBAL VARIABLES NONENON-STANDARD FEATURES NONE==============================================================================*//*=== Static CM_BITS_MASK_AND_STORE ROUTINE ===*//************************************************* The following routine masks and stores ** the value passed to it by the out value ** by masking the appropriate bits in the ** base integer. The particular bit affected ** is determined by the bit_offset value. ** This routine stores to the bits[] array. ** ** Created 7/22/91 ** Last Modified 7/22/91 J.P.Murray *************************************************/static int cm_bits_mask_and_store(short *base,int bit_offset,int bit_value){ switch (bit_offset) { case 0: *base = *base & 0xfff0; break; case 1: *base = *base & 0xff0f; bit_value = bit_value << 4; break; case 2: *base = *base & 0xf0ff; bit_value = bit_value << 8; break; case 3: *base = *base & 0x0fff; bit_value = bit_value << 12; break; } *base = *base | bit_value;}/*==============================================================================FUNCTION cm_bits_mask_and_retrieve()AUTHORS 22 Jul 1991 Jeffrey P. MurrayMODIFICATIONS 30 Sep 1991 Jeffrey P. MurraySUMMARY The following routine masks and retrieves the value passed to it by the out value by masking the appropriate bits in the base integer. The particular bit affected is determined by the bit_offset value. INTERFACES FILE ROUTINE CALLED N/A N/ARETURNED VALUE NONEGLOBAL VARIABLES NONENON-STANDARD FEATURES NONE==============================================================================*//*=== Static CM_BITS_MASK_AND_RETRIEVE ROUTINE ===*//*************************************************** The following routine masks and retrieves ** the value passed to it by the out value ** by masking the appropriate bits in the ** base integer. The particular bit affected ** is determined by the ram_offset value. ** ** Created 7/22/91 ** Last Modified 7/22/91 J.P.Murray ***************************************************/static void cm_bits_mask_and_retrieve(short base,int bit_offset,Digital_t *out){ short value; /* the hexadecimal value of the masked bit */ switch (bit_offset) { case 0: break; case 1: base = base >> 4; break; case 2: base = base >> 8; break; case 3: base = base >> 12; break; } value = 0x000f & base; switch (value) { case 0: out->state = ZERO; out->strength = STRONG; break; case 1: out->state = ONE; out->strength = STRONG; break; case 2: out->state = UNKNOWN; out->strength = STRONG; break; case 3: out->state = ZERO; out->strength = RESISTIVE; break; case 4: out->state = ONE; out->strength = RESISTIVE; break; case 5: out->state = UNKNOWN; out->strength = RESISTIVE; break; case 6: out->state = ZERO; out->strength = HI_IMPEDANCE; break; case 7: out->state = ONE; out->strength = HI_IMPEDANCE; break; case 8: out->state = UNKNOWN; out->strength = HI_IMPEDANCE; break; case 9: out->state = ZERO; out->strength = UNDETERMINED; break; case 10: out->state = ONE; out->strength = UNDETERMINED; break; case 11: out->state = UNKNOWN; out->strength = UNDETERMINED; break; }}/*==============================================================================FUNCTION cm_get_bits_value()AUTHORS 22 Jul 1991 Jeffrey P. MurrayMODIFICATIONS 23 Jul 1991 Jeffrey P. Murray 30 Sep 1991 Jeffrey P. MurraySUMMARY The following routine retrieves four-bit data from short integer array "bits". The integers are assumed to be at least two bytes each, so each will hold four four- bit values. INTERFACES FILE ROUTINE CALLED N/A N/ARETURNED VALUE NONEGLOBAL VARIABLES NONENON-STANDARD FEATURES NONE==============================================================================*//*=== Static CM_GET_BITS_VALUE ROUTINE ===*//************************************************* The following routine retrieves four-bit ** data from short integer array "bits". The ** integers are assumed to be at least two ** bytes each, so each will hold four four- ** bit values. ** ** Created 7/22/91 ** Last Modified 7/23/91 J.P.Murray *************************************************/static void cm_get_bits_value(State_Table_t *states,int index, int bit_number, Digital_t *out){ int err, /* error index value */ int1, /* temp storage variable */ bit_index, /* bits base address at which word bits will be found */ bit_offset; /* offset from ram base address at which bit[0] of the required word can be found */ short base; /* variable to hold current base integer for comparison purposes. */ double double1, double2; /* holding variables for modf routine */ /* obtain offset value from index, word_width & bit_number */ int1 = index * states->num_outputs + bit_number; double1 = int1 / 4.0; modf(double1, &double2); bit_index = double2; bit_offset = int1 - (double2 * 4.0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -