flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Longmode cursor problem

Author
Thread Post new topic Reply to topic
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 11:56
Hello all Smile

I've been playing around with 64bit long mode for a while,
using PetroffHeroj's FAT12 boot sector and Tomasz Grysztar's long mode example.

For a while I've been trying to set the cursor position using the following code:

Code:
        ; BX = Offset in buffer
     mov     AL, 0Eh
     mov     AH, BH
      mov     DX, 03D4h
   out     DX, AX
      inc     AX
  mov     AH, BL
      out     DX, AX
    


The problem is that I can set the position to anything up to position 118 in the buffer, but as soon as i try anything above 118 the cursor disappears from the monitor.

I have tested the code using bochs 2.4.5 on two computers, same result on both.

So, my question is; is the problem in the setcursor code or is it related to the boot sector or long mode code ?

Any examples that work would be nice. Smile

References:
http://flatassembler.net/examples/phboot.zip
http://flatassembler.net/examples/longmode.zip

TAH
Post 23 Feb 2011, 11:56
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 23 Feb 2011, 16:56
This is a nice OS (Baremetal OS) that has 64bit functions examples for cursor in it.
http://www.returninfinity.com/baremetal.html
Post 23 Feb 2011, 16:56
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4352
Location: Now
edfed 23 Feb 2011, 17:10
use double buffering and update cursor position during VSYNC, before text video memory refresh.
Post 23 Feb 2011, 17:10
View user's profile Send private message Visit poster's website Reply with quote
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 17:16
Dex4u wrote:
This is a nice OS (Baremetal OS) that has 64bit functions examples for cursor in it.
http://www.returninfinity.com/baremetal.html


Thanks, I'll look into it. Smile
Post 23 Feb 2011, 17:16
View user's profile Send private message Reply with quote
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 17:19
edfed wrote:
use double buffering and update cursor position during VSYNC, before text video memory refresh.


Is this really needed when using a hardware cursor?

I've done stuff like this in the good-old dos environment, vsync wasn't an issue.
Post 23 Feb 2011, 17:19
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4352
Location: Now
edfed 23 Feb 2011, 17:28
test it, it is the only way to know if it solves the problem.
double buffering lets you play with video memory image, without the overhead induced by slow direct video memory accesses.
Post 23 Feb 2011, 17:28
View user's profile Send private message Visit poster's website Reply with quote
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 18:07
Well, seems like there is something strange going on here.

Tried the setcursor in bare-metal-os, and waiting for vsync.
None of those solved the problem.

Guess I'll have som debugging to do or start over rather Smile
Post 23 Feb 2011, 18:07
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 23 Feb 2011, 18:20
What interface are you using to set bx is it something like this
Code:
; Set the cursor to:  DH = X   DL = Y

;--------------------------------------

setcursorxy:
             push    eax
         push    ebx
         push    edx

             movzx   bx, dl
              mov     ax, bx
              shl     ax, 4
               shl     bx, 6
               add     bx, ax
              movzx   ax, dh
              add     bx, ax

          call    setcursor

               pop     edx
         pop     ebx
         pop     eax
         ret



; Set the cursor to:  BX = Offset
;---------------------------------
setcursor:
            push    eax
         push    ebx
         push    edx

             mov     al, 0eh
             mov     ah, bh
              mov     dx, 3d4h
            out     dx, ax
              inc     ax
          mov     ah, bl
              out     dx, ax

          pop     edx
         pop     ebx
         pop     eax
         ret
    


And what about memory mapping for screen is that OK ?
Post 23 Feb 2011, 18:20
View user's profile Send private message Reply with quote
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 19:04
Dex4u wrote:
What interface are you using to set bx is it something like this
Code:
; Set the cursor to:  DH = X   DL = Y
    


And what about memory mapping for screen is that OK ?


I use this for calculating the offset to move the cursor:

Code:
;       CH - Line
;       CL - Column

      mov     RAX, ScreenX
        mul     CH
  xor     CH, CH
      add     AX, CX
      mov     BX, AX
    


I think this is ok, it works fine for the sting output X/Y routines.
And i use the same address for screen output and clearscreen.

The only problem I have is to move the cursor to the end of the string.
Post 23 Feb 2011, 19:04
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 23 Feb 2011, 19:52
TAH wrote:

Code:
;       CH - Line
;       CL - Column

 mov     RAX, ScreenX
        mul     CH
  xor     CH, CH
      add     AX, CX
      mov     BX, AX
    



Have you just hand written that, if not should it not be
Code:
;       CH - Line
;       CL - Column

        mov     RAX, [ScreenX]
      mul     CH
  xor     CH, CH
      add     AX, CX
      mov     BX, AX
    
Post 23 Feb 2011, 19:52
View user's profile Send private message Reply with quote
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 20:04
ScreenX is declared as
Code:
ScreenX equ        80
    

As I remember I don't need the []....

And as I said, it works perfectly for the print string function.
Also, I put the value to move the cursor directly in the DX register for testing purposes.

And the code I borrowed from baremetal don't use ScreenX....
Post 23 Feb 2011, 20:04
View user's profile Send private message Reply with quote
TAH



Joined: 05 Jul 2009
Posts: 8
Location: Norway
TAH 23 Feb 2011, 22:14
After the responses I've got here, I think the bug must be somewhere in the longmode, IDT or GDT code (which is new to me).

I'll try to redo these parts, and see if I can make it work. I'll keep you posted.

Thanks for the help guys. Smile
Post 23 Feb 2011, 22:14
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 23 Feb 2011, 22:43
Yes i would like to know, just in case i move to 64bit and have the same problem.
Happy debugging Wink
Post 23 Feb 2011, 22:43
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.