Only for practice hand.using masm assemble languge to rewrite head.s
来源:互联网 发布:cisco 端口聚合 编辑:程序博客网 时间:2024/05/29 13:32
Today I decide to write my blog in English,though... beacause...
I rewrite the head.s in masm assemble language.
the following...
.386p
.model flat,stdcall
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
LATCH equ 11930
SCRN_SEL equ 18h
TSS0_SEL equ 20h
LDT0_SEL equ 28h
TSS1_SEL equ 30h
LDT1_SEL equ 38h
.code
;make the ds point a segment same to cs
org 0h
start: mov eax,10h
mov ds,ax
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lss esp,fword ptr [ds:[init_stack - start]]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call setup_idt
call setup_gdt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov eax,10h
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
lss esp,fword ptr [ds:[init_stack - start]]
;setting the timing chip
mov al,36h
mov edx,43h
out dx,al
mov eax,LATCH
mov edx,40h
out dx,al
mov ah,al
out dx,al
;setting the timer interrupt(8th) and calls interrupt(128th) in IDT table.
mov eax,00080000h
mov ax,word ptr (timer_interrupt - start)
mov dx,8e00h
mov ecx,08h
lea esi,(idt - start)[ecx*8]
mov dword ptr [esi],eax
mov dword ptr [esi + 4],edx
;中断80h设置
mov ax,word ptr (system_interrupt - start)
mov dx,0ef00h
mov ecx,80h
lea esi,(idt - start)[ecx*8]
mov dword ptr [esi],eax
mov dword ptr [esi + 4],edx
pushfd
and dword ptr [esp],0ffffbfffh
popfd
mov eax,TSS0_SEL
ltr ax
mov eax,LDT0_SEL
lldt ax
mov dword ptr [ds:[current - start]],0
sti
pushd 17h
pushd esp
pushfd
pushd 0fh
pushd task0 - start
iretd
setup_gdt:
lgdt fword ptr [ds:[lgdt_opcode - start]]
ret
setup_idt:
mov edx,word ptr (ignore_int - start)
mov eax,00080000h
mov ax,dx
mov dx,8e00h
lea edi,dword ptr [ds:[idt - start]]
mov ecx,256
rp_idt:
mov dword ptr [edi],eax
mov dword ptr [edi+4],edx
add edi,8
dec ecx
jne rp_idt
lidt fword ptr [ds:[idt_opcode - start]]
ret
write_char:
push gs
push ebx
mov ebx,SCRN_SEL
mov gs,bx
mov ebx,dword ptr [ds:[scr_loc - start]]
shl ebx,1
assume gs:nothing
mov byte ptr [gs:[ebx]],al
shr ebx,1
inc ebx
cmp ebx,2000
jb fl_write
mov ebx,0
fl_write:
mov dword ptr [ds:[scr_loc - start]],ebx
pop ebx
pop gs
ret
ALIGN 4
ignore_int:
push ds
push eax
mov eax,10h
mov ds,ax
mov eax,67
call write_char
pop eax
pop ds
iretd
ALiGN 4
timer_interrupt:
push ds
push eax
mov eax,10h
mov ds,ax
mov al,20h
out 20h,al
mov eax,1
cmp dword ptr [ds:[current - start]],eax
je time_i0
mov dword ptr [ds:[current - start]],eax
;;jmp far TSS1_SEL:0h
db 0eah
dd 0
dw TSS1_SEL
jmp time_i20
time_i0:
mov dword ptr [ds:[current - start]],0
;;jmp far TSS0_SEL:06h
db 0eah
dd 0
dw TSS0_SEL
time_i20:
pop eax
pop ds
iretd
ALIGN 4
system_interrupt:
push ds
push edx
push ecx
push ebx
push eax
mov edx,10h
mov ds,dx
call write_char
pop eax
pop ebx
pop ecx
pop edx
pop ds
iretd
current:
dd 0
scr_loc:
dd 0
idt_opcode:
dw 256*8-1
dd idt - start
lgdt_opcode:
dw (end_gdt - gdt)-1
dd gdt - start
align 4
idt:
dq 256 dup(0)
gdt:
dq 0000000000000000h
dq 00c09a00000007ffh
dq 00c09200000007ffh
dq 00c0920b80000002h
dw 68h,(tss0 - start),0e900h,0
dw 40h,(ldt0 - start),0e200h,0
dw 68h,(tss1 - start),0e900h,0
dw 40h,(ldt1 - start),0e200h,0
end_gdt:
dd 128 dup(0)
init_stack:
dd (init_stack - start)
dw 10h
align 4
ldt0:
dq 0000000000000000h
dq 00c0fa00000003ffh
dq 00c0f200000003ffh
tss0:
dd 0
dd (krn_stk0 - start),10h
dd 0,0,0,0,0
dd 0,0,0,0,0
dd 0,0,0,0,0
dd 0,0,0,0,0,0
dd LDT0_SEL,8000000h
dd 128 dup(0)
krn_stk0:
align 4
ldt1:
dq 0000000000000000h
dq 00c0fa00000003ffh
dq 00c0f200000003ffh
tss1:
dd 0
dd (krn_stk1- start),10h
dd 0,0,0,0,0
dd task1 - start,200h
dd 0,0,0,0
dd (usr_stk1 - start),0,0,0
dd 17h,0fh,17h,17h,17h,17h
dd LDT1_SEL,8000000h
dd 128 dup(0)
krn_stk1:
task0:
mov eax,17h
mov ds,ax
mov al,65
int 80h
mov ecx,0fffh
t01:loop t01
jmp task0
task1:
mov al,66
int 80h
mov ecx,0fffh
t11: loop t11
jmp task1
dd 128 dup(0)
usr_stk1:
END start
- Only for practice hand.using masm assemble languge to rewrite head.s
- Only wants to pull your hand
- abercrombie only hand to pull out
- Getting “CHECKOUT can only be performed on a version resource” when trying to commit using Eclipse s
- How to Create WPF Docking Windows Using Code Only
- how-to-print-a-long-integer-using-only-putchar
- welcome to masm 汇编程序
- Welcome To Masm!
- How to Disassemble/Assemble Galaxy S4 i9500 for Screen/Parts Repair!
- CProxyDllMaker : a class to make proxy dll's masm source code
- VSTO for Mere Mortals(TM): A VBA Developer's Guide to Microsoft Office Development Using Visual Stud
- head.s
- head.s
- MASM Programmer's Guide---Introduction
- OCR of Hand-written Data using SVM
- OCR of Hand-written Data using kNN
- OCR of Hand-written Data using SVM
- MASM for x64 (ml64.exe)
- RegularExpression 中的 lookahead 和 lookbehind 表达式
- 黑马程序员-Java API-day14
- JAVA获取随机数
- c++的内存管理机制,栈有多大,栈溢出
- 函数式宏定义与普通函数
- Only for practice hand.using masm assemble languge to rewrite head.s
- VC用MCI播放mp3等音乐文件
- android对文件的MD5验证
- 黑马程序员------C#类型
- 自己对编程原则的看法(初识数据结构)
- 有关C语言
- C#代码审查清单
- 黑马程序员-Java API-day15
- ubuntu文件系统和启动流程