[技術] Hexspeak

Written on 2:01 上午 by Yu Lai

我相信在程式設計師心理,都有想惡搞的一面,
這也大概就是HexSpeak會出現的原因吧。XD
PS: 這篇就當做用來設計Protocol與Magic Number參考用吧。

Ref: Wikipedia Hexspeak

Hexspeak, like leetspeak, is a novelty form of variant English spelling.

Hexspeak was created by programmers who wanted a magic number, a clear and unique identifier with which to mark memory or data. Using hexadecimal notation, which includes the digits 0123456789ABCDEF, it is possible to create small words with the digit "0" representing the letter "O", "1" representing the letter "I", "5" representing "S", and "6" or "9" representing "G" or "g" respectively.

Notable magic numbers

Many computer processors, operating systems, and debuggers make use of magic numbers, especially as a magic debug value.

* 0xABADBABE ("a bad babe") is used by Apple as the "Boot Zero Block" magic number.[citation needed]
* 0xBAADF00D ("bad food") is used by Microsoft's LocalAlloc(LMEM_FIXED) to indicate uninitialised allocated heap memory.[citation needed]
* 0xBADCAB1E ("bad cable") Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger.[citation needed]
* 0xBADDCAFE ("bad cafe") is used by 'watchmalloc' in OpenSolaris to mark allocated but uninitialized memory.[citation needed]
* 0xBEADFACE ("bead face, or face bead") Is the pattern that fills all unused memory locations in the Motorola 68HCS12DP256 micro-controller simulator, SimHC12.[citation needed]
* 0xCAFEBABE ("cafe babe") is used by Mach-O ("Fat binary" in both 68k and PowerPC) to identify object files, and by the Java programming language to identify Java bytecode class files.[1]
* 0xCAFED00D ("Cafe Dude") is used by Sun JAVA as a magic number for their pack200 compression.[citation needed]
* 0xD15EA5E ("disease") opens a game disc partition on the Wii video game console. (Also of note, it was 0xDEADBEEF on the Nintendo GameCube.)[citation needed]
* 0xDEADBABE ("Dead Babe") is used by IBM Jikes RVM as a sanity check of the stack of the primary thread [2]
* 0xDEADBEEF ("dead beef") is used by IBM RS/6000 systems, Mac OS on 32-bit PowerPC processors and the Commodore Amiga as a magic debug value. On Sun Microsystems' Solaris, it marks freed kernel memory. On OpenVMS running on Alpha processors, DEAD_BEEF can be seen by pressing CTRL-T.[3]
* 0xDEADDEAD ("dead dead") is the bug check (STOP) code displayed when invoking a Blue Screen of Death either by telling the kernel via the attached debugger, or by using a special keystroke combination[4]. This is usually seen by driver developers, as it is used to get a memory dump on Windows NT based systems. An alternative to 0xDEADDEAD is the bug check code 0x000000E2[5], as they are both called MANUALLY_INITIATED_CRASH as seen on the Microsoft Developer Network.
* 0xDEFEC8ED ("defecated") is the magic number for OpenSolaris core dumps.[6]
* 0xFACEFEED ("face feed") is used by Alpha servers running Windows NT. The Alpha Hardware Abstraction Layer (HAL) generates this error when it encounters a hardware failure.[7]
* 0xFEE1DEAD ("feel dead") is used as a magic number in the Linux reboot system call.[8]
* 0xFEEDFACE ("feed face") is used as a header for Mach-O binaries, and as an invalid pointer value for 'watchmalloc' in OpenSolaris.[citation needed]

[edit] Designing magic numbers

Given there are at least a few hundred words in English consisting of only the letters "a", "b", "c", "d", "e", "f", "o", "i" and "s", it is easy for programmers to devise their own, such as 0xD15EA5ED or 0xBED51DE5. As such, it is useful to observe a few patterns in the classic hexspeak constants given above. These constants all use the full width of the word (in this case 32-bit), and none begin with "1" or "5". This choice means that if the word is interpreted as an integer, it is a (usually large) negative integer. For example, 0xBAADF00D is -1163005939, a large negative integer that is unlikely to arise in many programs. Microsoft's 0xBAADF00D is also a good value to catch access to uninitialised memory for another reason—ending the word with the "1", "5", "b", "d", or "f" ensures that the constant is an odd number, which generates an unaligned pointer exception on many processor architectures if the constant is interpreted as a pointer value.
[edit] Alternative letters

* In the Ada programming language, hexadecimal numbers are enclosed by "16#" and "#". For example, "16#Ada_Ada_Ada_Ada#".
* The C programming language notation uses the "0x" prefix to indicate a hexadecimal number; the "0x" is usually ignored when reading the letters or numbers.
* In the Intel assembly language, hexadecimal numbers are denoted by a "h" suffix. For example: FEEDADEADF15h ("feed a dead fish"). Note that numbers in this notation that begin with a letter have to start with a zero to distinguish them from variable names. "FEEDADEADF15h" would then be "0FEEDADEADF15h".
* In 6502 assembly language , hexadecimal numbers are denoted by a "$" prefix. This allows for words starting with the letter "S", for example $EED ("seed").

If you enjoyed this post Subscribe to our feed

No Comment

張貼留言