flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Why does the code lead to a reset in bochs

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 08 Feb 2015, 09:34
Code:
  mov al,$34
  out $43,al
  mov al,$9c
  out $40,al
  mov al,$2e
  out $40,al
  ;Set interrupt
  lidt [ldtt]
  mov ecx,0
  setintloop:
  mov eax, [fs:tmr]
  mov [fs:$7000+8*8+ecx*8],eax
  mov edx, [fs:tmr*8]
  mov [fs:$7000+8*8+4+ecx*8],edx
  dec cl
  jnz setintloop
  mov eax,cr0             ; equivalent to "or cr0,1"
  or al,1                 ;   switches the CPU in protected mode-
  mov cr0,eax             ;   protected mode enable
;  mov ax,16
;  mov ss,ax
  jmp 8:start32
  use32
start32:
;  sti
  int 0
  mov [fs:$b8012],byte '#'
  jmp $

ldtt:
dw $800
dd $7000
alignde 8,2                     ; align on 8 byte boundary for optimal performance
gdt_size dw @f-(gdt_-8)-1       ; word part of pseudo desciptor, size of gdt in bytes
.linear dd (gdt_-8)             ; dword part of pseudo descriptor, linear base adress
.code=$-(gdt_-8)                ; first entry in gdt (8*1)
gdt_:
dw 0ffffh,0                     ;   4Gbytes, start at linear 0
db 0,10011010b,11001111b,0      ;   granularity = 64Kbytes, code segment, ring 0, read only,etc... 
gdt_data=$-(gdt_-8)             ; second entry in gdt (8*2)
dw 0ffffh,0                     ;   4Gbytes, start at linear 0 
db 0,10010010b,11001111b,0      ;   granularity = 64Kbytes, data segment, ring 0, read/write,etc...
@@:
tmr:
dq $0000F00000080000+loop2
;ldti 8:loop2,ldt_trap+ldt_32
str_loadt: db "Disk loaded ",0

loop2:
  inc byte [fs:$b8010]
  push ax
;  mov al,$60
;  out $20,al
  pop ax
  jmp $
  iretd
rb $7dfe-$                      ; reserve "free" bytes to make line below at offset 510
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
dw 0aa55h                       ; magic number boot mark, used by bios to test if valid boot sector
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
    

I search for it but nothing found[/code]
Post 08 Feb 2015, 09:34
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 08 Feb 2015, 09:50
CLI before LIDT
Post 08 Feb 2015, 09:50
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 08 Feb 2015, 09:51
sinsi wrote:
CLI before LIDT

But I've already CLI just after starting
Post 08 Feb 2015, 09:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 08 Feb 2015, 11:04
There is no evidence of a CLI in the code your posted. So if you say you have CLI somewhere else then the problem could also be in that somewhere else.

Post ALL the code you are using else we are just running blind wondering what you have done.
Post 08 Feb 2015, 11:04
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 08 Feb 2015, 11:54
revolution wrote:
There is no evidence of a CLI in the code your posted. So if you say you have CLI somewhere else then the problem could also be in that somewhere else.

Post ALL the code you are using else we are just running blind wondering what you have done.

Code:
    
Post 08 Feb 2015, 11:54
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 09 Feb 2015, 01:38
Who help moving this topic to "OS***"
Post 09 Feb 2015, 01:38
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 09 Feb 2015, 01:57
It is already there.
Post 09 Feb 2015, 01:57
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 09 Feb 2015, 03:40
revolution wrote:
It is already there.

It's just moved here.
I made a silly mistake : i want "ptr+4" but i inputed "ptr*8"
Post 09 Feb 2015, 03:40
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 10 Feb 2015, 23:34
bochs can be configured to log its execution trace (see logfile and log options sections) to diagnose the source/location/cause of issues:
e.g.
Quote:
00949056556e[CPU0 ] read_virtual_dword_32(): segment limit violation
00949122469i[CPU0 ] WARNING: HLT instruction with IF=0!
23648900000p[WGUI ] >>PANIC<< Window closed, exiting!
23648900000i[CPU0 ] CPU is in protected mode (halted)
23648900000i[CPU0 ] CS.mode = 32 bit
23648900000i[CPU0 ] SS.mode = 32 bit
23648900000i[CPU0 ] | EAX=0000d3b7 EBX=0000ba80 ECX=fea8e326 EDX=00000002
23648900000i[CPU0 ] | ESP=01ffff8c EBP=01ffffd8 ESI=0cb90000 EDI=ffffffff
23648900000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf SF zf AF pf CF
23648900000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
23648900000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | SS:0020( 0004| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | EIP=0000d114 (0000d114)
23648900000i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
23648900000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
23648900000i[CPU0 ] 0x000000000000d114>> jmp .+549 (0x0000d33e) : E925020000
I haven't tried it on your code but it's usually quite a useful for these things.
Post 10 Feb 2015, 23:34
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 12 Feb 2015, 02:50
cod3b453 wrote:
bochs can be configured to log its execution trace (see logfile and log options sections) to diagnose the source/location/cause of issues:
e.g.
Quote:
00949056556e[CPU0 ] read_virtual_dword_32(): segment limit violation
00949122469i[CPU0 ] WARNING: HLT instruction with IF=0!
23648900000p[WGUI ] >>PANIC<< Window closed, exiting!
23648900000i[CPU0 ] CPU is in protected mode (halted)
23648900000i[CPU0 ] CS.mode = 32 bit
23648900000i[CPU0 ] SS.mode = 32 bit
23648900000i[CPU0 ] | EAX=0000d3b7 EBX=0000ba80 ECX=fea8e326 EDX=00000002
23648900000i[CPU0 ] | ESP=01ffff8c EBP=01ffffd8 ESI=0cb90000 EDI=ffffffff
23648900000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf SF zf AF pf CF
23648900000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
23648900000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | SS:0020( 0004| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
23648900000i[CPU0 ] | EIP=0000d114 (0000d114)
23648900000i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
23648900000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
23648900000i[CPU0 ] 0x000000000000d114>> jmp .+549 (0x0000d33e) : E925020000
I haven't tried it on your code but it's usually quite a useful for these things.

Only a silly wrong...
Post 12 Feb 2015, 02:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.