散100!有谁能帮我写成C?

虾猫先生 虾猫先生 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
以下有一个汇编写成的有关看门狗的例子,有哪位大侠可以写成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
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部
虾猫先生
C语言 70,040 成员 243,237 内容