SlideShare a Scribd company logo
1 of 7
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
// Prototype of FOUR functions, each for a STATE.
// The func in State 1 performs addition of "unsigned numbers"
x0 and x1.
int s1_add_uintN(int x0, int x1, bool *c_flg);
// The func in State 2 performs addition of "signed numbers" x0
and x1.
int s2_add_intN(int x0, int x1, bool *v_flg);
// The func in State 3 performs subtraction of "unsigned
numbers" x0 and x1.
int s3_sub_uintN(int x0, int x1, bool *c_flg);
// The func in State 3 performs subtraction of "signed numbers"
x0 and x1.
int s4_sub_intN(int x0, int x1, bool *v_flg);
// We define the number of bits and the related limits of
unsigned and
// and signed numbers.
#define N 5 // number of bits
#define MIN_U 0 // minimum value of unsigned N-bit
number
#define MAX_U ((1 << N) - 1) // maximum value of unsigned
N-bit number
#define MIN_I (-(1 << (N-1)) ) // minimum value of signed N-
bit number
#define MAX_I ((1 << (N-1)) - 1) // maximum value of signed
N-bit number
// We use the following three pointers to access data, which can
be changed
// when the program pauses. We need to make sure to have the
RAM set up
// for these addresses.
int *pIn = (int *)0x20010000U; // the value of In should be -1,
0, or 1.
int *pX0 = (int *)0x20010004U; // X0 and X1 should be N-bit
integers.
int *pX1 = (int *)0x20010008U;
int main(void) {
enum progState{State1 = 1, State2, State3, State4};
enum progState cState = State1; // Current State
bool dataReady = false;
bool cFlg, vFlg;
int result;
while (1) {
dataReady = false;
// Check if the data are legitimate
while (!dataReady) {
printf("Halt program here to provide correct update of
datan");
printf("In should be -1, 0, and 1 and ");
printf("X0 and X1 should be N-bit SIGNED
integersn");
if (((-1 <= *pIn) && (*pIn <= 1)) &&
((MIN_I <= *pX0) && (*pX0 <= MAX_I)) &&
((MIN_I <= *pX1) && (*pX1 <= MAX_I))) {
dataReady = true;
}
}
printf("Your input: In = %d, X0 = %d, X1 = %d n", *pIn,
*pX0, *pX1);
switch (cState) {
case State1:
result = s1_add_uintN(*pX0, *pX1, &cFlg);
printf("State = %d, rslt = %d, Cflg = %dn", cState,
result, cFlg);
cState += *pIn;
if (cState < State1) cState += State4;
break;
case State2:
result = s2_add_intN(*pX0, *pX1, &vFlg);
printf("State = %d, rslt = %d, Vflg = %dn", cState,
result, vFlg);
cState += *pIn;
break;
case State3:
case State4:
default:
printf("Error with the program staten");
}
}
}
int s1_add_uintN(int x0, int x1, bool *c_flg) {
if (x0 < 0) x0 = x0 + MAX_U + 1;
if (x1 < 0) x1 = x1 + MAX_U + 1;
int temp = x0 + x1;
if (temp > MAX_U) {
temp = temp - (MAX_U + 1);
*c_flg = true;
} else {
*c_flg = false;
}
return temp;
}
int s2_add_intN(int x0, int x1, bool *v_flg) {
int temp = x0 + x1;
if (temp < MIN_I) {
temp = temp + MAX_U + 1;
*v_flg = true;
} else if (temp > MAX_I) {
temp = temp - (MAX_U + 1);
*v_flg = true;
} else {
*v_flg = false;
}
return temp;
}
int s3_sub_uintN(int x0, int x1, bool *c_flg) {
return 0;
}
int s4_sub_intN(int x0, int x1, bool *v_flg) {
return 0;
}

More Related Content

Similar to #include stdio.h#include stdint.h#include stdbool.h.docx

Program flowchart
Program flowchartProgram flowchart
Program flowchartSowri Rajan
 
C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptxDEEPAK948083
 
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docxLISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docxSHIVA101531
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxhappycocoman
 
#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docxajoy21
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 
how to reuse code
how to reuse codehow to reuse code
how to reuse codejleed1
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfezonesolutions
 
I have come code already but I cant quite get the output rig.pdf
I have come code already but I cant quite get the output rig.pdfI have come code already but I cant quite get the output rig.pdf
I have come code already but I cant quite get the output rig.pdfkashishkochhar5
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersSheila Sinclair
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docxajoy21
 

Similar to #include stdio.h#include stdint.h#include stdbool.h.docx (20)

week-17x
week-17xweek-17x
week-17x
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
C programm.pptx
C programm.pptxC programm.pptx
C programm.pptx
 
C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptx
 
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docxLISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Functions
FunctionsFunctions
Functions
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx
 
C important questions
C important questionsC important questions
C important questions
 
7 functions
7  functions7  functions
7 functions
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Pointer
PointerPointer
Pointer
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
how to reuse code
how to reuse codehow to reuse code
how to reuse code
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
 
I have come code already but I cant quite get the output rig.pdf
I have come code already but I cant quite get the output rig.pdfI have come code already but I cant quite get the output rig.pdf
I have come code already but I cant quite get the output rig.pdf
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx#include stdafx.h using namespace std; #include stdlib.h.docx
#include stdafx.h using namespace std; #include stdlib.h.docx
 

More from AASTHA76

(APA 6th Edition Formatting and St.docx
(APA 6th Edition Formatting and St.docx(APA 6th Edition Formatting and St.docx
(APA 6th Edition Formatting and St.docxAASTHA76
 
(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx
(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx
(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docxAASTHA76
 
(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx
(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx
(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docxAASTHA76
 
(Assmt 1; Week 3 paper) Using ecree Doing the paper and s.docx
(Assmt 1; Week 3 paper)  Using ecree        Doing the paper and s.docx(Assmt 1; Week 3 paper)  Using ecree        Doing the paper and s.docx
(Assmt 1; Week 3 paper) Using ecree Doing the paper and s.docxAASTHA76
 
(Image retrieved at httpswww.google.comsearchhl=en&biw=122.docx
(Image retrieved at  httpswww.google.comsearchhl=en&biw=122.docx(Image retrieved at  httpswww.google.comsearchhl=en&biw=122.docx
(Image retrieved at httpswww.google.comsearchhl=en&biw=122.docxAASTHA76
 
(Dis) Placing Culture and Cultural Space Chapter 4.docx
(Dis) Placing Culture and Cultural Space Chapter 4.docx(Dis) Placing Culture and Cultural Space Chapter 4.docx
(Dis) Placing Culture and Cultural Space Chapter 4.docxAASTHA76
 
(1) Define the time value of money.  Do you believe that the ave.docx
(1) Define the time value of money.  Do you believe that the ave.docx(1) Define the time value of money.  Do you believe that the ave.docx
(1) Define the time value of money.  Do you believe that the ave.docxAASTHA76
 
(chapter taken from Learning Power)From Social Class and t.docx
(chapter taken from Learning Power)From Social Class and t.docx(chapter taken from Learning Power)From Social Class and t.docx
(chapter taken from Learning Power)From Social Class and t.docxAASTHA76
 
(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx
(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx
(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docxAASTHA76
 
(a) The current ratio of a company is 61 and its acid-test ratio .docx
(a) The current ratio of a company is 61 and its acid-test ratio .docx(a) The current ratio of a company is 61 and its acid-test ratio .docx
(a) The current ratio of a company is 61 and its acid-test ratio .docxAASTHA76
 
(1) How does quantum cryptography eliminate the problem of eaves.docx
(1) How does quantum cryptography eliminate the problem of eaves.docx(1) How does quantum cryptography eliminate the problem of eaves.docx
(1) How does quantum cryptography eliminate the problem of eaves.docxAASTHA76
 
#transformation10EventTrendsfor 201910 Event.docx
#transformation10EventTrendsfor 201910 Event.docx#transformation10EventTrendsfor 201910 Event.docx
#transformation10EventTrendsfor 201910 Event.docxAASTHA76
 
$10 now and $10 when complete Use resources from the required .docx
$10 now and $10 when complete Use resources from the required .docx$10 now and $10 when complete Use resources from the required .docx
$10 now and $10 when complete Use resources from the required .docxAASTHA76
 
#MicroXplorer Configuration settings - do not modifyFile.Versio.docx
#MicroXplorer Configuration settings - do not modifyFile.Versio.docx#MicroXplorer Configuration settings - do not modifyFile.Versio.docx
#MicroXplorer Configuration settings - do not modifyFile.Versio.docxAASTHA76
 
#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docx#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docxAASTHA76
 
$ stated in thousands)Net Assets, Controlling Interest.docx
$ stated in thousands)Net Assets, Controlling Interest.docx$ stated in thousands)Net Assets, Controlling Interest.docx
$ stated in thousands)Net Assets, Controlling Interest.docxAASTHA76
 
#include stdio.h#include stdlib.h#include pthread.h#in.docx
#include stdio.h#include stdlib.h#include pthread.h#in.docx#include stdio.h#include stdlib.h#include pthread.h#in.docx
#include stdio.h#include stdlib.h#include pthread.h#in.docxAASTHA76
 
#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docxAASTHA76
 
#Assessment BriefDiploma of Business Eco.docx
#Assessment BriefDiploma of Business Eco.docx#Assessment BriefDiploma of Business Eco.docx
#Assessment BriefDiploma of Business Eco.docxAASTHA76
 
#1) Identify 2020 National Health Goals related to home care d.docx
#1) Identify 2020 National Health Goals related to home care d.docx#1) Identify 2020 National Health Goals related to home care d.docx
#1) Identify 2020 National Health Goals related to home care d.docxAASTHA76
 

More from AASTHA76 (20)

(APA 6th Edition Formatting and St.docx
(APA 6th Edition Formatting and St.docx(APA 6th Edition Formatting and St.docx
(APA 6th Edition Formatting and St.docx
 
(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx
(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx
(a) Thrasymachus’ (the sophist’s) definition of Justice or Right o.docx
 
(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx
(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx
(Glossary of Telemedicine and eHealth)· Teleconsultation Cons.docx
 
(Assmt 1; Week 3 paper) Using ecree Doing the paper and s.docx
(Assmt 1; Week 3 paper)  Using ecree        Doing the paper and s.docx(Assmt 1; Week 3 paper)  Using ecree        Doing the paper and s.docx
(Assmt 1; Week 3 paper) Using ecree Doing the paper and s.docx
 
(Image retrieved at httpswww.google.comsearchhl=en&biw=122.docx
(Image retrieved at  httpswww.google.comsearchhl=en&biw=122.docx(Image retrieved at  httpswww.google.comsearchhl=en&biw=122.docx
(Image retrieved at httpswww.google.comsearchhl=en&biw=122.docx
 
(Dis) Placing Culture and Cultural Space Chapter 4.docx
(Dis) Placing Culture and Cultural Space Chapter 4.docx(Dis) Placing Culture and Cultural Space Chapter 4.docx
(Dis) Placing Culture and Cultural Space Chapter 4.docx
 
(1) Define the time value of money.  Do you believe that the ave.docx
(1) Define the time value of money.  Do you believe that the ave.docx(1) Define the time value of money.  Do you believe that the ave.docx
(1) Define the time value of money.  Do you believe that the ave.docx
 
(chapter taken from Learning Power)From Social Class and t.docx
(chapter taken from Learning Power)From Social Class and t.docx(chapter taken from Learning Power)From Social Class and t.docx
(chapter taken from Learning Power)From Social Class and t.docx
 
(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx
(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx
(Accessible at httpswww.hatchforgood.orgexplore102nonpro.docx
 
(a) The current ratio of a company is 61 and its acid-test ratio .docx
(a) The current ratio of a company is 61 and its acid-test ratio .docx(a) The current ratio of a company is 61 and its acid-test ratio .docx
(a) The current ratio of a company is 61 and its acid-test ratio .docx
 
(1) How does quantum cryptography eliminate the problem of eaves.docx
(1) How does quantum cryptography eliminate the problem of eaves.docx(1) How does quantum cryptography eliminate the problem of eaves.docx
(1) How does quantum cryptography eliminate the problem of eaves.docx
 
#transformation10EventTrendsfor 201910 Event.docx
#transformation10EventTrendsfor 201910 Event.docx#transformation10EventTrendsfor 201910 Event.docx
#transformation10EventTrendsfor 201910 Event.docx
 
$10 now and $10 when complete Use resources from the required .docx
$10 now and $10 when complete Use resources from the required .docx$10 now and $10 when complete Use resources from the required .docx
$10 now and $10 when complete Use resources from the required .docx
 
#MicroXplorer Configuration settings - do not modifyFile.Versio.docx
#MicroXplorer Configuration settings - do not modifyFile.Versio.docx#MicroXplorer Configuration settings - do not modifyFile.Versio.docx
#MicroXplorer Configuration settings - do not modifyFile.Versio.docx
 
#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docx#include string.h#include stdlib.h#include systypes.h.docx
#include string.h#include stdlib.h#include systypes.h.docx
 
$ stated in thousands)Net Assets, Controlling Interest.docx
$ stated in thousands)Net Assets, Controlling Interest.docx$ stated in thousands)Net Assets, Controlling Interest.docx
$ stated in thousands)Net Assets, Controlling Interest.docx
 
#include stdio.h#include stdlib.h#include pthread.h#in.docx
#include stdio.h#include stdlib.h#include pthread.h#in.docx#include stdio.h#include stdlib.h#include pthread.h#in.docx
#include stdio.h#include stdlib.h#include pthread.h#in.docx
 
#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx
 
#Assessment BriefDiploma of Business Eco.docx
#Assessment BriefDiploma of Business Eco.docx#Assessment BriefDiploma of Business Eco.docx
#Assessment BriefDiploma of Business Eco.docx
 
#1) Identify 2020 National Health Goals related to home care d.docx
#1) Identify 2020 National Health Goals related to home care d.docx#1) Identify 2020 National Health Goals related to home care d.docx
#1) Identify 2020 National Health Goals related to home care d.docx
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

#include stdio.h#include stdint.h#include stdbool.h.docx

  • 1. #include <stdio.h> #include <stdint.h> #include <stdbool.h> // Prototype of FOUR functions, each for a STATE. // The func in State 1 performs addition of "unsigned numbers" x0 and x1. int s1_add_uintN(int x0, int x1, bool *c_flg); // The func in State 2 performs addition of "signed numbers" x0 and x1. int s2_add_intN(int x0, int x1, bool *v_flg); // The func in State 3 performs subtraction of "unsigned numbers" x0 and x1. int s3_sub_uintN(int x0, int x1, bool *c_flg); // The func in State 3 performs subtraction of "signed numbers" x0 and x1. int s4_sub_intN(int x0, int x1, bool *v_flg); // We define the number of bits and the related limits of unsigned and
  • 2. // and signed numbers. #define N 5 // number of bits #define MIN_U 0 // minimum value of unsigned N-bit number #define MAX_U ((1 << N) - 1) // maximum value of unsigned N-bit number #define MIN_I (-(1 << (N-1)) ) // minimum value of signed N- bit number #define MAX_I ((1 << (N-1)) - 1) // maximum value of signed N-bit number // We use the following three pointers to access data, which can be changed // when the program pauses. We need to make sure to have the RAM set up // for these addresses. int *pIn = (int *)0x20010000U; // the value of In should be -1, 0, or 1. int *pX0 = (int *)0x20010004U; // X0 and X1 should be N-bit integers. int *pX1 = (int *)0x20010008U;
  • 3. int main(void) { enum progState{State1 = 1, State2, State3, State4}; enum progState cState = State1; // Current State bool dataReady = false; bool cFlg, vFlg; int result; while (1) { dataReady = false; // Check if the data are legitimate while (!dataReady) { printf("Halt program here to provide correct update of datan"); printf("In should be -1, 0, and 1 and "); printf("X0 and X1 should be N-bit SIGNED integersn"); if (((-1 <= *pIn) && (*pIn <= 1)) && ((MIN_I <= *pX0) && (*pX0 <= MAX_I)) && ((MIN_I <= *pX1) && (*pX1 <= MAX_I))) {
  • 4. dataReady = true; } } printf("Your input: In = %d, X0 = %d, X1 = %d n", *pIn, *pX0, *pX1); switch (cState) { case State1: result = s1_add_uintN(*pX0, *pX1, &cFlg); printf("State = %d, rslt = %d, Cflg = %dn", cState, result, cFlg); cState += *pIn; if (cState < State1) cState += State4; break; case State2: result = s2_add_intN(*pX0, *pX1, &vFlg); printf("State = %d, rslt = %d, Vflg = %dn", cState, result, vFlg); cState += *pIn;
  • 5. break; case State3: case State4: default: printf("Error with the program staten"); } } } int s1_add_uintN(int x0, int x1, bool *c_flg) { if (x0 < 0) x0 = x0 + MAX_U + 1; if (x1 < 0) x1 = x1 + MAX_U + 1; int temp = x0 + x1; if (temp > MAX_U) { temp = temp - (MAX_U + 1); *c_flg = true;
  • 6. } else { *c_flg = false; } return temp; } int s2_add_intN(int x0, int x1, bool *v_flg) { int temp = x0 + x1; if (temp < MIN_I) { temp = temp + MAX_U + 1; *v_flg = true; } else if (temp > MAX_I) { temp = temp - (MAX_U + 1); *v_flg = true; } else { *v_flg = false; } return temp;
  • 7. } int s3_sub_uintN(int x0, int x1, bool *c_flg) { return 0; } int s4_sub_intN(int x0, int x1, bool *v_flg) { return 0; }