#borlandcpp — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #borlandcpp, aggregated by home.social.
-
-
The Dark Art of DOS Audio: PC Speaker Tricks and PWM Madness
Think the old PC speaker was only good for making awful beeps? Yeah, me too—until I started digging into how it actually works.#MSDOS #BorlandCPP #RetroCoding #DOSDev #chiptune
https://ncot.uk/videos/the-dark-art-of-dos-audio-pc-speaker-tricks-and-pwm-madness/ -
This appears to be the minimal configuration that can demonstrate the bug. Turns out, the procedure being passed does not need to be fastcall; it being a procedure is sufficient.
#include <stdio.h>
void inner () {}
struct Thing {
void _fastcall outer (void (*formal)());
};
void _fastcall Thing::outer (void (*formal)()) {
printf("this = %p, formal = %p\n", this, formal);
}
void main () {
Thing thing;
printf("&thing = %p, inner = %p\n", &thing, inner);
thing.outer(inner);
}Compiling it in small memory model, with 16-bit code pointers, triggers the bug, as depicted below. Compiling in compact model, where function pointers are 32-bit and don't fit into a single 16-bit register, does not. (Never mind that this
printftemplate is not entirely correct for when data pointers and code pointers can have different sizes.)