Skip to content

Instantly share code, notes, and snippets.

@berk76
berk76 / bom.md
Last active November 11, 2017 19:54
BOM

Byte Order Mark

Byte Order Mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream. Its code point is U+FEFF. BOM use is optional, and should appear at the start of the text stream, if used.

Types of BOM:

Encoding Representation
UTF-8 EF BB BF
UTF-16 (BE) FE FF
@berk76
berk76 / windows_service.md
Last active November 12, 2017 22:10
Framework for Windows NT/2000/XP service application

Template for creating Windows service application in c

All necessary information are included in comments within following template.

/* --------------------------------------------
   Framework for Windows NT/2000/XP service application
   Copyright (c) 2005, Franck Charlet
   All rights reserved.
@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 / 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 / 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 / flakes.md
Last active January 8, 2018 14:37
DOS: Snow flakes
@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 / 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 / AS400.md
Last active March 4, 2020 20:57
CL Commands
@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