

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture handout was provided at Quaid-i-Azam University for Microprocessor and Assembly Language Programming course by Prof. Saleem Raza. Its main points are: Language, Functions, Convention, Pascal, Microprocessor, Interfacing, Registers, Return
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


int divide( int dividend, int divisor );
push dword [mydivisor]
push dword [mydividend] call _divide add esp, 8 ; EAX holds the answer
void swap( int* p1, int* p2 ) { int temp = *p1; *p1 = *p2; *p2 = temp; }
[section .text] extern _swap x: dd 4 y: dd 7
push dword y push dword x call _swap ; will only retain the specified registers add esp, 8
; swap generated by gcc with no optimizations (converted to Intel syntax) ; 15 instructions AND 13 memory accesses _swap: push ebp mov ebp, esp sub esp, 4 ; space created for temp
mov eax, [ebp+8] mov eax, [eax] mov [ebp-4], eax ; temp = *p
mov edx, [ebp+8] mov eax, [ebp+12] mov eax, [eax] mov [edx], eax ; *p1 = *p
mov edx, [ebp+12] mov eax, [ebp-4] mov [edx], eax ; *p2 = temp
leave ;;;;; EQUIVALENT TO mov esp, ebp AND pop ebp ;;;;; ret