The exact meaning of [offset someData] in assembly language -
my question offset in assembly language
i have written code below :(emu8086)
data segment data1 dw 6 data2 dw 5 ends stack segment dw 128 dup(0) ends code segment start: mov ax, data mov ds, ax mov es, ax mov bx, [offset data1] mov ax, [offset data2] mov ax, 4c00h ; exit operating system. int 21h ends end start ; set entry point , stop assembler.
i excepted when type [offset data1]
receive 6 , when type [offset data2]
receive 5.
my reason : offset
gives address of data , sign[]
give content of mentioned place of memory. when use [offset data1]
should receive data1 (here 6)
but result thing else. after running code ax 0006h , bx 0000h , can't understand why.
can please me understand meaning of [offset somedata]
?
i know basic i'm new in assembly.
thanks in advance attention
i tried assemble code tasm , received bx=0 , ax=2 expected:
cs:0000 b88f4e mov ax,4e8f cs:0003 8ed8 mov ds,ax cs:0005 8ec0 mov es,ax cs:0007 bb0000 mov bx,0000 cs:000a b80200 mov ax,0002 cs:000d b8004c mov ax,4c00 cs:0010 cd21 int 21
in assemblers, mov reg,variable load reg offset of variable , mov reg,[variable] variable contens. not case of masm, interprets mov reg,variable loading reg memory-variable contents , had explicitely write mov reg,offset variable load offset part of variable address. syntax mixed , business of used assembler whether parse mov reg,[offset variable] offset or contents or generate warning. omitt word offset if want load contents of datax. may have specify assume ds:data tell assembler have loaded ds register segment address.
Comments
Post a Comment