Thank you very much.
But I just have a few little things to clear up
The only difference is code readability - "mov si,packet" loads the address of a structure into SI, while "mov si,sizeofpacket" loads the address of the first field in the structure into SI. In practice it's exactly the same address.
Correct me if I am wrong but isn't the address of a structure the address of the first element in that structure. Kind of like an array is a pointer to the first element.
Also in your last example
what happens if you had something that wasn't just preprossor directive ...etc etc stuff
like
Code: Select all
label:
mov ax , ax ;
xor dx , dx
jmp label
So this is like a jmp a few bytes back (I forget how many bytes those 2 instructions would be but something like jmp (address of jmp - 4)
So when you have code between a label declaration the lable is the address of mov ax , ax.
Yes/No ? And if you did jmp label + 4 it would jump back to the jmp command.
So what I am getting down to is when you declare a label that get's compiled to the address of the next instruction after it.
And a varable is nothing more then a label. So it would stand to reason if I did
Code: Select all
jmp start
myvar db '1'
start:
jmp myvar
Which would jump to myvar and if it was bits 16 would try to execute an instruction
that was 00000001 , first 8 bits of my jump command. And probably crash because it is not a valid instruction.
But the point is you can jmp to varables just as you can jump to labels. yes/no ?
And the scheme for the address of a label is the same as the scheme for the address of a variable. So what is the difference between varables as opposed to label's? I would say you can still have
var db EF , 90
jmp var
which var in this case is an address of a vaild instruction so the cpu would process the instruction after the jump to that instruction EF 90.
So if their is anything I am misunderstanding let me know.
But
Code: Select all
var1 db 0
;same as
var2: db 0
mov ax , [var1]
;same as
mov ax , [var2]
So we have to things that are the same.
correct me if I am wrong but
[var1]
[var2] ;are the values at the memory address of var1 , and var2
var1
var2 ; are the memory addresses of var1 and var2
And the segment data key line
is the same type of thing like a label
because
Code: Select all
mov ax , data ;moves the address of the data segment which I think is the address of the first varable in the data segment?