OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 10:54 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: HLT instruction question
PostPosted: Sat Jul 14, 2007 2:16 am 
Offline

Joined: Sat Jun 30, 2007 10:11 pm
Posts: 4
Hey whats up? Currently i am trying to implement a way to "wait for a keypress to continue"

Since the code can explain it better then i can, well here it is haha

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    The Kew Keyboard ISR calls the old keyboard ISR   and ;;
;;    updates bit 0 at 9ffff  to 1 when a key is pressed  ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NewKeyboardISR:
   push es
   push ax
   mov ax,infoSegment ;infosegment:0 is original ISR for keyboard
   mov es,ax
   or byte [es:deviceStatus],0x1 ;changes to 1 whenever keyboard is pressed
   mov ax,900
   mov es,ax
   pushf
   call far [es:0] ;calls original keyboard ISR
   pop ax
   pop es
   iret

   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Below is the main interrupt accessed by int 60h       ;;
;; currently it's only function is to wait till a key   ;;
;; is pressed before it returns                       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MainInt:
   mov WORD [messagePointer],(kerneladdr+(PressAKey-Kernel))
   call 0:biosPrintString
   push ax
   push es
   mov ax,infoSegment
   mov es,ax
   and byte [es:deviceStatus], 0xFE
   .loop
      hlt
      mov byte al,[es:deviceStatus]
      and al,1
      cmp al,1
      jne .loop
   pop es
   pop ax
   iret


So basically when interrupt 0x60 is called it waits till my new keyboardISR updates a bit saying a key was pressed. The problem is the program hangs =/ . I don't think its bochs either. Any help would be much appreciated =). - Happy Coding

*edit* hm i guess i could make a keyboardISR and have it jump to w/e address when a key is pressed...but i'm still wondering why this hangs XD


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 2:44 am 
Offline
Member
Member

Joined: Sun Apr 29, 2007 1:13 am
Posts: 234
hlt halts the CPU


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 2:55 am 
Offline
Member
Member
User avatar

Joined: Thu Sep 28, 2006 10:32 am
Posts: 1309
Location: Slovakia
HLT halts the CPU like I was told, until a hardware interrupt occurs, so in the keyboard handler it's OK. If used with CLI and HLT, this should halt the system completely :mrgreen: - Try giving STI in the very beginning of your int 0x60 ISR. I had a CLI in mine and it halted the system completely, because it waited for the keyboard interrupt when interrupts were disabled :lol:

inflater

_________________
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 12:19 pm 
Offline

Joined: Sat Jun 30, 2007 10:11 pm
Posts: 4
Hm still no luck...
*edit*
Code:
mov ax,900

should of been
Code:
mov ax,0x900

:oops: haha i hate that when it happens

But you where right about the sti ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 10:23 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 6:06 pm
Posts: 1437
Location: Vancouver, BC, Canada
@Mods: Please move this to the OS Development forum... Thanks.

_________________
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 62 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group