;;; ================================================================== ;;; programme d'exemple avec utilisation de macro et structure ;;; de donnees ;;; Jean-Michel RICHER ;;; ================================================================== ;;; compilation ;;; nasm -f elf exemple_macro_et_struc.asm ;;; gcc -o exemple_macro_et_struc.exe exemple_macro_et_struc.o ;;; global main extern printf ;;; inclusion du fichiers de macros %include "nasm_macros.asm" ;;; ================================================================== ;;; section de donnees ;;; ================================================================== section .data msg db "%s was born in %d", 10, 0 ;;; definition d'une structure Person struc Person name: resb 32 ; nom sur 32 octets year: resd 1 ; annee de naissance endstruc ;;; definition d'une instance jm_richer: istruc Person at name, db 'jean-michel richer' db 0 at year, dd 1970 iend ;;; definition d'une autre instance c_schiffer: istruc Person at name, db 'claudia schiffer' db 0 at year, dd 1970 iend ;;; ================================================================== section .text ;;; ================================================================== ;;; sous-programme pour l'affichage d'une personne ;;; void print_person(Person *p) ;;; %define print_person_p ARG_1 proc print_person mov ebx,print_person_p mov eax,[ebx+year] push eax lea eax,[ebx+name] push eax push dword msg call printf endproc ;;; sous-programme principal proc main pushad mov eax,dword jm_richer push eax call print_person add esp,4 mov eax,dword c_schiffer push eax call print_person add esp,4 popad xor eax,eax endproc