Docsity

Linking Assembly Programs-Assembly Language Programming-Lab Slides, Slides of Assembly Language Programming

Partial preview of the text

Download Linking Assembly Programs-Assembly Language Programming-Lab Slides and more Slides Assembly Language Programming in PDF only on Docsity!

Linking C++ programs toAssembly Programs

  • Objective:– Write a Assembly procedure that can be calledfrom C++ code– Issues
    • How are arguments passed• How are result returned

Arguments passing

  • When a C function calls another functionthe arguments are Pushed onto stack inreverse order• E.g int FindArray(long searchVal, longaray[], long count)• Order is from right to left

[EBP+16]

Count [EBP+12]

[array] [EBP+08]

SearchVal [EBP+04]

Ret address EBP,ESP 

EBP

Linking to VC++ 6.

  • Assemble the assembly file using ml.exe• In MASM folder keep the .asm file andassemble using ml file.asm• Make a Win32 Console application projectin Microsoft visual C++ 6.0• Keep the object file of asm file in this folder• Rest in code files

Assignment

-^ Write procedure for the insertion sort in assemblylanguage.•^ Call this procedure from the C program so that theaddress of the array to be sorted and the number ofelements in array are arguments to the procedure (last slide). Array to be sorted is in C++ program.•^ Implement the sorting functionality in Assemblylanguage