; CIS-261 ; Week06demo.asm ; @topic W060101 Examples of DATA segment values and MOV instructions ; @brief MOV instruction uses EBX register as data placeholder or an address pointing to memory .386 ; Tells MASM to use Intel 80386 instruction set. .MODEL FLAT ; Flat memory model option casemap:none ; Treat labels as case-sensitive .CONST ; Constant data segment .STACK 100h ; (default is 1-kilobyte stack) .DATA ; Begin initialized data segment mydata BYTE 10, 20, 30, 40, 50 ; array of five bytes shortval WORD 111, 222, 333 table1 DWORD 20 DUP (?) status BYTE 7 DUP (0) intval DWORD 77778888h .CODE ; Begin code segment _main PROC ; Beginning of code mov [intval], 11112222h ; store value 11112222h in memory pointed by label intval mov EBX, intval ; get value at intval and put it in EBX mov EBX, [intval] ; same as above -- and strongly preferred syntax mov EBX, OFFSET intval ; load "address of" intval into EBX mov DWORD PTR [EBX], 33334444h ; use EBX as memory address and store 789 there ret _main ENDP END _main ; Marks the end of the module and sets the program entry point label In Visual Studio immediate window: ? intval ; this prints the value at memory location of intval 2004322440 ; this is 77778888h ? &intval ; this prints the address 0x01344062 intval ; this is what it prints