This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void examine_bits(int16_t x) { | |
| if (x & 0x1) | |
| printf("%d is odd.\n", x); | |
| else | |
| printf("%d is even.\n", x); | |
| if (!x) | |
| printf("%d is zero.\n", x); | |
| else if (x & 0x8000) | |
| printf("%d is negative.\n", x); | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void iterate_over_alphabet(void) { | |
| printf("Iterating over the lower-case letters...\n"); | |
| for (char c = 'a'; c <= 'z'; c++) | |
| printf("%c ", c); | |
| printf("\n"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <unistd.h> | |
| #define MS_PER_uS 1000 | |
| void nonterminating_loop(void) { | |
| float x; | |
| int duration = 100 * MS_PER_uS; | |
| for (x = 0.0; x != 10.0; x += 0.1) { | |
| printf("x = %f\n", x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <unistd.h> | |
| #define MS_PER_uS 1000 | |
| void terminating_loop(void) { | |
| _Decimal32 x; | |
| int duration = 100 * MS_PER_uS; | |
| for (x = 0.0df; x != 10.0df; x += 0.1df) { | |
| printf("x = %Ha\n", x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long mov_demo1(long i) { | |
| return i; | |
| } | |
| int mov_demo2() { | |
| int i = 3; | |
| return i; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long load_demo(long *i) { | |
| return *i; | |
| } | |
| long *store_demo() { | |
| long *i; // uninitialized pointer; will probably result in a segmentation fault | |
| *i = 3; | |
| return i; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long *scalar_demo(long *i) { | |
| long *j; | |
| *j = *i; | |
| return j; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct foo { | |
| long i; | |
| long j; | |
| }; | |
| long struct_demo(struct foo *bar) { | |
| return bar->j; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long array_demo1(long *i, long j) { | |
| return i[j]; | |
| } | |
| long array_demo2(long *i) { | |
| return i[3]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long add_demo(long *i, long j) { | |
| return *i + j; | |
| } | |
| long sub_demo(long *i, long j) { | |
| return *i - j; | |
| } | |
| long mul_demo(long *i, long j) { | |
| return *i * j; |
OlderNewer