散100!有谁能帮我写成C?
虾猫先生 2003-12-31 09:27:25 以下有一个汇编写成的有关看门狗的例子,有哪位大侠可以写成C?急用!谢谢!
1、解锁寄存器
2、设置INDEX 37H 的位 6 为"0"禁止看门狗定时器
3、设置INDEX 3BH,3AH,39H 为预期的定时计数值
4、设置INDEX 38H 位 7-4 选择超时所触发的事件
5、设置INDEX 37H 的位 6 为"1"使能看门狗定时器
6、锁定寄存器
设定定时值128秒,超时事件为系统复位System RESET
dosseg
.model small
.stack 100h
.code
main proc
mov ax 0c513h;Unlock config.register
call writechip
mov ax 03737h;Disable watchdog timer
call readchip
and al,10111111b
xchg ah,al
call writechip
mov ax,0403bh;Set the expected counter value
call writechip;to [400000h]
mov ax,0003ah;30.5*sec*400000h=128sec
call writechip
mov ax,00039h
call writechip
mov ax,03838h;Select"system reset"as timeout action
call readchip
and al,00001111b
or al,11010000b
xchg ah,al
call writechip
mov ax,03737h;Wnable watchdog timer
call readchip
or al,01000000b
xchg ah,al
call writechip
mov ax,00013h;Lock config.register
call writechip
mov ax,04c00h
int 21h
main endp
readchip proc
out 22h,al
nop
nop
in al,23h
nop
nop
ret
readchip endp
writechip proc
out 22h,al
nop
nop
xchg ah,al
out 23h,al
nop
nop
xchg ah,al
ret
writechip endp
end main