Question

So on my quest to jump into Assembly, I've "hlt"'d on one thing in this real mode binary..

This is preparing a stack from 9FB00->90000. The guide I was following assumed I had knowledge of segments and I was hoping I could get an explanation as to how 9000->90000.

 [BITS 16]
 [ORG 0x7C00]

 jmp 0x0:Start

 Start:
 cli
 ;<<<ZONE IN QUESTION>>>
 mov AX,0x9000
 mov SS,AX
 ;<<<ZONE IN QUESTION>>>
 mov SP,0xFB00
 sti

 cli
 hlt

 times 510 - ($ - $$) db 0 ;nasmgasm
 dw 0xAA55
Était-ce utile?

La solution

x86 registers in real mode include the normal set of processor registers, and an additional set of segment registers, all of which are 16 bits long. To extend the address space beyond 64kb the segment registers are offset 4 bits from the other address registers, and the final address is calculated by adding the address register (the Stack Pointer in your case) to the segment register (SS for your question)

Thus you get:

SS = 9000    ; offset 4 bits
SP =  FB00
     =====
     9FB00  ; Final address in actual memory space.

This is extended considerably once you leave real mode as 32-bit registers become available.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top