flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Move cursor console without interrupt

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



Joined: 27 Nov 2017
Posts: 276
Fulgurance 28 Mar 2020, 16:23
Yes i need to use other way.

Thanks you for your code, but i need to understand why my code don't work, or i don't make progress

I think i have found something to solve my problem.

Into my assembly book, it's writed 0x61 port it's used to confirm the scancode reception of port 0x60, if that step isn't executed, 0x60 port keep the last scancode
Post 28 Mar 2020, 16:23
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 28 Mar 2020, 17:48
revolution wrote:
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.

If it’s OS construction then how is the OP expected to even load his operating system without BIOS services or output any meaningful messages in case bootloading fails? Or do you mean the case when the OP intentionally made BIOS services unavailable while staying in real mode?
Post 28 Mar 2020, 17: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: 20454
Location: In your JS exploiting you and your system
revolution 28 Mar 2020, 17:59
DimonSoft wrote:
If it’s OS construction then how is the OP expected to even load his operating system without BIOS services or output any meaningful messages in case bootloading fails? Or do you mean the case when the OP intentionally made BIOS services unavailable while staying in real mode?
I would imagine this is just sample code.

You can load your boot loader and whatnot using the BIOS. But once you switch to protected mode (or whatever mode) then you need to use your own drivers with their own IN/OUT code.
Post 28 Mar 2020, 17:59
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 28 Mar 2020, 18:48
I have tested with port 0x61 and 0x64, but nothing. I don't understand ...

If Thomas can look my topic T_T
Post 28 Mar 2020, 18:48
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 28 Mar 2020, 19:04
Fulgurance wrote:
If Thomas can look my topic T_T
In my kelvar example there is a very simple keyboard driver in SOURCE\SYSTEM\KEYBOARD.INC, you can try reusing fragments of that code. Some time ago I've been showing on live stream how to run it under Bochs, and I can also assure you that it's been working correctly on actual hardware.

