TITLE prog5.asm .MODEL SMALL .STACK 100H .CODE SMBus_Port equ 5000h LM75_ID EQU 98h compu proc far start: jmp initialize public WaitSmbus WaitSmbus proc near push cx mov cx,100h @@: loop short @B pop cx ret WaitSmbus endp ;[]==============================================================[] ;Input : CL - register index ;Output : AX - Value read ;[]==============================================================[] Get_LM75_Word Proc Near push cx mov dx,SMBus_Port +04h mov al,(LM75_ID + 1) ;LM75 write ID out dx,al jmp $+2 jmp $+2 call Chk_SMBus_READY mov dl,03h pop ax out dx,al ;Index jmp $+2 jmp $+2 mov dl,02h mov al,4ch out dx,al ;write data jmp $+2 jmp $+2 xor cx,cx @@: jmp $+2 loop short @B call Chk_SMBus_READY mov dl,06 in al,dx ;Data1 jmp $+2 jmp $+2 mov ah,al mov dl,05 in al,dx ;Data0 jmp $+2 jmp $+2 ret Get_LM75_Word endp public Chk_SMBus_READY Chk_SMBus_READY Proc Near mov dx,SMBus_Port + 0 clc mov cx,0100h Chk_I2C_OK: in al,dx ;get status or al,al jz short Clear_final test al,04h jnz short SMBus_Err test al,01h ;busy ? jz short Not_Smbusy call WaitSmbus Not_Smbusy: out dx,al loop short Chk_I2C_OK SMBus_Err: out dx,al ;R04 jmp $+2 in al,dx ;get status ;R04 jmp $+2 test al,04h ;R04 jnz short SMBus_Err ;R04 stc Clear_final: ret Chk_SMBus_READY Endp timer_int proc far pushf push es push ax push bx push cx push si push di mov ah,02h ;read data per second int 1ah ; mov di,offset sectemp ; mov al,cs:[di] ;get second from sectemp mov byte ptr cs:[di],dh ;put new time(second) to sectemp cmp al,60h ;first time? je begin_go ;yes! go cmp al,dh ;same time(second)? je no_change ;yes! exit begin_go: mov ax,0b800h mov es,ax mov si,120 mov cx,string_len mov di,offset show_string @@: mov al,cs:[di] mov es:[si],al add si,2 inc di loop @B mov cl,0 call Get_LM75_Word cmp al,100 jbe short OK_75Temp mov al,0 OK_75Temp: xor ah,ah ; mov bl,0ah ;change Hex to BCP div bl ; xchg ah,al ; mov cl,4 ; shl ah,cl ; or al,ah ; call bcd_p mov al, 'ø' mov es:[si],al add si,2 mov al, 'C' mov es:[si],al add si,2 no_change: pop di pop si pop cx pop bx pop ax pop es popf iret timer_int endp show_string label byte db 'CPU TEMPERATURE ' string_len equ ($-offset show_string) sectemp db 60h ; bcd_p proc near mov ah,al mov cl,4 shr ah,cl add ah,30h mov es:[si],ah add si,2 and al,0fh add al,30h mov es:[si],al add si,2 ret bcd_p endp ; initialize: mov ax,0 mov ds,ax mov si,70h mov ax,cs mov dx,offset timer_int ;set interupt vector mov [si],dx mov [si+2],ax mov al,0 mov dx,300 mov ah,31h int 21h compu endp end