flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 12 Oct 2006, 01:59
I'll try to answer
First: It establishes the ORiGin, this means that all the code below it will have an origin offset of 7c00h in your case. Since your "JMP start" probably costs two bytes, message is at offset 7c02h. Note that changing the origin to another offset doesn't means that "message" will still referenceable because the boot code is loaded at a base address of 0:7c00h so if you set it wrong then your code will reference "message" wrong (for example setting ORG to 7c01h will reference the message starting from "o" instead of "L". The other parts are not affected by ORG because the JMPs and CALLs of your code all references the labels with IP-relative addresses instead of the absolute address. Second: In the context of that code (real mode-20 bits addresses) segments just establishes the base address to be added to the offset. This actually happens with protected mode too but in real mode the base address is calculated using the segment number instead of a base address defined in a descriptor referenced by the segment selector (or segment number in the case of real mode). The way it works is the following: Given a segment number and an offset, the segment number is multiplied by 16 (or shifted to the left 4 bits) which produces a 20-bit value, to that 20-bit value is then added the offset and with that you get the physical address. The last question: based on the above look how 0:600 is the same address than 60:0 (0 shl 4) + 600 = 600 (60 shl 4) + 0 = 600 + 0 = 0 Also look that segments overlaps every 16 bytes so 1:0 points to the same physical address than 0:10. To access to physical address 600h you can also use 50:100. Note that in real mode you can have only 16 segments without overlaping each other, so segment:offset pairs in the form of x000:xxxx where x is any hex value will never overlap. Hope that this helps [edit] Note that all the addresses here are specified in hex. [/edit] [edit2] BTW why do you use Code: done:
call load_os Code: done:
ret Note that since you called bios_print instead of JMPing to it, RET will cause the processor to execute the next instruction below the call to bios_print[/edit2] |
|||
![]() |
|
rhyno_dagreat 12 Oct 2006, 02:18
Thanks, and as far as the edit, I realized that
![]() |
|||
![]() |
|
rhyno_dagreat 12 Oct 2006, 02:20
I realized that too, that is old code though, from when I first started on my first ASM OS back a few months ago, so I was still pretty new.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.