TITLE Mov instruction examples (mov_ex.asm) ; Program Description: move insruction examples ; Author: Christopher Young ; Date Created: 9/23/2003 ; Last Modification Date: ;********************************************************************* ; include files ;********************************************************************* INCLUDE Irvine32.inc ;********************************************************************* ; (insert symbol definitions here) ;********************************************************************* ;********************************************************************* ;Data section: Variables, initialized arrays, etc... ;********************************************************************* ; initialized data .data ;Use of label directive var1_8 LABEL BYTE var1_16 LABEL WORD var1_32 LABEL DWORD var1 BYTE 12h,34h,56h,78h var2 BYTE 0AAh,00h,00h,10h var3_32 LABEL DWORD var3 WORD 1234h,5678h ; unitialized data .data? var4 BYTE 100 dup(?) ; reserve 100 bytes of space ;********************************************************************* ; Code section ;********************************************************************* .code main PROC ; Insert executable instructions here: ; ; zero the registers we will be using ; mov eax, 0 ; mov ebx, 0 ; mov ecx, 0 ; mov edx, 0 ; call DumpRegs ; verify these are zero ; ; ; The assembler does typechecking on the variables (nice) ; ; to overide this, use PTR before the variable name. ; ; mov al,var1 ; mov bx,WORD PTR var1 ; mov ecx,DWORD PTR var1 ; mov dx,var3 ; ; call DumpRegs ; display register contents. ; ; ; zero the registers we will be using ; mov eax, 0 ; mov ebx, 0 ; mov ecx, 0 ; mov edx, 0 ; call DumpRegs ; verify these are zero ; ; ; Alternately we could label our data differently ; mov al,[var1_8+1] ; mov bx,[var1_16+1] ; mov ecx,[var1_32+1] ; mov edx,[var3_32+1] ; call DumpRegs ; verify these are zero ; ; ; movzx (move zero extend) ; ; zero the registers we will be using ; mov eax, 0 ; mov ebx, 99999999h ; mov ecx, 0 ; mov edx, 0 ; call DumpRegs ; verify these are zero ; ; mov ax, 0AB7Dh ; movsx ebx, al ; 8 to 32 bits ; ; call DumpRegs ; verify these are zero ; movsx (move sign extend) ; Indirect operands & use of the OFFSET directive. ; zero the registers we will be using mov eax, 0 mov ebx, 0 mov ecx, 0 mov edx, 0 call DumpRegs ; display register contents. ; try edx for an indirect read/write of memory mov edx, OFFSET var1 ;edx points to var1 (within the data segment) mov eax,[edx] ;read memory where edx points mov bx,[edx] mov cl,[edx] call DumpRegs ; display register contents. exit ; exit to operating system main ENDP ;********************************************************************* ; END OF CODE ;********************************************************************* END main