#  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. Ubuntu 16.04安装各种软件

    Ubuntu 16.04发布了,带来了很多新特性,同样也依然带着很多不习惯的东西,所以装完系统后还要进行一系列的优化. 1.删除libreoffice libreoffice虽然是开源的,但是Java ...

  2. Delphi运算符及优先级

    单目运算符 (最高优先级) @ 取变量或函数的地址(返回一个指针) not 逻辑取反或按位取反 乘除及按位运算符 * 相乘或集合交集 / 浮点相除 div 整数相除 mod 取模 (整数相除的余数) ...

  3. 一、Nuxt简介

    1.Nuxt是什么    Nuxt.js是基于vue的服务器端渲染框架,常用来做SSR(服务器端渲染)   2.为什么用Nuxt    Vue开发的SPA(单页应用)不利于搜索引擎的SEO优化   3 ...

  4. PHP多线程pthreads

    Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | EmailPHP 高级 ...

  5. Asp.Net MVC anti-forgery token的问题:nameidentifier not present

    前一篇关于anti-forgery token问题的博文提到我们可以通过修改AntiForgeryConfig.UniqueClaimTypeIdentifier属性来避免AntiForgeryTok ...

  6. Linux中的位置参数变量

    解释: 主要是向脚本中传递数据,变量名不能自定义,变量作用是固定的 $n $0代表命令本身,$1-9代表接受的第1-9个参数,10以上需要用{}括起来,比如${10}代表接收的第10个参数 $* 代表 ...

  7. Symfony4 数据库连接

    代码 https://github.com/liudianpeng/BlogMVC-Symfony4 在 .env 文件可以调整一下数据库连接信息 ###> doctrine/doctrine- ...

  8. Python基础-序列化(json/pickle)

    我们把对象(变量)从内存中变成可存储的过程称之为序列化,比如XML,在Python中叫pickling,在其他语言中也被称之为serialization,marshalling,flattening等 ...

  9. 【jenkins】jenkins实时显示python脚本输出

    jenkins在构建shell脚本时可以实时输出结果,但是在构建python脚本时,是等到python执行完成以后,才显示结果,这个对于我们判断脚本执行状态非常不利 这里介绍一种方法,能够实时显示py ...

  10. github代码托管

    下载github客户端软件 1)  官网下载help.github.com 2)  百度搜索,一般用于windows7以前的系统 安装github软件 按照软件提示安装即可.不过,博主倾向使用命令行工 ...