flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > getting keyboard input? |
Author |
|
vid 23 Jan 2007, 07:19
in OS construction, you probably can't use int 21h. You have to use int 16h.
|
|||
23 Jan 2007, 07:19 |
|
oscar 23 Jan 2007, 10:10
thanks heaps!
So far i have it to the point of recognising what key is hit (loops through until enter is hit) but i still can't get it to print it to the screen. Code: Macro Input prompt{ local .GetInput local .Done local .Var Write prompt ; reference to macro that prints to screen without going to newline .GetInput: int 16h mov ah, 0 ;### start print string .Var db [al],0 mov si, .Var mov ah, 0Eh int 10h jmp .GetInput ;### end print cmp al, 13 jz .Done jmp .GetInput .Done: NewLine ;reference toanother macro which prints newline to the screen } |
|||
23 Jan 2007, 10:10 |
|
Dex4u 23 Jan 2007, 16:28
Here is some code from MiniDOS that may help:
http://board.flatassembler.net/topic.php?t=5275&start=0 Code: ;====================================================; ; GetCommand ; ;====================================================; GetCommand: pusha ; Save genral regs push es ; Save ES push cs ; Move CS to stack pop es ; Move CS from stack in to ES mov di,CommandBuffer ; Move the address of CommandBuffer in DI mov cx,64 ; move 64 in to counter mov dx,di ; Remember initial offset getkey: xor ax,ax ; Get a key int 16h ; Call interrupt service cmp al,13 ; Enter? je AH_3hd ; Jump = to label AH_3hd cmp al,8 ; Backspace? je backspace ; Jump = to label backspace mov bx,di ; Are we at CX bytes already? sub bx,dx cmp bx,cx jae getkey ; Jump above or = to label getkey mov ah,0Eh ; Write Character mov bx,0x0001 int 10h ; Call interrupt service stosb ; Record and display keystroke jmp getkey ; Jump to label getkey backspace: cmp di,CommandBuffer ; Compear pointer to start of buffer jbe getkey ; Jump bellow or = to label getkey dec di ; Go back in buffer mov al,8 ; Move cursor back mov ah,0Eh ; Request display mov bx,0x0001 int 10h ; Call interrupt service mov al,32 ; Print a space mov ah,0Eh ; Request display mov bx,0x0001 int 10h ; Call interrupt service mov al,8 ; Move cursor back again mov ah,0Eh ; Request display mov bx,0x0001 int 10h ; Call interrupt service jmp getkey ; Get another key AH_3hd: ; Finish up mov cx,di ; CX = byte count sub cx,dx xor al,al ; Zero-terminate stosb ; Store a byte xor ax,ax ; Success mov si,CommandBuffer ; Move the address of CommandBuffer in SI mov ax,si ; Move SI into AX mov dx,si ; Move SI into DX pop es ; Restore ES popa ; Restore genral regs ret ; Return CommandBuffer: times 128 db 0 |
|||
23 Jan 2007, 16:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.