The MASM Forum

Microsoft 64 bit MASM => MASM64 SDK => Topic started by: stevenxie on November 15, 2020, 01:00:00 AM

Title: loop of the messagebox
Post by: stevenxie on November 15, 2020, 01:00:00 AM
hi,all boys and girls.
this is a loop of the messagebox.it  will show  next to  5 messageboxes constandly. In the source code, note. while .endw,. if .endif,{},{= and other advanced grammar application structure points.

        ; -------------------------------------------------------------------------
   
         ;include \masm32\include64\invoke.inc

          include \masm32\include64\masm64rt.inc

        ; -------------------------------------------------------------------------
        .data

          szDlgTitle    db "Minimum MASM--最小的对话框", 0
          szMsg         db "  --- 64 Bit Assembler Pure and Simple ---  ", 0

        .code
   
        entry_point proc
   
        ;jmp @F
        ;szDlgTitle    db "Minimum MASM--最小的对话框", 0
        ;szMsg         db "  --- 64 Bit Assembler Pure and Simple ---  ", 0
        ;@@:


        LOCAL .rcx:qword
       
       ;=================================================================
       ;= ;xor rcx, rcx
       ;= ;lea rdx, szMsg
       ;= ;lea r8, szDlgTitle
       ;= ;mov r9, MB_OK
       ;= ;call MessageBox
       ;= ;xor rcx, rcx
       ;= call ExitProcess
       ;==================================================================
        ; --------------------------------------------------------
        ; The following are the same function calls using MASM
        ; "invoke" syntaxa and "rcall" syntaxa. It is clearer code, it is not type checked
        ; against a function prototype and it is not less error prone. :P
        ; --------------------------------------------------------

       ; LOCAL .rcx:qword       

          mov bx,1

         ;请使用rax,rbx,al,bl,ax,bx,r10,r11,r12,r13,r14,r15等寄存器做条件判断和循环计数器,我们会看到不同的程序运行结果,这就深刻认识了CPU的工作机制和WIN64的调用约定。除了rbx,bx,bl,r12,r13,r14,r15做计数器外,
         ;其他的寄存器做计数器,程序都陷入死循环。对话框消息无限制循环下去。

         .while bx {= 10
         
              .if bx } 5
                  .exit
              .endif
              rcall MessageBox,0,"=====MASM64 Pure and Simple!!!======="," UI Template",MB_OK
              xor rcx, rcx
              lea rdx, szMsg
              lea r8, szDlgTitle
              mov r9, MB_OK

              call MessageBox

              add bx,1
   
   
         .endw

         .exit


         entry_point endp
   
        end