Using nasm with visual studio 2010

2 0 0
Using nasm with visual studio 2010

Đang tải... (xem toàn văn)

Thông tin tài liệu

KIẾN TRÚC MÁY TÍNH VÀ HỢP NGỮ lvlong@fit hcmus edu vn KIẾN TRÚC MÁY TÍNH VÀ HỢP NGỮ lvlong@fit hcmus edu vn LẬP TRÌNH NASM VỚI VISUAL STUDIO 2010 CÀI ĐẶT CẤU HÌNH NASM 1 Cài đặt NASM với đường dẫn C \[.]

KIẾN TRÚC MÁY TÍNH VÀ HỢP NGỮ lvlong@fit.hcmus.edu.vn LẬP TRÌNH NASM VỚI VISUAL STUDIO 2010 CÀI ĐẶT CẤU HÌNH NASM Cài đặt NASM với đường dẫn C:\nasm Thêm biến môi trường Path với đường dẫn C:\nasm Copy file target (nasm.prop,nasm.targets & nasm.xml) vào thư mục “C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\” nơi lưu file masm.tagets LẬP TRÌNH NASM VỚI VISUAL STUDIO 2010 Tạo project C++, đặt tên tùy ý, ví dụ NASM Click phải vào tên project (ở NASM)  Build Customizations Một cửa sổ xuất hiện, check vào nasm  OK (nếu chưa thực bước khơng xuất tùy chọn nasm) Thêm file asm vào project: click phải vào Source File Project  Add  New Item  Chọn C++ source file  Đặt tên với phần mở rộng asm (VD: NhapXuatChuoi.asm)  Add Thêm file cpp vào project: click phải vào Source File Project  Add  New Item  Chọn C++ source file  Đặt tên với phần mở rộng cpp (VD: main.cpp)  Add Add library “libcmt.lib” vào project: click phải vào Project NASM  Properties  Chọn thẻ Linker  Input  Thêm “libcmt.lib;” vào phần đầu mục the Additional Dependencies File main.cpp : #include #include extern "C" int NhapXuatChuoi(void); void main(void) { int x= NhapXuatChuoi(); getch(); } KIẾN TRÚC MÁY TÍNH VÀ HỢP NGỮ lvlong@fit.hcmus.edu.vn File NhapXuatChuoi.asm : Extern _printf extern _gets SECTION tb1: tb2: str: data ; Data section, initialized variables db "Moi nhap chuoi: ",0 db "Chuoi vua nhap la: %s",10,0 db 30 SECTION text global _ NhapXuatChuoi _ NhapXuatChuoi: push ebp mov ebp, esp ;Xuat tb1 push call add dword _printf esp, ; the standard gcc entry point ; the program label for the entry point ; set up stack frame tb1 ; address of ctrl string ; Call C function ; pop stack push times bytes ;Nhap push call add chuoi luu vao str gets(str) dword str _gets esp, ;Xuat push push call add tb2 dword dword _printf esp, mov pop xor ret eax, esp, ebp eax str tb2 ebp ; address of ctrl string ; Call C function ; pop stack push times bytes ; takedown stack frame ; same as "leave" op ; normal, no error, return value Nguồn: http://www.codeproject.com/Articles/410776/Integrating-a-compiler-assembler-in-VS-UsingNASM Target File: https://drive.google.com/file/d/0B5gBH5phXhhCWTNERXM5THZuU2c/edit?usp=sharing Source tham khảo: https://drive.google.com/file/d/0B5gBH5phXhhCTUttRGt4V3lCems/edit?usp=sharing

Ngày đăng: 08/04/2023, 06:22

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan