List of Examples

Chapter 1: Developing Efficient Program Code

Example 1.1: An assembly loop with a decremented counter
Example 1.2: An assembly loop with the cmovz command
Example 1.3: Optimizing the byte processing loop
Example 1.4: Copying double words (before optimization)
Example 1.5: Unrolling the loop by copying two double words instead of one
Example 1.6: Initializing the array (before optimization)
Example 1.7: Initializing the array (optimized)
Example 1.8: Array initialization (version for MASM 6.14)
Example 1.9: Initializing and displaying an array of integers
Example 1.10: Finding the absolute value of a number by using conditional jumps
Example 1.11: Finding the absolute value of a number without using conditional jumps
Example 1.12: A fragment of assembly code that evaluates the if (b < a) a = b expression by using conditional jumps
Example 1.13: A fragment of assembly code that evaluates the if (b < a) a = b expression without using conditional jumps
Example 1.14: An implementation of the if (i1 != 0) i1 = i2; else i1 = i3 algorithm with using the conditional jump commands
Example 1.15: An implementation of the if (i1 != 0) i1 = i2; else i1 = i3 algorithm without using the conditional jump commands
Example 1.16: An assembly module containing two functions (before optimization)
Example 1.17: The optimized variant of the assembly code with two functions
Example 1.18: A console application that displays the results of the fcall function
Example 1.19: Selecting the positive and negative numbers out of the array (non-optimized version)
Example 1.20: Selecting the positive and negative numbers out of the array (optimized version)

Chapter 2: Optimizing Calculation Algorithms

Example 2.1: Adding two floating-point numbers
Example 2.2: Summing up the elements of an integer array by using the C++ operators only
Example 2.3: The assembly-language version of the program for summing up array elements
Example 2.4: Evaluating a formula by using the FPU assembler commands
Example 2.5: A C++ program comparing two floating-point numbers
Example 2.6: Comparing two integers
Example 2.7: The application that counts the number of occurrences of the given number in the array
Example 2.8: A program for calculating the sine and the cosine of an angle
Example 2.9: The modified program calculating the sine and the cosine of an angle
Example 2.10: Testing if the floating-point number is equal to zero (0)
Example 2.11: The use of the LEA instruction as an arithmetic command
Example 2.12: Using the assembly-language commands for copying a string in a button click handler in a C++ .NET program
Example 2.13: Using the movsb command for copying the strings
Example 2.14: Using assembly language for copying an array of integers
Example 2.15: Using assembly language for string concatenation in a C++ .NET program
Example 2.16: Concatenation of two integer arrays
Example 2.17: Using the assembly commands for comparing two strings
Example 2.18: Comparing the arrays of integers
Example 2.19: Using the assembly-language commands to fill a string with space characters
Example 2.20: Filling an integer array with zeroes
Example 2.21: Converting lowercase characters to uppercase ones
Example 2.22: An implementation of string operations without using the string commands

Chapter 3: Developing and Using Procedures in Assembly Language

Example 3.1: Functions for computing the formula i1i2100
Example 3.2: A call to a procedure using a register
Example 3.3: Using the jmp command to call a procedure
Example 3.4: Passing parameters via registers in assembly procedures
Example 3.5: Saving registers when working with procedures
Example 3.6: Passing parameters to a procedure via the stack
Example 3.7: Using the data segment in an assembly procedure
Example 3.8: Using the code segment for work with local data
Example 3.9: The sub2 procedure
Example 3.10: The a2 procedure that adds up two integers
Example 3.11: The rets procedure
Example 3.12: The fchar procedure
Example 3.13: The subcom procedure
Example 3.14: The abs procedure

Chapter 4: Optimizing C++ Logical Structures with Assembly Language

Example 4.1: A fragment of an assembly program, with an analog of the if statement, that adds up two integers
Example 4.2: Computing the maximum of two numbers and displaying it
Example 4.3: A modified variant of the program that includes the if else statement
Example 4.4: A fragment of code that uses a while loop
Example 4.5: An assembly-language implementation of the task that uses a while loop
Example 4.6: An implementation of a while loop with the scasd command
Example 4.7: A fragment of the C++ code that finds the sum of the first four elements of an array
Example 4.8: The do while loop implemented in the assembler
Example 4.9: A fragment of C++ code that uses a for loop
Example 4.10: An assembly variant of a program that finds the sum of the first seven elements of an array with the for loop
Example 4.11: A fragment of assembly code that implements a switch statement
Example 4.12: A fragment of assembly code that uses condition-processing subroutines
Example 4.13: A C++ program that demonstrates the use of the switch statement
Example 4.14: Eliminating the switch case branching by using the inline assembler in a C++ program

