flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Move cursor console without interrupt

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Hello, i have read OsDev documentation, but there aren't many information about how to move console cursor without interrupt.

How can i for example, move cursor into right without interrupt ?
Post 26 Mar 2020, 23:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
For text mode you need to program the graphics card registers directly.

For graphics mode you need to undraw and redraw the cursor periodically.
Post 27 Mar 2020, 00:00
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Oh ... i have thinking there is a way to code that with in and ou instruction... OsDev don't talk about graphic card registers
Post 27 Mar 2020, 00:07
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE

_________________
¯\(°_o)/¯ unlicense.org
Post 27 Mar 2020, 02:21
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Yes, i have mention it in my first post, but i don't understand how this method work.
Post 27 Mar 2020, 09:04
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
I just tested the code: https://wiki.osdev.org/Text_Mode_Cursor#Moving_the_Cursor_2
It seems to work fine.

How it works is by setting two 8-bit registers in the VGA hardware. Moving the cursor to the right would consist of reading the registers; incrementing by one; and setting the registers. Really need more information about what you are doing to help further.

_________________
¯\(°_o)/¯ unlicense.org
Post 27 Mar 2020, 13:42
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
I have tested into my code, but nothing appening...

Code:
Format binary as "img"

org 0x7C00
use16

BootSector16:

mov ax,0xB800
mov es,ax
xor ax,ax
mov bp,ax

mov byte [es:bp],'>'
inc bp
mov byte [es:bp],00000111b

mov dl, 80
mul dl
add bx, ax

mov dx, 0x03D4
mov al, 0x0F
out dx, al
 
inc dl
mov al, bl
out dx, al

dec dl
mov al, 0x0E
out dx, al
 
inc dl
mov al, bh
out dx, al

Terminal:

jmp short Terminal

db 510-($-$$) dup 0x90
dw 0xAA55    
Post 27 Mar 2020, 18:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
You haven't initialised the value in bx.

The "mul dl" does nothing since al=0 at that point.
Post 27 Mar 2020, 19:16
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Ah yes ! Thanks !
Post 27 Mar 2020, 19:37
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
I try to apply that into little console mode.
In my code, i move console cursor when the user input some alphabet character.
But when my code run test, he always consider user have input something....

There is some scancode when user don't input nothing ?

Code:
Format binary as "img"

org 0x7C00
use16

BootSector16:

mov ax,0xB800
mov es,ax
xor ax,ax
mov bp,ax

mov byte [es:bp],'>'
inc bp
mov byte [es:bp],00000111b

mov bx,0x1

MoveCursorToRight:
mov dx,0x3d4
mov al,0x0f
out dx,al

mov dx,0x3d5
mov al,bl
out dx,al

mov dx,0x3d4
mov al,0x0e
out dx,al

mov dx,0x3d5
mov al,bh
out dx,al

Terminal:

xor si,si

TestInput:
in al,0x60
cmp al,0
jz TestInput
cmp al,[CharactersScanCodeTable+si]
inc si
jne TestInput

inc bx

jmp short MoveCursorToRight

jmp short Terminal

CharactersTable:
db 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
CharactersScanCodeTable:
db 0x10,0x30,0x2e,0x20,0x12,0x21,0x22,0x23,0x17,0x24,0x25,0x26,0x32,0x31,0x18,0x19,0x1e,0x13,0x1f,0x14,0x16,0x2f,0x2c,0x2d,0x15,0x11

db 510-($-$$) dup 0x90
dw 0xAA55
    
Post 27 Mar 2020, 23:02
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
Fulgurance wrote:
Code:
cmp al,[CharactersScanCodeTable+si]
inc si
jne TestInput    
The INC instruction also effects the Z flag.

_________________
¯\(°_o)/¯ unlicense.org
Post 28 Mar 2020, 10:50
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Z flag ? I don't understand the problem
Post 28 Mar 2020, 11:04
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 37
Location: france
N-LG
the z flag is the equal flag, when you do a cmp, its the same like "sub" but without saving the result
when you use the jne or jnz, the compiler use the same opcode, the jne or jnz is just for human




try this:
Code:
inc si
cmp al,[CharactersScanCodeTable-1+si]
jne TestInput     
[/code]
Post 28 Mar 2020, 11:29
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
I have updated my code, it's better to read now Very Happy

I have now different problem. When user input some alphabetic input, terminal always move cursor.
And i have followed your advice... strange
Post 28 Mar 2020, 13:04
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Code:
Format binary as "img"

