Warm tip: This article is reproduced from serverfault.com, please click

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

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

发布于 2020-12-16 18:48:53

我正在尝试读取可以在地址0000h:044Ch中找到的值1000h,并ax通过使用mov指令将其放入寄存器中每次我取回另一个值,比预期的1000h还多。

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

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

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

Questioner
Ahmed Crow
Viewed
11
Michael Petch 2020-12-17 03:27:54

你必须将一个段寄存器设置为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