Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emulateme for PIC baseline #176

Merged
merged 1 commit into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pic/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

emulateme.%.elf: emulateme.tinymem.c
xc8-cc -O0 -mcpu=$(notdir $*) -o $@ $<
rm *.o *.sdb *.sym *.lst *.rlf *.s *.d *.p1 *.cmf *.hxl
Binary file added pic/emulateme.pic16f505.elf
Binary file not shown.
25 changes: 25 additions & 0 deletions pic/emulateme.pic16f505.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
:1000000064002500A304040AA405A3044809A3046A
:100010003000A3044909A3043100A3044A09A3043E
:100020003200A3044B09A3043300A3044C09A30426
:100030003400A3044D09A3043500A3044E09A3040E
:100040003600A3044F09A3043700A3045009A304F6
:100050003800A3045109A3043900A3045209A304DE
:100060003A00A3045309A3043B00A3045409A304C6
:100070003C00A3045509A3043D00A3045609A304AE
:100080003E00A3045709A3043F006400A3043D0BF2
:10009000510853084D0877085808140851085F089C
:1000A00045086C0817087F086E0878087F081C0848
:0400B000A304000B9A
:1001D00068000402A4027F0EE201000858084108EA
:1001E0006E08790843086F086C086F087508720874
:1001F00059086F0875084C0869086B0865080008FD
:10020000A404C404710073001302D0012400A304E9
:10021000E909A3042F00300CA404C404D301240072
:100220000F02A001300CA404C404D3012400000276
:10023000A404C404B101010CF301100C93000307E2
:10024000220B230B040B580C91014306280B290B9E
:100250002A0B3C0B720011022F00300CD20124003B
:100260000F02A001010CA404C404F201100C9200BE
:1002700003073B0B3C0B2B0B0008020CA404C4042B
:10028000380018023000A3045809A304A304020A8A
:00000001FF
26 changes: 26 additions & 0 deletions pic/emulateme.tinymem.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdint.h>
#define LEN 0x10

static const uint8_t parity_ref = 0x58;
static char seckrit[LEN] = { 0x51, 0x53, 0x4d, 0x77, 0x58, 0x14, 0x51, 0x5f, 0x45, 0x6c, 0x17, 0x7f, 0x6e, 0x78, 0x7f, 0x1c };

uint8_t decrypt(const char *key) {
uint8_t parity = 0;
for (uint8_t i = 0; i < LEN; i++) {
seckrit[i] ^= key[i];
parity ^= seckrit[i];
}
if (parity != parity_ref) {
return 0;
}
for (uint8_t i = 0; i < LEN; i++) {
seckrit[i] ^= parity;
}
return 1;
}

int main(int argc, const char *argv[]) {
const char *key = "AnyColourYouLike";
decrypt(key);
return 0;
}