However, for console/video handling kelvar uses VESA BIOS, so it is not going to help with that. But for programming VGA directly (without BIOS) I have another recommendation - the good old MODES.ASM example (it is in TASM syntax, though not that hard to convert into fasm*). This sample is what I had been learning from when I wrote VGA drivers for my TitanOS (the one that I have lost in a HDD crash, so unfortunately I'm not able to share that code).
________
* I have also made a set of macros that allow to assemble MODES.ASM with fasmg without any alterations to source code. These macros work with an old (pre-CALM) version of 80386.INC, you'd need to get that old version from GitHub history. Or you can get it as a part of complete package of demonstrations of assembling legacy sources with fasmg. But this is mostly just a curiosity.
Post 28 Mar 2020, 19:04
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 28 Mar 2020, 21:22
Thanks for your example. I try to understand.

I have impression is necessary to use 0x64 and 0x61port. What is the use of this ports ?

What is the difference between cmp and test fonction ?
Post 28 Mar 2020, 21:22
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 28 Mar 2020, 21:28
revolution wrote:
DimonSoft wrote:
If it’s OS construction then how is the OP expected to even load his operating system without BIOS services or output any meaningful messages in case bootloading fails? Or do you mean the case when the OP intentionally made BIOS services unavailable while staying in real mode?
I would imagine this is just sample code.

You can load your boot loader and whatnot using the BIOS. But once you switch to protected mode (or whatever mode) then you need to use your own drivers with their own IN/OUT code.

Sorry, I was under impression that the question was related to real mode. It really wasn’t.

Then again, AFAIK, it’s not really a good idea to rely on VGA being properly emulated by modern video cards. It might be to some degree, but… The Intel HD Graphics card in the notebook I use to type this message requires additional setup to support 800x600 mode which is far newer than VGA’s 13h mode and the rest. I wouldn’t bet a single penny for its complete support of legacy VGA ports’ interface.
Post 28 Mar 2020, 21:28
View user's profile Send private message Visit poster's website Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 28 Mar 2020, 21:41
"cmp" make a "sub" but dont save the result and "test" make an "And" and dont save the result


for understanding the use of keybord i recommend the reading of http://www.stanislavs.org/helppc/8042.html
Post 28 Mar 2020, 21:41
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 10:32
Sorry, but your webpage isn't accessible (404 error)
Post 29 Mar 2020, 10:32
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 29 Mar 2020, 10:56
that strange, i can read the page (attached to this post)


Description:
Download
Filename: 8042.zip
Filesize: 5.14 KB
Downloaded: 729 Time(s)

Post 29 Mar 2020, 10:56
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 12:06
It's possible my security settings is little aggressive.
Post 29 Mar 2020, 12:06
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 29 Mar 2020, 15:12
I had never looked at the rest of the site but it seems to me to be a kind of pro Russian blog and anti West, there may be in the site itself blocking depending on the origin of the reader

I found another source for this doc: http://helppc.netcore2k.net/hardware/8042
he had fun recreating the initial presentation of the helppc program developed by David Jurgen http://helppc.netcore2k.net/

the hardware section is quite useful when starting a hobby OS (it was for me)
Post 29 Mar 2020, 15:12
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 16:15
Tomasz Grysztar, i have studied your code, and i have tried to apply what i have looked, but, i have the same result ... What is wrong into my code ?

If i have understand good, in firt i need to get the current scancode with 0x60 port.
I save it into ah register.
In second, i read 0x64 status port to check if signal is finished, or not, and if it's even, i compare current scancode. No ?

Look my code:
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

Main16:
xor si,si

.update:
call GetCurrentScanCode
cmp ah,[CharactersScanCodeTable+si]
jne Main16
inc bx
call MoveConsoleCursor
cmp si,0x1A
jge Main16
inc si

jmp .update

include "MoveConsoleCursor.fasm"
include "GetCurrentScanCode.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
ReleasedCharactersScanCodeTable:
db 0x90,0xb0,0xae,0xa0,0x92,0xa1,0xa2,0xa3,0x97,0xa4,0xa5,0xa6,0xb2,0xb1,0x98,0x99,0x9e,0x93,0x9f,0x94,0x96,0xaf,0xac,0xad,0x95,0x91

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



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 16:16
Code:
use16

GetCurrentScanCode:
in al,0x60
mov ah,al
in al,0x64
test al,1
jnz GetCurrentScanCode
ret
    
Post 29 Mar 2020, 16:16
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 16:16
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 29 Mar 2020, 16:16
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 29 Mar 2020, 16:40
no, First you have to read de 64h port to check if data are available and if the bit is set, read the 60h port


Code:
use16

GetCurrentScanCode:
in al,0x64
test al,1
jz GetCurrentScanCode
in al,0x60
mov ah,al
ret    
Post 29 Mar 2020, 16:40
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 16:47
I have tested, but nothing append when i input into my keyboard :C
Post 29 Mar 2020, 16:47
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 29 Mar 2020, 17:09
i test on my own os what is the state or register 64h and evry time the irq is call the 1st bit of 64h is at 1

you never desactivate the irq in your code, maybe the bios irq for the keyboard read and delete data from 60h register before your code
try to add a "cli" instruction in the start of your code


edit i test your code with a cli in the start of your code and it work but just for one key (the A)

et bizzarement votre clavier semble être un azerty....
Post 29 Mar 2020, 17:09
View user's profile Send private message Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 276
Fulgurance 29 Mar 2020, 17:38
Yes, i have mapped for azerty Very Happy
Yes, i think something is bad. I have updated my code. Now, cursor move but after i stay pressed into some key during loooong ago ... I think something is bad into my code, bad update or other thing .... Look:

Code:
Format binary as "img"

org 0x7C00
use16

BootSector16:

cli
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

Main16:

.reset:
xor si,si

.update:
call GetCurrentScanCode
cmp ah,[CharactersScanCodeTable+si]
jne .updateIndex

.updateCursor:
inc bx
call MoveConsoleCursor

.updateIndex:
cmp si,0x1A
jge .reset
inc si

jmp .update

include "MoveConsoleCursor.fasm"
include "GetCurrentScanCode.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
ReleasedCharactersScanCodeTable:
db 0x90,0xb0,0xae,0xa0,0x92,0xa1,0xa2,0xa3,0x97,0xa4,0xa5,0xa6,0xb2,0xb1,0x98,0x99,0x9e,0x93,0x9f,0x94,0x96,0xaf,0xac,0xad,0x95,0x91

db 510-($-$$) dup 0x90
dw 0xAA55
    
Post 29 Mar 2020, 17:38
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 29 Mar 2020, 18:22
i have understand why it was sooo long:


Code:
org 0x7C00
use16

BootSector16:
cli
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

Main16:

.reset:
xor si,si


call GetCurrentScanCode               ;i change this because you wait for
.update:                              ; a key for every scan code you test  
cmp ah,[CharactersScanCodeTable+si]
jne .updateIndex

.updateCursor:
push bx                           ;to write carac to screen
shl bx,1                          ; 
mov al,[si+CharactersTable]       ;
mov ah,7                          ;
mov [es:bx],ax                    ;
pop bx                            ;

inc bx
call MoveConsoleCursor

.updateIndex:
cmp si,0x19                           ;stop to lettre 25
jae .reset                            ;jg a jl are for signed number ja and jb are for non-signed number
inc si

jmp .update





GetCurrentScanCode:
in al,0x64
test al,1
jz GetCurrentScanCode
in al,0x60
mov ah,al
ret 



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




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
ReleasedCharactersScanCodeTable:
db 0x90,0xb0,0xae,0xa0,0x92,0xa1,0xa2,0xa3,0x97,0xa4,0xa5,0xa6,0xb2,0xb1,0x98,0x99,0x9e,0x93,0x9f,0x94,0x96,0xaf,0xac,0xad,0x95,0x91

db 510-($-$$) dup 0x90
dw 0xAA55    
Post 29 Mar 2020, 18:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.