This file contains 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(ExternalProject) | |
find_package(Git REQUIRED) | |
ExternalProject_Add( | |
doctest | |
PREFIX ${CMAKE_BINARY_DIR}/doctest | |
GIT_REPOSITORY https://github.com/doctest/doctest.git | |
TIMEOUT 10 | |
UPDATE_COMMAND ${GIT_EXECUTABLE} pull | |
CONFIGURE_COMMAND "" |
This file contains 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 <assert.h> | |
#include <stdio.h> | |
#include <limits.h> | |
#include <stdint.h> | |
void test_unsigned_add_8(uint8_t a, uint8_t b){ | |
uint8_t c; | |
c = a + b; | |
assert(c == 0); // (A1) | |
} |
This file contains 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
int main(void) | |
{ | |
*rcc_ahb1enr |= (1 << 3); // enable PortD's clock | |
// assume powerup conditions, moder is all 0's | |
// set bit-8 as output | |
uint32_t moder = portd->MODER; | |
moder |= (1 << 16); | |
moder &= ~(1 << 17); | |
portd->MODER = moder; |
This file contains 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
volatile GPIO_t* const portd = (GPIO_t*)0x40020C00; |
This file contains 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 <stdint.h> | |
typedef struct | |
{ | |
uint32_t MODER; // mode register, offset: 0x00 | |
uint32_t OTYPER; // output type register, offset: 0x04 | |
uint32_t OSPEEDR; // output speed register, offset: 0x08 | |
uint32_t PUPDR; // pull-up/pull-down register, offset: 0x0C | |
uint32_t IDR; // input data register, offset: 0x10 | |
uint32_t ODR; // output data register, offset: 0x14 |
This file contains 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 <stdint.h> | |
#include "timer.h" | |
volatile uint32_t* const portd_moder = (uint32_t*) 0x40020C00; | |
volatile uint32_t* const portd_odr = (uint32_t*) 0x40020C14; | |
volatile uint32_t* const rcc_ahb1enr = (uint32_t*) 0x40023830; | |
extern void sleep(uint32_t ms); // use systick to busy-wait |
This file contains 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
// $ ./bufferOverflow -2147482047 | |
#include <stdio.h> | |
#include <assert.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define MAX_BUF_SZ 1024 | |
int copySize; | |
int s[MAX_BUF_SZ*2]; // source buffer |
This file contains 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> | |
int main(void) | |
{ | |
unsigned int ui = 16; | |
printf("%u * 16 = %u\n", ui, ui*16); | |
printf("%u << 4 = %u\n", ui, ui << 4); | |
return 0; | |
} |
This file contains 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 <limits.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
assert(sizeof(int)==4); | |
int intMin = INT_MIN; |
This file contains 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 <limits.h> | |
#include <assert.h> | |
int main(void) | |
{ | |
assert(sizeof(unsigned char)==1); | |
unsigned char uc1 = 0xff; | |
unsigned char uc2 = 0; |
NewerOlder