Thanks, yes the conceptions is known to me, but to be honest I got confused. However, I have uptated the loader, since then, and now I load it on 0000:8000h, where the ORG of the second part is 8000h.
Yes the bootloader gave a bunch of bugs, which ate me yesterday, but I find the solution after all. The code for second stage, was also incomplete, due to the time of posting. However I solve this and the next furious problem with entering protected mode (processor-flag+GDT), which one was because of corrupted GDT - the access part of the Data Descriptor (executable bit) was saying it was another code selector.
I am still confused with these segment pointers, cs, ds, es, ss. However I know their purpose, but I got lost within the meaning, and thanks to this:
if you set org=0, and DS = 1000, you are using absolute address 1_0000 (65536 decimal)
if you set org=1000 and DS = 0, you are using absolute address 0_1000 (4096 decimal)
I think I got the link in between (segment pointer after all), with the offset, it got sense.
I forgot for the 4 bit offset, which of couse lead me to wrong usage of the segmentation, and the wrong questions, which ate my day.
For the bp, sp and ss, I am still suspicious. I know that by defining bp and sp I would define the bottom of the stack and the upper limit, ie the stack bounds. But, how ss is related to the sp? As I understand the principle:
First I have to reserve a space in memory for the stack, so SS would point the segment of the area where is the stack (currently it would be on the same segment 0h for 0000:8000h). Then for base (BP) I point the address of that space and SP will contain the upper corner i.e. the stack size (or it was the base + stacksize?).
However I did not set up a stack in stage 2. Would it be a problem, as far as I know it should be, however in some of the includes (including a lot of new ones) I have push/pop, but it is working normally both 16 and 32bit?
For the 32bit I have moved the ESP to 90000h, which is far away from the current location... while SS is 0x10 (the address of the data segment).
I have listened to your advice and I have commented the lines for the setup of the segment registers, all of them, because now I use the 0000:8000h and they sould be all the same, right?
Thank you for your post and explanation
Off topic:
However, I am glad for the excercises I have played. They say, the experience is comming with the bad decisions, whereas good decisions come with experience...
So for other people entered in such black hole area, I would suggest not to quit, but to keep thinking, inspecting and analyzing (keep trying), its not unresolvable.