#  head.s contains the -bit startup code.
# Two L3 task multitasking. The code of tasks are in kernel area,
# just like the Linux. The kernel code is located at 0x10000.
SCRN_SEL = 0x18
TSS0_SEL = 0x20
LDT0_SEL = 0x28
TSS1_SEL = 0X30
LDT1_SEL = 0x38 .text
startup_32:
movl $0x10,%eax
mov %ax,%ds
# mov %ax,%es
lss init_stack,%esp # setup base fields of descriptors.
call setup_idt
call setup_gdt
movl $0x10,%eax # reload all the segment registers
mov %ax,%ds # after changing gdt.
mov %ax,%es
mov %ax,%fs
mov %ax,%gs
lss init_stack,%esp # setup up timer chip.
movb $0x36, %al
movl $0x43, %edx
outb %al, %dx
movl $, %eax # timer frequency HZ
movl $0x40, %edx
outb %al, %dx
movb %ah, %al
outb %al, %dx # setup timer & system call interrupt descriptors.
movl $0x00080000, %eax
movw $timer_interrupt, %ax
movw $0x8E00, %dx
movl $0x08, %ecx # The PC default timer int.
lea idt(,%ecx,), %esi
movl %eax,(%esi)
movl %edx,(%esi)
movw $system_interrupt, %ax
movw $0xef00, %dx
movl $0x80, %ecx
lea idt(,%ecx,), %esi
movl %eax,(%esi)
movl %edx,(%esi) # unmask the timer interrupt.
# movl $0x21, %edx
# inb %dx, %al
# andb $0xfe, %al
# outb %al, %dx # Move to user mode (task )
pushfl
andl $0xffffbfff, (%esp)
popfl
movl $TSS0_SEL, %eax
ltr %ax
movl $LDT0_SEL, %eax
lldt %ax
movl $, current
sti
pushl $0x17
pushl $init_stack
pushfl
pushl $0x0f
pushl $task0
iret /****************************************/
setup_gdt:
lgdt lgdt_opcode
ret setup_idt:
lea ignore_int,%edx
movl $0x00080000,%eax
movw %dx,%ax /* selector = 0x0008 = cs */
movw $0x8E00,%dx /* interrupt gate - dpl=, present */
lea idt,%edi
mov $,%ecx
rp_sidt:
movl %eax,(%edi)
movl %edx,(%edi)
addl $,%edi
dec %ecx
jne rp_sidt
lidt lidt_opcode
ret # -----------------------------------
write_char:
push %gs
pushl %ebx
# pushl %eax
mov $SCRN_SEL, %ebx
mov %bx, %gs
movl scr_loc, %bx
shl $, %ebx
movb %al, %gs:(%ebx)
shr $, %ebx
incl %ebx
cmpl $, %ebx
jb 1f
movl $, %ebx
: movl %ebx, scr_loc
# popl %eax
popl %ebx
pop %gs
ret /***********************************************/
/* This is the default interrupt "handler" :-) */
.align
ignore_int:
push %ds
pushl %eax
movl $0x10, %eax
mov %ax, %ds
movl $, %eax /* print 'C' */
call write_char
popl %eax
pop %ds
iret /* Timer interrupt handler */
.align
timer_interrupt:
push %ds
pushl %eax
movl $0x10, %eax
mov %ax, %ds
movb $0x20, %al
outb %al, $0x20
movl $, %eax
cmpl %eax, current
je 1f
movl %eax, current
ljmp $TSS1_SEL, $
jmp 2f
: movl $, current
ljmp $TSS0_SEL, $
: popl %eax
pop %ds
iret /* system call handler */
.align
system_interrupt:
push %ds
pushl %edx
pushl %ecx
pushl %ebx
pushl %eax
movl $0x10, %edx
mov %dx, %ds
call write_char
popl %eax
popl %ebx
popl %ecx
popl %edx
pop %ds
iret /*********************************************/
current:.long
scr_loc:.long .align
lidt_opcode:
.word *- # idt contains entries
.long idt # This will be rewrite by code.
lgdt_opcode:
.word (end_gdt-gdt)- # so does gdt
.long gdt # This will be rewrite by code. .align
idt: .fill ,, # idt is uninitialized gdt: .quad 0x0000000000000000 /* NULL descriptor */
.quad 0x00c09a00000007ff /* 8Mb 0x08, base = 0x00000 */
.quad 0x00c09200000007ff /* 8Mb 0x10 */
.quad 0x00c0920b80000002 /* screen 0x18 - for display */ .word 0x0068, tss0, 0xe900, 0x0 # TSS0 descr 0x20
.word 0x0040, ldt0, 0xe200, 0x0 # LDT0 descr 0x28
.word 0x0068, tss1, 0xe900, 0x0 # TSS1 descr 0x30
.word 0x0040, ldt1, 0xe200, 0x0 # LDT1 descr 0x38
end_gdt:
.fill ,,
init_stack: # Will be used as user stack for task0.
.long init_stack
.word 0x10 /*************************************/
.align
ldt0: .quad 0x0000000000000000
.quad 0x00c0fa00000003ff # 0x0f, base = 0x00000
.quad 0x00c0f200000003ff # 0x17 tss0: .long /* back link */
.long krn_stk0, 0x10 /* esp0, ss0 */
.long , , , , /* esp1, ss1, esp2, ss2, cr3 */
.long , , , , /* eip, eflags, eax, ecx, edx */
.long , , , , /* ebx esp, ebp, esi, edi */
.long , , , , , /* es, cs, ss, ds, fs, gs */
.long LDT0_SEL, 0x8000000 /* ldt, trace bitmap */ .fill ,,
krn_stk0:
# .long /************************************/
.align
ldt1: .quad 0x0000000000000000
.quad 0x00c0fa00000003ff # 0x0f, base = 0x00000
.quad 0x00c0f200000003ff # 0x17 tss1: .long /* back link */
.long krn_stk1, 0x10 /* esp0, ss0 */
.long , , , , /* esp1, ss1, esp2, ss2, cr3 */
.long task1, 0x200 /* eip, eflags */
.long , , , /* eax, ecx, edx, ebx */
.long usr_stk1, , , /* esp, ebp, esi, edi */
.long 0x17,0x0f,0x17,0x17,0x17,0x17 /* es, cs, ss, ds, fs, gs */
.long LDT1_SEL, 0x8000000 /* ldt, trace bitmap */ .fill ,,
krn_stk1: /************************************/
task0:
movl $0x17, %eax
movw %ax, %ds
movl $, %al /* print 'A' */
int $0x80
movl $0xfff, %ecx
: loop 1b
jmp task0 task1:
movl $0x17, %eax
movw %ax, %ds
movl $, %al /* print 'B' */
int $0x80
movl $0xfff, %ecx
: loop 1b
jmp task1 .fill ,,
usr_stk1:

