Hướng dẫn thực hành môn Kiến trúc máy tính & Hợp Ngữ - Lập trình NASM với visual studio 2010

4. Tạo project C++, đặt tên tùy ý, ví dụ NASM
5. Click phải vào tên project (ở đây là NASM)  Build Customizations Một cửa sổ xuất
hiện, check vào nasm  OK (nếu chưa thực hiện bước 3 thì không xuất hiện tùy chọn
nasm)
6. Thêm file asm vào project: click phải vào Source File của Project  Add  New Item 
Chọn C++ source file  Đặt tên với phần mở rộng .asm
(VD: NhapXuatChuoi.asm)  Add 
pdf 2 trang xuanthi 28/12/2022 1860
Bạn đang xem tài liệu "Hướng dẫn thực hành môn Kiến trúc máy tính & Hợp Ngữ - Lập trình NASM với visual studio 2010", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.

File đính kèm:

  • pdfhuong_dan_thuc_hanh_mon_kien_truc_may_tinh_hop_ngu_lap_trinh.pdf

Nội dung text: Hướng dẫn thực hành môn Kiến trúc máy tính & Hợp Ngữ - Lập trình NASM với visual studio 2010

  1. 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 .data ; Data section, initialized variables tb1: db "Moi nhap chuoi: ",0 tb2: db "Chuoi vua nhap la: %s",10,0 str: db 30 SECTION .text global _ NhapXuatChuoi ; the standard gcc entry point _ NhapXuatChuoi: ; the program label for the entry point push ebp ; set up stack frame mov ebp, esp ;Xuat tb1 push dword tb1 ; address of ctrl string call _printf ; Call C function add esp, 4 ; pop stack 3 push times 4 bytes ;Nhap chuoi luu vao str gets(str) push dword str call _gets add esp, 4 ;Xuat tb2 push dword str push dword tb2 ; address of ctrl string call _printf ; Call C function add esp, 8 ; pop stack 3 push times 4 bytes mov esp, ebp ; takedown stack frame pop ebp ; same as "leave" op xor eax, eax ; normal, no error, return value ret Nguồn: NASM Target File: Source tham khảo: