views:

1393

answers:

45

Long before you practice writing readable code, what "magic numbers" you still remember up to this day?

here's some of my list:

  • 72 80 75 77 13 32 27 - up down left right enter space escape
  • 1 2 4 128 - blue green red blink
  • 67h 33h 17h - interrupt for EMS, mouse, printer
  • function AH 9, interrupt 21
  • alt+219 for block ASCII
  • alt+164 ñ
  • 90 NOP
  • 13 10 carriage return, line feed
  • ascii 1 and 2 face, ascii 3 heart. no not this heart: <3 :-)
  • debug -o72,10 -o71,12 clears the BIOS password. I don't know what those numbers mean, it's like a trade secret that gets shared with each other during college days.
  • ascii 7 sounds a beep

P.S. Somehow, remembering some of these magic numbers can help you in some tech problems, your keyboard is broken, the office pal's keyboard doesn't have accented characters. An anecdote, during college, one of my friend asked me how to remove the newlines in his Word document. Not having used Word so much then, I somehow "intuitively" guessed to find ^013 and replace it with blank. Well it works :-)

+3  A: 

How about

call -151
Paul Tomblin
I know a "call -151", but I don't think I'm familiar with "sys".
Curt Hagenlocher
@curt - you're right.
Paul Tomblin
Ah, memories of the glory days (incl "IN#6").
paxdiablo
I just remembered why I wrote "sys" there. I was thinking of "sys 49152" from the Commodore 64.
Paul Tomblin
+1  A: 
  • int 19h in DOS. Jumps to the MBR and executes from there.
  • Alt-58 is the colon (:). I need this when stuck in vi and an unknown key-table (Dvorak, etc.)
pi
+1  A: 

$C030 (Apple II internal speaker control address.)

Eric Rosenberger
+2  A: 

Alt-0183 for ·

simonjpascoe
+1  A: 

CD 20

Int 20h, Return control of application back to DOS.

Brian Knoblauch
+15  A: 
poke 53280, <color>
poke 53281, <color>
Henrik Gustafsson
+1: {c64 nostalgia bliss}
Jason S
+5  A: 
poke 36879, <color> (vic-20)
Tony Arkles
+35  A: 

42

mouviciel
6 x 9 = 42 (Works in base 13. Douglas Adams, right up to is dying breath, denied that that's why he came up with "what do you get when you multiply six by nine?" as the question to the answer (42) of life, the universe and everything.)
RobH
@RobH - I always thought the joke was that the Earth got its sums wrong, or rather that the question hadn't been finalised. To say "what is 6 times 7" is a really stupid thing to think of after ??? years of deep thinking, but to still be at "what is 6 times 9" because you haven't quite had time to get that last digit from 9 to 7? As for bases - if he'd said "what is 6 times 5", someone would point out that *that* is 42 (base 7). Pure coincidence isn't unlikely.
Steve314
+3  A: 

Bytes per MB: 1048576

recursive
+1  A: 

Probably far too many, but it's hard to recall on-demand. :)

I hope I'll never forget $dff180, the custom chip register that holds the current background color on the Commodore Amiga computers. You could have a lot of fun writing 10-line assembler programs that quickly poked various values into that register, thereby creating full-screen color patterns that moved crazily.

unwind
+1  A: 

J103 Recover a RM380z (last used in school early 80s)

49152 = spare 4k memory above basic on Commodore64

Martin Beckett
+2  A: 

Tons, some of which fade in and out. Assembly language stuff from several processors.

I know a lot of 8080 stuff in octal, and the corresponding hex for some of these. Similarly for a certain amount of ASCII.

I think that 040.136 is the the HDOS $TYPTXT subroutine (print a string embedded inline in the code, terminated by a NUL). In split-octal.

0x64 = 100 decimal.

0xF0 - 0xF9 are the digits 0-9 in EBCDIC.

0xCAFEBABE is the magic number for Java class files.

call $0005 in CP/M to make a system call. That worked in MSDOS up to about version 3.1.

Darron
OCT31 = DEC25 :-)
RobH
+3  A: 
  • 0xA000:0000 - start of video memory on x86,
  • int 13h - interrupt used to swtich video modes
  • 0x101 - I believe is the VESA video mode for 640x480x256 colours...

I did a lot of DOS graphics programming as a kid :) Happy days!

Mark Pim
+2  A: 

How about this set:

IRQs

  • 0 - System Timer
  • 1 - Keyboard
  • 2 - Second IRQ controller (Also redirected IRQ9)
  • 3 - COM2, COM4
  • 4 - COM1, COM3
  • 5 - LPT2, newer SoundBlaster cards
  • 6 - Floppy Controller
  • 7 - LPT1, older SoundBlaster cards
  • 8 - Open?
  • 9 - EGA Video / Open?
  • 10 - Open?
  • 11 - PS2 Mouse
  • 12 - Open?
  • 13 - Math Coprocessor
  • 14 - Hard Disk Controller 1
  • 15 - Hard Disk Controller 2

I also remember that the priority order goes 0, 1, 2, 8, 9, 10, 11, 12, 13, 14, 3, 4, 5, 6, 7 because the second IRQ controller was chained to IRQ 2.

R. Bemrose
+1  A: 

Man, I've forgotten the sys call for the Commodore PET PIC chip now. I had that one for years!

6031769 still remains, however.

bobince
+6  A: 

Reboot the C64:

SYS 64738

was huuuuuge fun to add a "magic variable" TEM with the value 64738, clear the screen, and issue:

SYSTEM RESET

and watch friends trying to figure out why that command didn't work when it came back to the prompt.

Lasse V. Karlsen
+1  A: 

8224 = two packed spaces (256*32) + 32

16 777 216 = 2 ^ 24

E5 = First byte of a deleted file

5C = Filename or 1st param in an FCB (File control block)

POKE -936 = Clear screen on Apple II

gbarry
Somewhere I've got a radix-50 string, too...hmmm, -31055 ?
gbarry
+5  A: 

86400 (number of seconds in a day)

Rob
+1  A: 

cdc901 - call the cls routine on a trs80 model 1.

3e - lda

21 - ld hl

11 - ld de

01 - ld bc

EvilTeach
+17  A: 

4 8 15 16 23 42

Yours truly,
Desmond

splattne
Entering this at work had to be a bitch.
MrHus
+1  A: 

POKE 646,C

Changed cursor color on the Commodore 64 (C=0-15)

splattne
+2  A: 

3c8h, port to select a color to change the palette for on a VGA card.

3c9h, port to write your r, g, and b values to for the selected color.

Laserallan
+1  A: 

300:2c 30 c0 a9 10 20 a8 fc 4c 00 03 300g

entered in the monitor of the Apple II will play a tone on the speaker.

Here's the first machine language program I every wrote: 300:a9 c8 20 ed fd a9 c9 20 ed fd 4c 00 03 which turns into 300: LDA #$C8 JSR $FDED ; COUT LDA #$C9 JSR $FDED JMP $0300

which prints HI repeatedly. (hey, I was 12)

plinth
+1  A: 

[\033[3;44m]\u@\h:\W$[\033[0m]

To set the bash prompt (PS1) to my choice.

Xolve
+1  A: 

0x0B8000000 - Beginning of text part of video memory
0x0A0000000 - Beginning of video memory int 21h, ax=4c terminate program
QBasic: Screen 12 - 640X480X16, screen 13 - 320X200X256.

(and IDDQD :D)

SurDin
A: 
38911 BYTES FREE
yatima2975
A: 

Assembler:

0x33 XOR

Daniel
+3  A: 

0xDEADBEEF, 0xCAFEBABE

Stefan Thyberg
+3  A: 

0xEFBBBF UTF-8 BOM

Gumbo
Surely, that depends on the endian-ness of the 3-octet word :-) Did you mean 0xEF 0xBB 0xBF?
paxdiablo
+1  A: 

from MS-DOS days:

CD 21 - system call
CD 27 - terminate and stay resident
CC    - INT 3 (x86 single byte interrupt)

and, of course, powers of 2 (up to 262144).

Ferruccio
+1  A: 

0xA9 - the LDA (immediate) instruction on a 6502. From at least 25 years ago...!

Alnitak
+1  A: 

49 49 2A - II* - the start of a header of a TIFF file

Kevin
that's only an intel (little endian) byte ordered TIFF. 4D 4D 2A is also valid. :)
plinth
true, but I almost exclusively work with the intel version, so that is what's stuck in my head
Kevin
+1  A: 

MODE 2

8 colour mode on the BBC B Micro. He*llo* Elite!

Robert Grant
actually Elite used two modes at the same time, by reprogramming the CRTC mid frame.
Alnitak
aaah OK so was only the bottom of the screen with the colour console Mode 2?
Robert Grant
+2  A: 
g=c800:5

From MS-DOS DEBUG, invoke the utility program in HDD controller ROM for low-level formatting, etc.

Andrew Medico
+2  A: 

A painful 6 month technical train document translation placement (French to English) resulted in the branding of my mind with:

ALT + 224 = à, ALT + 232 = è, ALT + 233 = é, ALT + 244 = ô

Along with muscle memory of using an AZERTY keyboard.

TreeUK
+1  A: 

Alt + 0 6 4 for an simple @

Still using it on stackoverflow (German keyboard layout + FF 3.0.2, Alt Gr + Q creates a blockquote :( )

furtelwart
A: 

53266 - C64 Raster register, used for many cool graphics tricks

abababa22
+1  A: 

PI - 3.14159265 (Wrote circle drawing programs and orbital programs on my Apple IIc, both requiring pi, and that was pi to the max number of significant figures in applesoft basic)

Solmead
A: 

here's one: 6.02x10^23

Tim
+1  A: 

alt + 255

I used to create invisible directories, or directories with spaces in it to fool people back in the early 90's

amischiefr
A: 

It's not a number, but:

/ppag

in the old, old days of Lotus 1-2-3 meant:

  • / bring up the menu
  • p print
  • p to the printer
  • a align (go to the top of the page)
  • g actually print the page.

What a waste of neurons!

Carl Manaster
+3  A: 

up up down down left right left right B A start

JC
A: 

0xCAFEBABE for Java class files :-)

mikera
A: 
RANDOMIZE USR 1230

in ZX basic made the screen border flash like it was loading a game. Handy for keeping people off the machine while you were away...

mdma
+1  A: 

I'm an electrical engineer, so:

  • Alt-234 for ohms (Ω)
  • Alt-230 for micro (µ)
  • Alt-248 for degrees (°)
  • Alt-250 for interpunct (for conjugating units) (·)
Nick T