Chapter 5: Assembly Module Interface to C++ Programs

Example 5.1: A function that adds together two numbers. The _stdcall convention is used
Example 5.2: An assembly function with the _cdecl calling convention
Example 5.3: A function with the _fastcall calling convention
Example 5.4: The AddTwo function (a modified variant)
Example 5.5: The Sub20 assembly function
Example 5.6: A project file that uses the AddTwo and Sub20 functions
Example 5.7: The AddTwo and Sub100 functions
Example 5.8: Functions that use the _fastcall and _cdecl calling conventions
Example 5.9: The onBnclicked handler
Example 5.10: The nfp function that returns the result on the coprocessors stack
Example 5.11: An application that uses the nfp function

Chapter 6: Developing and Using Assembly Subroutines

Example 6.1: A function that multiplies an integer by 5
Example 6.2: A C++ program that uses the mul5 procedure
Example 6.3: An assembly function that passes a character string to the main program
Example 6.4: A console application that calls the strshow function
Example 6.5: An assembly function that copies a string to the main application
Example 6.6: A console application that displays a copy of a string
Example 6.7: A function that returns a substring to the C++ program
Example 6.8: The ID_PartStr menu item selection handler
Example 6.9: A C++ program that displays a substring
Example 6.10: A function that searches for a character in a string
Example 6.11: An on-button-clicked event handler in a C++ application
Example 6.12: A function that searches for the maximum element in a floating-point array
Example 6.13: A C++ program that displays the maximum value
Example 6.14: Displaying the lines
Example 6.15: Inverting an integer in an assembly procedure
Example 6.16: A console application that demonstrates processing the elements of a structure in an assembly procedure
Example 6.17: A function processing the elements of a union
Example 6.18: The main fragments of a C++ program that uses the uex function

Chapter 7: Linking Assembly Modules with C++ .NET Programs

Example 7.1: The source code of the subf2 function
Example 7.2: A C++ application that uses a separate object module
Example 7.3: A modified version of the subf2.asm assembly file
Example 7.4: A console application that uses the functions subf2 and add100 from the added assembly module
Example 7.5: The source code of the functions subf2 and add100 with the conventions _cdecl and _stdcall
Example 7.6: The use of the fres common variable in an assembly module
Example 7.7: The use of a common variable in a C++ .NET application
Example 7.8: The conv assembly function that processes a character string
Example 7.9: A program that uses the conv function
Example 7.10: The source code of the convs.asm function
Example 7.11: A console application that uses the functions convs and convt
Example 7.12: The add2.cpp function
Example 7.13: The sub2.asm function
Example 7.14: An application that uses a library
Example 7.15: The assembly functions of the liblasm module
Example 7.16: The assembly function of the lib2asm module
Example 7.17: A console application that uses the libiasm.lib and lib2asm.lib library files
Example 7.18: A modified variant of the CPP DLL file
Example 7.19: The sub2 function
Example 7.20: A console application that uses a dynamic link library
Example 7.21: The max and min assembly functions
Example 7.22: The USING_IMPDLL_STANDARD dynamic link library
Example 7.23: The source code of an application that uses assembly functions of a standard library and DLL
Example 7.24: The source code of the COMMON_DLL dynamic link library that uses the absf assembly function
Example 7.25: The absf assembly function
Example 7.26: A main program that uses the DLL containing the absfdll function

Chapter 8: Dynamic Link Libraries and Their Development in Assembly Language

Example 8.1: Source code for imdll.dll
Example 8.2: Using impdll in the application test_impdll
Example 8.3: Template of DLL developed in MASM
Example 8.4: The modified variant of DLLs assembly version
Example 8.5: Calling of a function from DLL using the load-time dynamic linking
Example 8.6: DLL template
Example 8.7: Function sub2
Example 8.8: Using the object modules in DLL
Example 8.9: More complicated example where load-time dynamic linking is used
Example 8.10: Demonstration of run-time linking of DLL
Example 8.11: Source code of addsub2.dll
Example 8.12: The source code of application using addsub2.dll
Example 8.13: Incorrect use of calling convention

Chapter 9: Basic Structures of Visual C++ .NET 2003 Inline Assembler

Example 9.1: Using a macro with the inline assembler
Example 9.2: Using the square brackets in the _asm block through a button handler
Example 9.3: The function returning results through a return operator
Example 9.4: The function returning result in the EAX register
Example 9.5: Using the printf library function in the assembly block
Example 9.6: Using C++ functions atoi and printf within an assembly block
Example 9.7: Complex example of using the inline assembler

Chapter 10: Inline Assembler and Application Optimization. MMX and SSE Technologies

