include all files
This commit is contained in:
38
Makefile
Normal file
38
Makefile
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
SHELL = /bin/sh
|
||||||
|
.SUFFIXES:
|
||||||
|
|
||||||
|
CC = avr-gcc
|
||||||
|
RM = rm -vf
|
||||||
|
STRIP = avr-strip
|
||||||
|
|
||||||
|
CPPFLAGS ?= -DNDEBUG
|
||||||
|
CFLAGS ?= -Os
|
||||||
|
LDFLAGS ?= -nostdlib -nostartfiles -flto
|
||||||
|
|
||||||
|
CPPFLAGS += -Iinclude
|
||||||
|
CFLAGS += -std=gnu99 -MMD -MP
|
||||||
|
CFLAGS += -Wall -Wextra -Wpedantic -Wno-pointer-arith
|
||||||
|
|
||||||
|
SRC := $(wildcard src/*.c src/*/*.c src/*/*/*.c src/*/*/*/*.c src/*/*/*/*/*.c src/*/*/*/*/*/*.c src/*/*/*/*/*/*/*.c src/*/*/*/*/*/*/*/*.c)
|
||||||
|
SRC += $(wildcard src/*.S src/*/*.S src/*/*/*.S src/*/*/*/*.S src/*/*/*/*/*.S src/*/*/*/*/*/*.S src/*/*/*/*/*/*/*.S src/*/*/*/*/*/*/*/*.S)
|
||||||
|
OBJ := $(SRC:%=obj/%.o)
|
||||||
|
|
||||||
|
|
||||||
|
all: bin/a.out
|
||||||
|
clean:; @-$(RM) -r bin/ obj/
|
||||||
|
|
||||||
|
bin/a.out: $(OBJ)
|
||||||
|
$(info [LD] $@)
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||||
|
|
||||||
|
bin/a.hex: bin/a.out
|
||||||
|
$(info [STRIP] $@)
|
||||||
|
@$(STRIP) -o $@ $<
|
||||||
|
|
||||||
|
obj/%.o: %
|
||||||
|
$(info [CC] $@)
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
-include $(OBJ:%.o=%.d)
|
||||||
8
include/asm.h
Normal file
8
include/asm.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/* Contains some assembly-specific instructions
|
||||||
|
* that ought to be beneficial*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define lo8(x) ((x) & 0xFF) /* Use bits 0..7 of x. */
|
||||||
|
#define hi8(x) (((x) >> 8) & 0xFF) /* Use bits 8..15 of x. */
|
||||||
|
#define hlo8(x) (((x) >> 16) & 0xFF) /* Use bits 16..23 of x. */
|
||||||
|
#define hhi8(x) (((x) >> 24) & 0xFF) /* Use bits 24..31 of x. */
|
||||||
0
include/avr.h
Normal file
0
include/avr.h
Normal file
8
include/avr/avr128da28.h
Normal file
8
include/avr/avr128da28.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "asm.h"
|
||||||
|
|
||||||
|
/* I/O addresses. */
|
||||||
|
#define SPH 0x3E /* Stack pointer high address. */
|
||||||
|
#define SPL 0x3D /* Stack pointer low address. */
|
||||||
|
#define RAMEND 0x4000 /* The maximum address available in RAM. */
|
||||||
17
src/crt0.S
Normal file
17
src/crt0.S
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "avr128da28.h"
|
||||||
|
|
||||||
|
/* This section contains the executable code. */
|
||||||
|
.section .text
|
||||||
|
/* Entry-point as defined by the linker at address 0x00. */
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
ldi r16, hi8(RAMEND)
|
||||||
|
out SPH, r16
|
||||||
|
ldi r16, lo8(RAMEND)
|
||||||
|
out SPL, r16
|
||||||
|
|
||||||
|
rcall main
|
||||||
|
|
||||||
|
.section .data /* Initialised data */
|
||||||
|
.section .bss /* Uninitialised data*/
|
||||||
|
.section .rodata /* Initialised read-only data */
|
||||||
7
src/main.c
Normal file
7
src/main.c
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
int main(void) __attribute__((noreturn));
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
47
src/types.h
Normal file
47
src/types.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
typedef long long llong;
|
||||||
|
|
||||||
|
typedef unsigned char uchar;
|
||||||
|
typedef unsigned short ushort;
|
||||||
|
typedef unsigned int uint;
|
||||||
|
typedef unsigned long ulong;
|
||||||
|
typedef unsigned long long ullong;
|
||||||
|
|
||||||
|
typedef __INT8_TYPE__ i8;
|
||||||
|
typedef __INT16_TYPE__ i16;
|
||||||
|
typedef __INT32_TYPE__ i32;
|
||||||
|
typedef __INT64_TYPE__ i64;
|
||||||
|
typedef __UINT8_TYPE__ u8;
|
||||||
|
typedef __UINT16_TYPE__ u16;
|
||||||
|
typedef __UINT32_TYPE__ u32;
|
||||||
|
typedef __UINT64_TYPE__ u64;
|
||||||
|
|
||||||
|
typedef __INTPTR_TYPE__ intptr;
|
||||||
|
typedef __UINTPTR_TYPE__ uintptr;
|
||||||
|
|
||||||
|
#if __SIZEOF_SIZE_T__ == 8
|
||||||
|
typedef i64 ssize;
|
||||||
|
typedef u64 usize;
|
||||||
|
#elif __SIZEOF_SIZE_T__ == 4
|
||||||
|
typedef i32 ssize;
|
||||||
|
typedef u32 usize;
|
||||||
|
#elif __SIZEOF_SIZE_T__ == 2
|
||||||
|
typedef i16 ssize;
|
||||||
|
typedef u16 usize;
|
||||||
|
#elif __SIZEOF_SIZE_T__ == 1
|
||||||
|
typedef i8 ssize;
|
||||||
|
typedef u8 usize;
|
||||||
|
#else
|
||||||
|
#error could not determine the appropriate type for usize and ssize
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __SIZEOF_FLOAT__ == 4
|
||||||
|
typedef float f32;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __SIZEOF_DOUBLE__ == 8
|
||||||
|
typedef double f64;
|
||||||
|
#elif __SIZEOF_LONG_DOUBLE__ == 8
|
||||||
|
typedef long double f64;
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user