So -> 0x0050:0 is the same as 0x500:0
Not quite.
0x0050:0 is the same as 0x500 absolute liner address, NOT 0x500:0.
0x50:0 is the seg:offset address, 0x500 is the
linear (Absolute) address.
0x500:0 is a seg:offset address representing 0x5000 absolute address, which is not what you want.
I am going to use the code that you got from the net for an example.
In this code:
Code: Select all
mov ax, 0x0100
mov es, ax ; destination for image
mov bx, 0x0000 ; destination for image
push bx
This is pointing to seg:offset address 0x100:0, which is 0x1000 (Absolute linear address.)
segment:offset addresses are different from absolute addresses.Lets look at the other code you posted from the net to complete the example...
Code: Select all
bits 16
org 0x0000
[SEGMENT .text]
mov ax, 0x0100
Remember that 0x100 is the
segment address using
segment:offset notation. So, this is 0x100:0.
Remembering the formula to convert this to an absolute address,
0x100:0 = 0x1000 (Linear address), NOT 0x1000:0.
Because this code is located at 0x1000 physical address, or (0x100:0 in seg:offset notation), all we need to do is insure that the segment registers are set to the segment to use (0x100)
The org directive is only needed to let the assembler know the base address. Because the code sets the segment registers during execution, the ORG can be 0.