Example 10.1: Using pointers in a program that computes the sum of the floating-point array elements
Example 10.2: Looking for the maximum element in an integer array and displaying the result
Example 10.3: A fragment of a C++ program that searches for the maximum element
Example 10.4: The code of the disassembled for loop
Example 10.5: Fragment of a program that sorts an integer array and displays the result
Example 10.6: The code that sorts an integer array only with C++ statements
Example 10.7: The disassembled C++ code
Example 10.8: A check whether the processor supports MMX technology
Example 10.9: Adding two 8-byte sequences
Example 10.10: The disassembled fragment of code that adds two 8-byte arrays
Example 10.11: An assembly version of the program that adds 8-byte arrays
Example 10.12: The disassembled code of the asm block
Example 10.13: Pairwise addition of two integer arrays with common C++ statements
Example 10.14: Addition of two integer arrays with intrinsics
Example 10.15: An application that adds two integer arrays with 64-bit assembly commands
Example 10.16: Comparing two character strings with MMX extension intrinsics
Example 10.17: Comparing two 8-byte strings with MMX assembly instructions
Example 10.18: Comparing two strings by value with MMX assembly commands
Example 10.19: Searching for a character in a string with the pcmpeqb command
Example 10.20: Pairwise addition of positive integers stored in two arrays
Example 10.21: The use of the pmasw MMX command that compares elements of an integer array in pairs
Example 10.22: Comparing strings with the pxor MMX extension command
Example 10.23: Multiplying two integers with MMX extension intrinsics
Example 10.24: Multiplying two integers with the MMX extension assembly commands
Example 10.25: Finding the absolute value of an integer with the MMX extension assembly commands
Example 10.26: Checking the processor for the SSE extension support
Example 10.27: Checking the operating system for the SSE extension support
Example 10.28: Scalar addition of two floating-point numbers
Example 10.29: Adding elements of two arrays in parallel
Example 10.30: Subtracting the elements of floating-point arrays with the subps command
Example 10.31: A modified version of the application that subtracts the elements of arrays
Example 10.32: Parallel multiplication and division of SSE data
Example 10.33: Scalar multiplication and division with SSE extension assembly commands
Example 10.34: Using SSE extension intrinsics to compare array elements
Example 10.35: The disassembled code of SSE extension intrinsics
Example 10.36: A modified version of the application that compares array elements with SSE extension assembly commands
Example 10.37: Comparing two floating-point arrays for greater than/less than
Example 10.38: Comparing floating-point arrays with the comiss command
Example 10.39: Converting MMX integers to SSE floating-point numbers
Example 10.40: Converting SSE floating-point numbers to MMX integers
Example 10.41: Parallel extraction of the square root from floating-point packed numbers
Example 10.42: A search for the maximum and minimum element among pairs of floating-point packed numbers
Example 10.43: An onBnclicked handler that processes a cstring string with C++ .NET statements
Example 10.44: An assembly function that looks for and replaces characters in a cstring string
Example 10.45: The use of an assembly procedure for searching for and replacing characters in a CString string

Chapter 11: Optimizing Multimedia Applications with Assembly Language

Example 11.1: Using multithreading for scaling a vector and computing its length (in C++)
Example 11.2: A modified variant of the vector operations
Example 11.3: Using the MMX extension for vector operations

Chapter 12: Optimizing Multithread Applications with Assembly Language

Example 12.1: A three-thread application for counting the number of characters
Example 12.2: Performing mathematical operations in a two-thread application

Chapter 13: C++ Inline Assembler and Windows Time Functions

Example 13.1: Computing the time of execution of a for loop with C++ .NET statements
Example 13.2: Replacing the for loop with an assembly block
Example 13.3: Computing ten values of the sine with time intervals of 5 msec
Example 13.4: Using Windows system timers
Example 13.5: Using a callback function for handling a timer event
Example 13.6: Using a waitable timer for computing the maximum every 0.5 seconds
Example 13.7: A modified variant of the application that finds the maximum with a timeout function in the waitable timer

Chapter 14: Using Assembly Language for System Programming in Windows

Example 14.1: Copying files with character substitution
Example 14.2: Copying characters with the virtualAlloc function
Example 14.3: Converting a file mapped to the memory with the assembler

Chapter 15: Optimizing Procedure-Oriented Applications and System Services

Example 15.1: A procedure-oriented Windows application that computes the difference between two integers
Example 15.2: The FileWriter system service that looks for the maximum element in a binary file
Example 15.3: A program that tests a system service
Example 15.4: The source code of the CWServiceWinService class
Example 15.5: The source code of cw.dll


Visual C++ Optimization with Assembly Code
Visual C++ Optimization with Assembly Code
ISBN: 193176932X
EAN: 2147483647
Year: 2003
Pages: 50
Authors: Yury Magda

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