如何从 Bios 数据区中的地址正确读取值?

How I can read a value from an address in the Bios Data Area correctly?

我正在尝试读取地址 0000h:044Ch 中的值 1000h,并使用 mov 指令将其放入 ax 寄存器中。每次我得到一个不同于预期 1000h 的值。

这是我在 TASM 中使用的指令:

mov     ax, [word ptr 0000h:044Ch] 

我已经在调试器中检查了 ax 中的值。

您必须将其中一个段寄存器设置为 0x0000,然后通过该段寄存器访问偏移量 044ch 处的字。这样的事情应该有效:

xor ax, ax         ; XOR register with itself same as setting register to 0
mov es, ax         ; ES = 0
mov ax, [es:044ch] ; Get size of text video page of current display mode in bytes
; AX now has the 16-bit WORD value at 0000h:044ch

shr ax, 4          ; Divide by 16 to get size in paragraphs
add ax, 0b800h     ; Add to the base of text video memory segment to get page 1 segment

; Then you can put AX in a segment like ES to access text video memory
mov es, ax         ; ES = segment of page 1 of current text video mode