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
import time | |
from random import randint | |
import curses | |
from console import ConsoleDisplay | |
if __name__ == '__main__': | |
rows, cols = (25, 80) | |
def func(stdscr, rows, cols): | |
console = ConsoleDisplay(stdscr, rows, cols) |
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
; get value_addr % 0x10 | |
; | |
; yasm -f elf32 -o div.o -g stabs div.asm | |
; or | |
; yasm -f elf32 -o div.o -g dwarf2 div.asm | |
; | |
; ld -m elf_i386 -o div div.o | |
; | |
; run the program | |
; ./div |
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
typedef struct dlist_s dlist_t; | |
struct dlist_s | |
{ | |
dlist_t *next; | |
dlist_t *prev; | |
}; | |
void dlist_init(dlist_t *list) | |
{ |
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
uint32_t | |
hash(uint8_t const *buff, size_t count, uint32_t hash, uint8_t bits) | |
{ | |
for (size_t i = 0; i < count; i++) | |
{ | |
hash = ((hash << bits) | (hash >> (32 - bits))) ^ buf[i]; | |
} | |
return hash; | |
} |
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
extern uint32_t crc32_table[]; | |
uint32_t | |
crc32(uint8_t *buf, size_t count, uint32_t crc) | |
{ | |
while (count--) | |
crc = crc32_table[(crc32 ^ *buf++) & 0xff] ^ crc32 >> 8; | |
return crc; | |
} |
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
int8_t c2hex(int8_t c) | |
{ | |
return (unsigned) (c - '0') < 10 ? c - '0' : ((unsigned) (c | 0x20) - 'a' < 6 ? 9 + (c&7) : -1); | |
} | |
int8_t _c2hex(int8_t c) | |
{ | |
if (c - '0' >= 0 && c - '0' < 10) return c - '0'; | |
if (c - 'a' >= 0 && c - 'a' < 7) return c - 'a' + 10; | |
if (c - 'A' >= 0 && c - 'A' < 7) return c - 'A' + 10; |
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
; yasm -o %:r.o % -f elf32 -g stabs | |
; ld -m elf_i386 %:r.o -o %:r -lc --dynamic-linker /lib/ld-linux.so.2 | |
section .text | |
msg db "hello world!",10,0 | |
extern puts | |
extern exit |
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
; yasm -o %:r.o % -f elf32 -g stabs | |
; ld -m elf_i386 %:r.o -o %:r -lc --dynamic-linker /lib/ld-linux.so.2 | |
section .data | |
dividend dq 0xdeadbeef12 | |
divisor dd 0x100 | |
quotient dd 0 | |
remainder dd 0 | |
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> | |
int main() | |
{ | |
long long a = -1ll; | |
unsigned b = 0xff; | |
a &= ~b; | |
// what is a now? | |
printf("0x%016llx\n", a); | |
} |
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 <iostream> | |
struct one_bit_t | |
{ | |
signed value : 1; | |
}; | |
int main() | |
{ | |
one_bit_t a; |