Skip to content

Instantly share code, notes, and snippets.

@majioa
Created January 24, 2013 11:00
Show Gist options
  • Save majioa/4620037 to your computer and use it in GitHub Desktop.
Save majioa/4620037 to your computer and use it in GitHub Desktop.
Sample CMOS utils for DOS. They allows to write and read PC CMOS.
.MODEL SMALL
COD SEGMENT PARA
ASSUME CS:COD,DS:COD
ORG 100H
START:
XOR AX,AX
MOV CX,256
LEA DI,BUF
PUSH CS
PUSH CS
POP DS
POP ES
CMOS1:
MOV AL,AH
OUT 70H,AL
JMP $+2
IN AL,71H
STOSB
INC AH
LOOP CMOS1
LEA SI,FNAME
LEA DX,BUF
MOV CX,256
XOR BX,BX
CALL SAVE_FILE
MOV AX,4C00H
INT 21H
INCLUDE ..\..\LIBRARY\FILE\SAVEFILE.LIB
FNAME DB 'CMOS.DAT',0
BUF DB 64 DUP (0)
ENDS
END START
.MODEL SMALL
COD SEGMENT PARA
ASSUME CS:COD,DS:COD
ORG 100H
START:
PUSH CS
PUSH CS
POP DS
POP ES
LEA SI,FNAME
LEA DX,BUF
MOV CX,256
XOR BX,BX
CALL LOAD_FILE
CALL SET_CONTROL_SUMM
CALL COPY_UP
XOR AX,AX
MOV CX,256
LEA SI,BUF
CMOS1:
MOV AL,AH
OUT 70H,AL
JMP $+2
LODSB
OUT 71H,AL
INC AH
LOOP CMOS1
MOV AX,4C00H
INT 21H
SET_CONTROL_SUMM PROC
XOR AX,AX
MOV DX,AX
LEA SI,BUF+10H
MOV CX,1EH
SET_CONTROL_SUMM_1:
LODSB
ADD DX,AX
LOOP SET_CONTROL_SUMM_1
MOV AX,DX
XCHG AL,AH
MOV WORD PTR DS:[2EH+BUF],AX
RET
ENDP
COPY_UP PROC
LEA SI,BUF
LEA DI,BUF+80H
MOV CX,80H
REP MOVSB
RET
ENDP
INCLUDE ..\..\LIBRARY\FILE\LOADFILE.LIB
FNAME DB 'CMOS.DAT',0
BUF:
ENDS
END START
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment