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

Prof. Abhay Aggrawal delivered this lecture at Birla Institute of Technology and Science for lab of Assembly Language Programming. It includes: Assembly, MASM, Insertion, Assignment, Sorted, Arguments, Procedure, Sorting, Assembly, Language

Typology: Slides

2011/2012

Uploaded on 07/26/2012

parina
parina 🇮🇳

4.4

(67)

222 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Linking C++ programs to
Assembly Programs
Objective:
Write a Assembly procedure that can be called
from C++ code
Issues
How are arguments passed
How are result returned
docsity.com
pf3
pf4
pf5

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