org 0x7C00
use16

BootSector16:

mov ax,0xB800
mov es,ax
xor ax,ax
mov bp,ax

mov byte [es:bp],'>'
inc bp
mov byte [es:bp],00000111b

mov bx,0x1
call MoveConsoleCursor

xor si,si
jmp TestCurrentInput

include "MoveConsoleCursor.fasm"
include "TestCurrentInput.fasm"

CharactersTable:
db 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
CharactersScanCodeTable:
db 0x10,0x30,0x2e,0x20,0x12,0x21,0x22,0x23,0x17,0x24,0x25,0x26,0x32,0x31,0x18,0x19,0x1e,0x13,0x1f,0x14,0x16,0x2f,0x2c,0x2d,0x15,0x11

db 510-($-$$) dup 0x90
dw 0xAA55
    
Post 28 Mar 2020, 13:05
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Code:
use16

MoveConsoleCursor:
mov dx,0x3d4
mov al,0x0f
out dx,al

mov dx,0x3d5
mov al,bl
out dx,al

mov dx,0x3d4
mov al,0x0e
out dx,al

mov dx,0x3d5
mov al,bh
out dx,al
ret
    
Post 28 Mar 2020, 13:05
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 200
Fulgurance
Code:
use16

TestCurrentInput:
mov ah,[CharactersScanCodeTable+si]
in al,0x60

cmp al,0x0
je short TestCurrentInput

cmp al,ah
jne short Update

inc bx
call MoveConsoleCursor

Reset:
xor si,si
jmp short TestCurrentInput

Update:
cmp si,0x1A
jge short Reset
inc si

jmp short TestCurrentInput
    
Post 28 Mar 2020, 13:05
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3050
Location: vpcmipstrm
bitRAKE
Give this a try ...
(untested on real hardware)
Code:
; kbdtst.com
org 0x100
use16

mov ax,0xB800
mov es,ax
mov ax,cs
mov ds,ax
xor ax,ax
mov di,ax
mov bx,kbdus

  @@:
        in al,0x64
        test al,1
        jz @B
        test al,0x20
        jnz @B

        in al,0x60
        xlatb
        cmp al,0
        jz @B

        ; output char
        mov ah,[TUI.Attribute]
        stosw

        ; move cursor
        mov dx,0x3d4
        mov al,0x0f
        out dx,al

        mov dx,0x3d5
        push di
        pop ax
        shr ax,1
        out dx,al

        mov dx,0x3d4
        mov al,0x0e
        out dx,al

        mov dx,0x3d5
        mov al,ah
        out dx,al

        jmp @B

TUI.Attribute db 00000111b

; scancode translation table
kbdus db 0,0,\
'1234567890-=',\
0,\     ; Backspace
0,\     ; Tab
'qwertyuiop[]',\
0,\     ; Enter key
0,\     ; Control
"asdfghjkl;'`",\
0,\     ; Left shift
'\zxcvbnm,./',\
0,\     ; Right shift
'*',\
0,\     ; Alt
' ',\
0,\     ; Caps lock
0,0,0,0,0,0,0,0,0,0,\   ; F1-F10 key
0,\     ; Num lock
0,\     ; Scroll Lock
0,\     ; Home key
0,\     ; Up Arrow
0,\     ; Page Up
'-',\
0,\     ; Left Arrow
0,\
0,\     ; Right Arrow
'+',\
0,\     ; End key
0,\     ; Down Arrow
0,\     ; Page Down
0,\     ; Insert Key
0,\     ; Delete Key
0,0,0,\
0,0     ; F11-F12 Key

; All other keys are undefined, or highbit set
rb 255 - ($ - kbdus)
db 0 ; force fasm to output zero bytes    

_________________
¯\(°_o)/¯ unlicense.org
Post 28 Mar 2020, 14:57
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
Guys, what’s wrong with int 10h/02h? Why mess with VGA ports when BIOS provides a means to do the same thing? Do you have much spare space with real mode addressing to reimplement BIOS?
Post 28 Mar 2020, 15:48
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
DimonSoft wrote:
Guys, what’s wrong with int 10h/02h? Why mess with VGA ports when BIOS provides a means to do the same thing? Do you have much spare space with real mode addressing to reimplement BIOS?
This is OS Construction so I assume the OP needs to write code where the BIOS isn't available.
Post 28 Mar 2020, 16:07
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.