Assembly Inserts as a Workbench

Assembly Inserts as a Workbench

It is extremely difficult to program in pure Assembly. A program with minimal functionality contains an awful lot of constructs interacting in a sophisticated manner with one another and starting to behave unpredictably without any notice. At one stroke, you isolate yourself from an environment, to which you are accustomed. It is easy to add two numbers in Assembly; displaying the result on the screen is a different matter.

Assembly inserts are the way out. Classical manuals on Assembly language from the opening pages drown the reader in the depths of system programming, which is frightening in its complexity of the processor architecture and the operating system. Assembly inserts, on the other hand, allow programmers to remain in the development environment (C/C++, Pascal, or both), to which they are accustomed, and gradually, without abrupt changes, allow them to get acquainted with the internal world of the processor. The same approach allows the programmers to begin the study of Assembly language from the 32-bit protected processor mode. In its pure form, the protected mode is so complicated that it is practically impossible to master it from the start. Because of this, all classical manuals start with a description of the obsolete 16-bit real mode. This turns out to be not only unnecessary dead weight but also excellent means of confusing beginners . Perhaps you remember the proverb, "Forget what you've learned; remember what you know." Based on my experience, and on the experience of my friends and colleagues, I dare say that the approach to the study of Assembly language based on Assembly inserts surpasses all others by at least the following two categories:

  • Efficiency ” Practically within 3 or 4 days of intense learning, the programmer who has not been involved in Assembly programming before will write quite decent programs.

  • Ease of mastering ” Study of Assembly language goes seamlessly, without any difficulties, and it doesn't require serious effort. At no stage of the learning process does the student risk being drowned in tons of difficult and irrelevant information. Each further step is intuitively clear, and all potential obstacles have been carefully removed from the road.

Well, you need not wait. To declare assembly inserts in Microsoft Visual C++, the __asm keyword is used. The simplest Assembly insert appears as shown in Listing 2.4.

Listing 2.4: The simplest Assembly insert that adds two numbers
image from book
 main() {         int a = 1;   // Declare the a variable and assign it the value of 1.         int b = 2;   // Declare the b variable and assign it the value of 1.         int c;       // Declare the c variable without  initializing it.         // Start of the Assembly insert         __asm{            MOV EAK, a      ; Load the value of the a variable into                            ; the EAX register.            MOV EBX, b      ; Load the value of the b variable into                            ; the EBX register.            ADD EAX, EBX    ; Add EAX to EBX, and write the result                            ; into EAX.            MOV c, EAX      ; Load the EAX value into the c variable.         }         // End of Assembly insert         // Output the contents of the c variable         // using the customary printf function.         printf("a + b  =  %x + %x  =  %x\n", a, b, c); } 
image from book
 


Shellcoder's Programming Uncovered
Shellcoders Programming Uncovered (Uncovered series)
ISBN: 193176946X
EAN: 2147483647
Year: 2003
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net