banana() { asm("nop"); }
Here's how you embed assembly language instructions using Microsoft C on a PC:
__asm mov ah, 2
__asm mov dl, 43h
You can also prefix the assembler code with the keyword "_ _asm". You can also use the keyword
once, and put all the assembler code in a pair of braces, like this:
__asm {
mov ah, 2
mov dl, 43h
int 21h
}
Little checking is done for you, and it's easy to create programs that bomb out. But it's a good way to
experiment with and learn the instruction set of a machine. Take a look at the SPARC architecture
manual, the assembler manual (which mostly talks about syntax and directives), and a databook from
one of the SPARC vendors, such as Cypress Semiconductor's "SPARC RISC User's Guide."
Chapter 7. Thanks for the Memory
A master was explaining the nature of the Tao to one of his novices.
"The Tao is embodied in all software—regardless of how insignificant," said the master.
"Is the Tao in a hand-held calculator?" asked the novice. "It is," came the reply.
"Is the Tao in a video game?" continued the novice. "It is even in a video game," said the master.
"And is the Tao in the DOS for a personal computer?"
The master coughed and shifted his position slightly. "That would be in the stack frame Bob, and the
lesson is over for today," he said.
—Geoffrey James, The Tao of Programming
the Intel 80x86 family...the Intel 80x86 memory model and how it got that way...virtual
memory...cache memory...the data segment and heap... memory leaks...bus error—take the
train...some light relief—the thing king and the paging game
This chapter starts with a discussion of memory architecture for the Intel 80x86 processor family (the
processor at the heart of the IBM PC). It contrasts PC memory with the virtual memory feature found
on other systems. A knowledge of memory architecture helps a programmer to understand some of the
C conventions and restrictions.