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
// implements a race-based rng using posix threads | |
#include <pthread.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <unistd.h> | |
// https://randu.org/tutorials/threads/ |
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
// re-writing strlen, while certainly doable, isn't the point | |
#include <string.h> | |
void print(char* message); | |
void readLine(int maxBytes, char *dest); | |
int main(void) { | |
char message[] = "Hello world!\n"; | |
print(message); |
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
section .data | |
msg db "Hello, World.asm","\0x0a" ; | |
section .text | |
global hello | |
hello: | |
mov rax, 1 | |
mov rdi, 1 | |
mov rsi, msg |
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() { | |
printf("Enter 0 to print hello and 1 to print goodbye: "); | |
unsigned long mask = 0; | |
scanf("%ld", &mask); | |
// ensure mask is 0 or 1 | |
mask = !(!(mask)); |
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
; cleaner, more efficient implementation of final program shown in https://youtu.be/APiHPkPmwwU | |
; to execute $ nasm boot.asm -f bin -o boot.bin && qemu-system-x86_64 -drive file=boot.bin,format=raw | |
mov ah, 0x0e | |
mov al, 65 | |
int 0x10 | |
loop: | |
inc al | |
cmp al, 'Z' | |
int 0x10 |
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
; Solution to exercise at end of https://youtu.be/APiHPkPmwwU | |
; to execute $ nasm boot.asm -f bin -o boot.bin && qemu-system-x86_64 -drive file=boot.bin,format=raw | |
mov ah, 0x0e | |
mov al, 97 | |
mov dl, 97 | |
int 0x10 | |
loop: | |
inc dl | |
mov al, dl |