segments and NASM help again

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
_mark

segments and NASM help again

Post by _mark »

OK - my boot sector get loaded 0x7C00.

Question 1:
CS:0x200 is the end of the running boot loader. Right? If not, what is it?

Question 2:
How do I access memory just after the boot loader. I have been trying to do the equivelent of the following pseudo code:
BX = CS:0x200 + [offset]
where offset is a 16 bit number I have defined, but I'm still trying to come up to speed on ASM and the syntax is getting me.

Can anyone help me out?
Thanks
_mark()
_mark

Re:segments and NASM help again

Post by _mark »

never mind...I seem to have it working. ;)
_mark

Re:segments and NASM help again

Post by _mark »

One last question if I may, then things should be working...

      MOV      BX, [koff]
      MOV      AX, [kseg]
;      JMP      AX:BX
      JMP      0800:0000
      HLT

How can I jump to the kernel at [kseg]:[koff]. I have
tried numerous things, but I cannot seem to land on the right way to do it?


Thanks
_mark()
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:segments and NASM help again

Post by Pype.Clicker »

check the instruction set in the documentations coming with NASM.

What you probably want is something like

farptr:
   dd k_offset
   dw k_segment

jmp [farptr]
_mark

Re:segments and NASM help again

Post by _mark »

Great, that is the syntax I was looking for. Now just one question about your example. Why is it you have the offset 4 bytes and the segment second. I would have expect to see both 16 bit values with the segment first:

farptr:
DD kseg
DD koff

My code is a boot loader running in real-mode.

Thanks
_mark
_mark

Re:segments and NASM help again

Post by _mark »

by trial and error, it seems like the offset does come first. Anyone know the reason for that, it seems backwards to me.

BTW:
From the manual I found that:
JMP FAR WORD [kernel]
was not required, but made it more clear to me that it was 16 bit.

Mark
Post Reply