C

0.00-050613_head.s的更多相关文章

  1. cxGRID中的字段怎么能以0.00的格式显示

    CXGRID中的字段如何能以0.00的格式显示在CXGRID中如何让字段能以0.00的格式显示,我的字段是FLOAT类型,满意的马上给分! ------解决方案-------------------- ...

  2. decimalFormat("#","##0.00") java

    importjava.text.DecimalFormat; publicclassTestNumberFormat{ publicstaticvoidmain(String[]args){ doub ...

  3. 基于python做的抓图程序1.0.00版本

    #coding=gbkimport urllibimport urllib2import reimport osimport time# import readline def getHtml(url ...

  4. SQL获取前一天0:00:00至23:59:59数据

    一.前言 因为我公司要做财务结算前一天0:00:00至23:59:59的数据,利用到动态拼接SQL语句 我们需要明白声明DateTime 和 Date 获取的时间格式是不一样的,所以通过此计算有利于得 ...

  5. ToString(“N2”)和ToString(“0.00”)之间的区别

    看来N会包含数千个分隔符,而0.00则不会. N2将以500.00的方式工作,但是当您有5000.00时,N2将显示为 5,000.00 代替 5000.00 If you do this inste ...

  6. 求一元二次方程的根【double型的0输出%.2lf为-0.00】

    #include <bits/stdc++.h> using namespace std; #define LL long long #define eps 1e-6 int main() ...

  7. decimal.ToString("#0.00")与decimal.ToString("#.##")的区别

    decimal decTemp = 2.1m; Console.WriteLine(decTemp.ToString("#0.00")); //输出2.10 Console.Wri ...

  8. php如何判断 0.0/0.00/0.000 是否为空? 测试过用empty函数不行

    if ( (int) $number == 0) echo 'empty'; if ( floatval($number) == 0 ) echo 'empty' 首先,PHP 认为 0.0 是空,同 ...

  9. vue中的金额格式0.00 和 后台返回时间格式带T调整正常格式

    <template> <div class="consumption"> <p>{{payTime|Time}}</p> <p ...

  10. 一元三次方程 double输出 -0.00

    求一个 a*x*x*x+b*x*x+c*x+d 的解 题目很简单,但是我输出了-0.00,然后就一直卡着,这个问题以后要注意. 让0.00 编程-0.00的方法有很多. 第一种就是直接特判 if(fa ...

随机推荐

  1. 巨蟒python全栈开发django13:中间件部分

    1.回顾昨日内容 2.session认证装饰器 3.django整个流程 4.中间件简单应用 5.简单统计访问次数 6.中间件其他方法 7.orm单表内容回顾

  2. Java基础 - 获取键盘输入

    package com.demo3; import java.util.Scanner; /* * 使用 Scanner 获取键盘输入供程序使用 * * 使用步骤: * A:导包 * import j ...

  3. 从“关于Java堆与栈的思考”一帖看错误信息的传播

    我对转贴的信息一直有敌意,原因如下:首先,除了制造更多的信息垃圾,转贴不会带来新的价值,想收藏的话一个链接足矣:其次,将错误信息以讹传讹,混淆视听.不妨选一个典型的例子说明一二. 相信<关于Ja ...

  4. AGS Server10.1中地图文档更新如何使服务更新

    一.需求背景 发布服务的mxd文档发生了更改,如何对该mxd文档映射的地图服务进行更新. 二.分析 由于在10.1中地图服务的发布采用的是msd的形式,也就是虽然在ArcMap中准备的地图文档是mxd ...

  5. Java源码之Object

    本文出自:http://blog.csdn.net/dt235201314/article/details/78318399 一丶概述 JAVA中所有的类都继承自Object类,就从Object作为源 ...

  6. JQuery UI 入门

    1. JQuery UI 概述 1.1 JQuery UI 主要分为三部分: 交互部件(interactions):是一些与鼠标交互相关的内容; 小部件(widgets): 主要是一些页面的扩展; 效 ...

  7. 经典书Discrete.Mathematics上的大神

    版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...

  8. hadoop学习第二天-了解HDFS的基本概念&&分布式集群的搭建&&HDFS基本命令的使用

    一.HDFS的相关基本概念 1.数据块 1.在HDFS中,文件诶切分成固定大小的数据块,默认大小为64MB(hadoop2.x以后是128M),也可以自己配置. 2.为何数据块如此大,因为数据传输时间 ...

  9. nfs共享存储

    1.下载软件包 yum install nfs-utils nfs-utils-lib -y 2.编辑/etc/exports文件: 1.创建目录:mkdir -p /home/glance2.编辑e ...

  10. loadrunder之脚本篇——action分类

    Action分类 l . Vuser_init 2. Vuser_end 3.  Action 在lr中用户的初始化操作应该存放在Vuser_init中.用户的结束操作存放在Vuser_end中.因为 ...