Question
I am a bit lost here.
Just to confirm, our code, this bin, will be loaded at absolute address 0x7c0.
We change our code segment to 0x7c0 and start referring to everything with an origin of 0.
1) Does it mean 'ds' and 'es' point to a) absolute address 0x7c0 or b) 0x7c0 (where we are loaded, now referred as 0) + 0x7c0?
If it's a), overlapping the code segment and data segment address cannot cause problems?
2) The stack segment 'finishes' at 0x00 and at the top, the stack pointer starts at 0x7c00. Are the interrupts not within this range?
I think It would help to have a visual walkthrough of where all the things we learned get mapped at this point. Also, the use of '0x7c0' and '0x7c00' for many different things is confusing me; it seems like everything steps on each one's toes but at the same time both addresses are far away.
Thank you.
Answered by Daniel McCarthy
Instructor
Hello Oiliver,
Thanks for your question. I will be happy to assist. Theirs an assembly section at the end of this course that explains all your questions in a lot of detail I recommend watching it.
Whilst we are in real mode we have what is known as segment registers. These registers point to in memory the address multiplied by 16. So if the segment register is 0x7c0 it points to address 0x7c00.
Lets pretend the data segment is at 0x7c0. Then when accessing data such as mov byte [0x01], 30 you are moving decimal 30 into address 0x7c01 because the data segment is used. Depending on the instructions used determines which segment register is used. The interrupt vector table starts at absolute address 0x00, to access it set the data segment to address 0x00. Then all your offsets will offset from the interrupt vector table.
Does that make sense? Check the assembly catchup for sure as we have a lot of information in there.
Thanks,
Dan
Follow-up by Olivier Henley
Question author
Thank you Daniel. I already listened to the assembly catchup. Ok, I re-listened to episode 8. and now I get it ... except the stack segment at 0x00 * 16 = 0x000. Isn't there an overlap with the interrupt vector table "starts at absolute address 0x00"?
Thank you.
Follow-up by Olivier Henley
Question author
Ok I think I get it from episode 13. ss is set at 0x00 for convenience as we will be using it to move interrupt handlers and offset to the addresses of the interrupt vector tables. I suppose, if we were to let the stack grow, we would not allow it to grow over the interrupts range. Probably this will be more detailed as we move on.
Thank you.
Answered by Daniel McCarthy
Instructor
Sorry for the late reply Oliver my mother came to visit me for one month, I live abroad. I am back to work now. Did you find out what you are looking for or did you have any other question relating to this.
Follow-up by Olivier Henley
Question author
Hey Daniel! Hope you had a good time with your mom. :)
Yeah, everything is fine now. Thank you!
Answered by Daniel McCarthy
Instructor
Great yes we had a great time thanks :) Any more questions you know how to find me! For direct contact feel free to email at daniel@dragonzap.com or ask another question here.