A jump instruction but seems not work well
Posted: Thu Jan 26, 2006 10:54 pm
Source code is listed as follow:
I used gcc -c and ld --oformat binary -Ttext 0 -e 0 to compile and link it.And,I've already place 0xFA,0xF4 correctly at 0800:0200 (512k+512).But when I debug the section of code on bochs ,bochs restarted again and again.Relative log informations are listed as follow:
Best regards.
Code: Select all
/* Region [256k,512k) reserved for buffering */
BUFFER_START_SEG=0x0400
/* stack stretchs from 640k down */
STACK_START_SEG=0x0A00
/* stage2 starts at 0x0800:0000 */
STAGE2_START_SEG=0x0800
/* sizeof fs header=40 */
HEADER_SIZE=40
.code16
.text
_start:
cli
movw %cs,%ax
movw %ax,%ds
movw $booting_stage2_msg,%si
call put_string
call get_memory_e801
call enable_a20_gate
jmp prepare_to_32
enable_a20_gate:
pushw %ax
inb $0x92,%al
xorb $2,%al
outb %al,$0x92
popw %ax
ret
prepare_to_32:
lidt idt_48
xorl %eax, %eax
movw %ds, %ax
shll $4, %eax
addl $gdt, %eax
movl %eax, (gdt_48+2)
lgdt gdt_48
movl %cr0,%eax
orl $1,%eax
movl %eax,%cr0
movw $0x10,%ax
movw %ax,%ss
movw %ax,%ds
movl $640*1024-1,%eax
movl %eax,%esp
.byte 0x66
.byte 0xea
.long 0x80200
.word 0x8
// <pype>helper functions stripped out for clarity</pype>
booting_stage2_msg:
.string "Now booting Stage2...\n\r"
die_e801_msg:
.string "[FATAL]e801 is not supported!\n\r"
.align 16
gdt:
.word 0
.word 0
.word 0
.word 0
.word 0xFFFF
.word 0
.word 0x9A00
.word 0x00CF
.word 0xFFFF
.word 0
.word 0x9200
.word 0x00CF /*0x00CF*/
gdt_end:
.align 4
.word 0
idt_48:
.word 0
.word 0, 0
.word 0
gdt_48:
.word gdt_end - gdt - 1
.word 0, 0
Please anyone tell me why to cause the fault.00000950337i[CPU0 ] LOCK prefix unallowed (op1=0x1, attr=0x300, mod=0xc0, nnn=6)
00000950337e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00000950337i[CPU0 ] protected mode
00000950337i[CPU0 ] CS.d_b = 32 bit
00000950337i[CPU0 ] SS.d_b = 32 bit
00000950337i[CPU0 ] | EAX=0009fe09 EBX=00000001 ECX=00000007 EDX=00000080
00000950337i[CPU0 ] | ESP=0009fffb EBP=0009fffb ESI=000000d0 EDI=00000200
00000950337i[CPU0 ] | IOPL=0 vm RF ac nt of df if tf SF zf af PF cf
00000950337i[CPU0 ] | SEG selector base limit G D
00000950337i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00000950337i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00000950337i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00000950337i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00000950337i[CPU0 ] | ES:0400( 0000| 0| 0) 00004000 0000ffff 0 0
00000950337i[CPU0 ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000950337i[CPU0 ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000950337i[CPU0 ] | EIP=0009fd24 (0009fd24)
00000950337i[CPU0 ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00000950337i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00000950337i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
Best regards.