#  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. Instapaper 使用经验和技巧

    Instapaper 分类本质是文件夹整理,没有标签. 文件夹意味着一篇文章只能放在一个文件夹里,不像标签可以实现一篇文章多个标签的功能. 一.文件夹和Like功能 1.已有文件夹: Home:存放所 ...

  2. SharePoint服务器端对象模型 之 访问网站和列表数据(Part 4)

    (四)栏/字段 SharePoint中的字段(中文版中叫做"栏")与传统的数据栏类似,也有不同类型的区别,不过SharePoint中内置的栏类型除了按照数据类型(如数字.日期和时间 ...

  3. mysql_用户_操作

    一. 创建用户 登录MySQL mysql -u root -p 添加新用户 create user 'username'@'host' identified by 'password'; usern ...

  4. 阻塞队列 ArrayBlockingQueue 我给自己挖了一个坑

    说一句MMB, 一下午时间, package cn.tbnb1.seckil.quene; import java.util.concurrent.ArrayBlockingQueue; import ...

  5. python基础里的那些为什么?

    一.执行python脚本的两种方式? 直接在解释器里编写并在解释器里执行 文件编写,并在终端通过 python 路径  这种方式执行 好,我们就以输出hello world这个例子来比较两种方式的不同 ...

  6. 洛谷 P2261 [CQOI2007]余数求和

    洛谷 一看就知道是一个数学题.嘿嘿- 讲讲各种分的做法吧. 30分做法:不知道,这大概是这题的难点吧! 60分做法: 一是直接暴力,看下代码吧- #include <bits/stdc++.h& ...

  7. CF145E Lucky Queries

    CF145E Lucky Queries 英文题面不放了,直接上翻译: 题目描述 给你n个数,每个数是4或者7,给你m个任务完成 switch l r 把[l,r]位置的4换成7,7换成4 count ...

  8. Linux用户相关文件之组文件

    组信息文件: 1.文件地址: /etc/group -rw-r--r--. 1 root root 492 10月 6 21:56 /etc/group 2.文件内容: xiaol:x:500: 3. ...

  9. springboot整合Ehcache

    首先引入maven包: <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...

  10. Python Redis pipeline操作(秒杀实现)

    设想这样的一个场景,你要批量的执行一系列redis命令,例如执行100次get key,这时你要向redis请求100次+获取响应100次.如果能一次性将100个请求提交给redis server,执 ...