📄 spdich8.asm
字号:
include macro.inc
data segment
titl1 db 'Show Spd of Ram Module for ICH8',13,10
db ' ---fic/sw',13,10,'$'
ch0_spd db 13,10,'The Spd of Ram0 is: ',13,10,'$'
ch1_spd db 13,10,'The Spd of Ram1 is: ',13,10,'$'
lower_add db ' 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E OF',13,10
db 13,10
row0 db '00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row1 db '01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row2 db '02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row3 db '03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row4 db '04 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row5 db '05 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row6 db '06 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10
row7 db '07 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF',13,10,'$'
OEM_SMB_DEFAULT_IO DW ?
data ends
code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov ah,0
mov al,03
int 10h
lea dx,titl1
mov ah,09
int 21h
lea dx,ch0_spd
mov ah,09
int 21h
;===============================================================================================================
mov eax,8000FB04h ;Enable DEV#31,FUNC#3,REG#04h,BIT0
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in ax,dx
or ax,01h
out dx,ax
mov eax,8000FB40h ;Enable DEV#31,FUNC#3,REG#40h,BIT0
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in al,dx
or al,01h
out dx,al
;==============================================================================================================
mov eax,8000fb20h
mov dx,0cf8h
out dx,eax
mov dx,0cfch
in ax,dx
and ax,0ffe0h
mov OEM_SMB_DEFAULT_IO,ax
mov di,0A1H
SPDRead128Bty:
mov bx,0
mov cx,0
lea si,row0
SaveSpdData:
mov al,bl
call ReadSPD
call HexToAscii
ror dx,8
inc bx
add cx,3
xchg bx,cx
mov ds:[bx+si],dx
xchg bx,cx
cmp cx,48
jne SaveSpdData
add si,row1-row0
mov cx,0
cmp bx,128
jne SaveSpdData
SPDDrawTbl128Bty:
mov ah,09h
lea dx,lower_add
int 21h
cmp di,0A5H ; SPDII reading finish??
je main_exit
mov ah,09
lea dx,ch1_spd
int 21h
mov di,0A5H
jmp SPDRead128Bty
main_exit:
mov ah,4ch
int 21h
ret
main endp
;//////////////////////////////////////////////////////////////////
;ENTRY: di:SMB Device ADDRESS
; AL:SPD Register Index
;EXPORT: AL:the Register Data
;---- ReadSPD --------------------------------------------------------;
; ;
; Purpose: Reads a value from a Dimm module SPD offset ;
; ;
; Input: AL SPD offset to read from ;
; DI SMB Device ADDRESS
; ;
; Output: AL Value read ;
; C Carry set means error reading spd ;
; NC No carry means no error ;
; ;
; Uses: RET_MC, PUSH_MC, POP_MC macros ;
; ;
;-----------------------------------------------------------------------;
ReadSPD PROC NEAR
push ecx
PUSH edx ; preserve edx
xor ecx,ecx
loopecx:
loop loopecx
xchg ah, al ; save offset to read
mov dx, OEM_SMB_DEFAULT_IO ; Host Status Register (00)
mov al, 1Eh ; Clear all status bits
out dx, al
mov dx, OEM_SMB_DEFAULT_IO ; Host Command Register (03)
add dx,03
xchg ah, al ; restore al (offset to read)
out dx, al
or di, 1 ; Set Read Command
mov dx, OEM_SMB_DEFAULT_IO ; Host Address Register (04)
add dx,04
mov ax,di
out dx, al
mov dx, OEM_SMB_DEFAULT_IO ; Host Control Register (02)
add dx,02
mov al, 48h ; Read byte protocol and Start
out dx, al ; command
mov dx, OEM_SMB_DEFAULT_IO ; Host Status Register (00)
xor ecx,ecx
waitForDevErrororInterrupt:
in al, dx ; Read host status register
and al,0Fh
cmp al,02h
je readSPDOk ; Br if not done yet
loop waitForDevErrororInterrupt
readSPD_Err:
mov al,0ffh
stc ; carry set = SMBUS error
jmp readSPDDone
readSPDOk:
mov dx, OEM_SMB_DEFAULT_IO ; Host Data Register (05)
add dx,05
in al, dx ; (al) = SPD byte data
clc ; no carry means no error
readSPDDone:
POP edx ; restore edx
pop ecx
RET
ReadSPD ENDP
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -