Skip to content

Instantly share code, notes, and snippets.

@berk76
berk76 / terminal_resize.md
Last active February 16, 2021 10:00
UNIX: Detecting terminal window resize

Detecting terminal window resize in UNIX

How to get current size of terminal window and how to detect changes.

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include 
@berk76
berk76 / com_exe.md
Last active February 9, 2018 15:07
DOS: com vs exe

COM vs. EXE Program

EXE program can have any size whereas COM program can have maximally 64kB (just one segment).

COM Program

At the beginning of program there is program segment prefix (PSP). Because COM program is stored only in one segment so PSP occupies first 256 bytes (100h). Therefore start point begins at 100h. Values of segment registers are set to the begin of segment and don’t change during executing.

COM program in memory:

@berk76
berk76 / flakes.md
Last active January 8, 2018 14:37
DOS: Snow flakes
@berk76
berk76 / plot.md
Last active January 6, 2018 21:22
DOS: Changing CRT mode using TC and inline asm

Changing CRT mode using TC and inline assembler

This program is an example of using Turbo C inline assembly statements. For compilation you will need:

  • Turbo C 2.01 and Turbo Assembler installed (tcc -B plot.c)
  • or Borland C++ 3.1 (bcc -B plot.c)
/****************************************************************
*                                                               *
@berk76
berk76 / memory_model.md
Last active June 18, 2024 19:32
DOS: Choosing a memory model
C News  Vol. 1  Issue 11                         Sept 15, 1988


        CHOOSING A MEMORY MODEL by Bill Mayne

        ABSTRACT:   The  meaning  of  the  "near",  "far",  and  "huge"
        keywords specifying pointer types and how these are related  to
        the  various memory models available to C programmers using the
        80x86 family of processors used in IBM and compatible  PCs  and
@berk76
berk76 / c_asm.md
Last active April 2, 2020 20:45
DOS: TASM and C

How to combine Assembly and C in DOS

This gist is showing an example of C program calling routine written in assembly.

Some theory

  • C is case sensitive so it is necessary to use /ml switch in TASM
  • C compiler uses leading underscore (_) character for function names
  • parameters are passed to function in stack and integer return value is passed back in AX register
  • stack cleaning is done by caller
@berk76
berk76 / clavier.md
Created January 2, 2018 10:11
DOS: Clavier

Simple AdLib FM Clavier by Indrek Pinsel 1993

  • CLAVIER.COM - Executive
  • CLAVIER.DOC - This document
  • CLAVIER.C - C source

Tiny computer keyboard FM player for those who have kind of AdLib or Sound Blaster. It's just a little piece of code for fun...

NB! The Extended (4-operator) FM Synthesis Mode of SBPro 2 is not controlled. Due to it there may be missounds when the Clavier is executed with SBPro 2 with ExtFM switched on.

@berk76
berk76 / fireworks.md
Last active December 31, 2017 21:27
DOS: Fireworks in basic

Fireworks in QBasic

FIREWORK.BAS from unknown author

DECLARE SUB bmper ()
DECLARE SUB delay (seconds!)
RANDOMIZE TIMER
CONST del = .02         'Sets standard movement delay (.02)
CONST scrnmode = 13     'Sets SCREEN mode (12 or 13)
CONST lowerbound = 100  'Least amount of sparks to create (100)
@berk76
berk76 / cursor.md
Last active December 30, 2017 10:03
DOS: Cursor mangling in C

Cursor mangling in C

/*********************************************************************/
/*                                                                   */
/*  All the following functions were written by Paul Edwards and     */
/*  placed in the Public Domain except for cursor() which was        */
/*  written by Gary Chambers and I am waiting for him to tell me     */
/*  whether his routine can be placed in the Public Domain.  Oh      */
/*  yeah, I modified Gary's routines *slightly*.                     */
@berk76
berk76 / AS400.md
Last active March 4, 2020 20:57
CL Commands