我的学习之旅(42)asm.s

49 篇文章 0 订阅
49 篇文章 0 订阅

asm.s只要实现软、硬中断发生后的响应。代码主要模仿linux的asm.s实现。

asm.s:

-------------

.globl default_handle, timer_interrupt, restore_esp, system_call_interrupt /*全局变量*/

default_handle: /*中断发生后的默认处理*/
 call do_default_handle
 iret

.align 2
timer_interrupt:/*硬件定时器中断*/

/*保留当前所有的寄存器,保留现场*/

 push %ds
 push %es
 push %fs
 push %gs

 pushl %ebp  
 pushl %edi  
 pushl %esi 
 
 pushl %edx  
 pushl %ecx  
 pushl %ebx  
 pushl %eax


 incl jiffies/*刷新jiffies计数器并结束中断*/
 movb $0x020, %al
 outb %al, $0x20

/*esp保存在eax,并将eax值刷新到当前任务current->current_esp*/

 mov %esp, %eax
 call save_esp

/*调用定时器处理函数并做任务调度并将current指向新任务*/
 call do_timer

/*将curret->current_esp的值刷新到esp中*/
 call restore_esp
 mov %eax, %esp
 /*此时已经是新任务的esp了,可以恢复现场并中断返回了。*/
 popl %eax
 popl %ebx
 popl %ecx
 popl %edx

 popl %edi
 popl %esi
 popl %ebp

 pop %gs
 pop %fs
 pop %es
 pop %ds
 
 iret

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值