Category : Assembly Language Source Code
Archive   : CMOSSAVE.ZIP
Filename : CMOSPUT.ASM

 
Output of file : CMOSPUT.ASM contained in archive : CMOSSAVE.ZIP
PAGE ,132 ; (CTRL-OH) IBM PC PRINTER CONDENSED MODE
TITLE CMOSPUT - WRITE CMOS DATA CREATED BY CMOSGET BACK TO CMOS MEMORY
; SYNTAX = CMOSPUT < CMOS.DAT
CSEG SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CSEG,DS:CSEG,SS:CSEG,ES:CSEG ;ALREADY SET BY DOS LOADER

ORG 100H ;COM FILE FORMAT, SKIP TO END OF THE PSP

CMOS_ADR EQU 70H ;ADDRESS PORT OF CMOS
CMOS_DATA EQU 71H ;DATA PORT OF CMOS
NUM_BYTES EQU 64 ;NUMBER OF BYTES IN CMOS

MAIN PROC NEAR

MOV CX,NUM_BYTES ;NUMBER OF CMOS BYTES

GET_NEXT_BYTE:

MOV AH,7 ;KEYBOARD INPUT W/O ECHO
INT 21H ; THRU DOS
MOV AH,AL ;SAVE BYTE IN AH

MOV AL,NUM_BYTES ;CALCULATE
SUB AL,CL ; BYTE TO FETCH
CLI ;NO INTERRUPTS
OUT CMOS_ADR,AL ;ASK FOR THIS BYTE
JMP SHORT $+2 ;DELAY FOR SLOW OUTPUT PORTS
MOV AL,AH ;GET SAVED BYTE IN AH
OUT CMOS_DATA,AL ;SAY THIS BYTE IS COMING
STI ;ALLOW INTERRUPTS
LOOP GET_NEXT_BYTE ;REPEAT UNTIL DONE

; UPDATE TIME AND DATE. dOS GIVES VALUES IN HEX. CMOS STORES DATA
; IN BCD. PERFORM THE TRANSFORMATION AND UPDATE CMOS WITH A BIOS CALL.

MOV AH,2CH ;GET TIME FN
INT 21H ; THRU DOS

CALL HEX2BCD ;CONVERT CH,CL,DH,DL TO BCD

MOV AH,3 ;SET REALTIME CLOCK FN
MOV DL,0 ;0=NORMAL TIME
INT 1AH ; THRU AT BIOS

MOV AH,2AH ;GET DATE FN
INT 21H ; THRU DOS

MOV AX,CX ;CONVERT YEAR TO
MOV CL,100 ; CENTURY:YEAR FORMAT
DIV CL ;AH=YEAR, AL=CENTURY
XCHG AH,CL ;FIX ORDER

MOV CX,AX ;PREPARE FOR CONVERSION

CALL HEX2BCD ;TRANSFORM CX, DX TO BCD

MOV AH,5 ;SET REALTIME DATE FN
INT 1AH ; THRU AT BIOS

RET ;NEAR RETURN TO DOS
MAIN ENDP

; CONVERT CH,CL,DH,DL FROM HEX TO BCD REPRESENTATION

HEX2BCD PROC NEAR

PUSH CX ;SAVE REGISTER ON STACK
MOV AX,DX ;CONVERT DX FIRST
CALL HB_1 ;PERFORM 1ST CONVERSION
MOV DX,AX ;RETURN TO DX
POP AX ;GET 2ND ARG FROM STACK

HB_1:

MOV CX,0AH ;SET CH=0, CL=A (10)
XCHG AH,CH ;SET AH=0, SAVE HIGH BYTE
DIV CL ;QUOTIENT IN AL, REM IN AH
MOV CL,4
SHL AL,CL ;CONVERT TO BCD

OR AL,AH ; AND COMBINE
XCHG AL,CH ;SAVE

XOR AH,AH ;ZERO NUMERATOR HIGH BYTE
MOV CL,0AH ;
DIV CL ;DIVIDE BY 10
MOV CL,4
SHL AL,CL ;CONVERT TO BCD

OR AH,AL ;
MOV AL,CH ;FULL RESULT IN AX
MOV CX,AX ; AND CX

RET
HEX2BCD ENDP

CSEG ENDS
END MAIN


  3 Responses to “Category : Assembly Language Source Code
Archive   : CMOSSAVE.ZIP
Filename : CMOSPUT.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/