flat assembler
Message board for the users of flat assembler.
Index
> Windows > need help..Emu > FASM |
Author |
|
revolution 23 Dec 2010, 00:25
Did you want this in the DOS section?
|
|||
23 Dec 2010, 00:25 |
|
bitRAKE 23 Dec 2010, 03:31
Copy-n-Paste from web, but it looks like it'd work.
Code: ; Input: ; ; DS:SI = offset to input buffer ; (first byte specifies size) ; Input: mov ah, 01h ; Select DOS "Input with echo" function mov cl, [ di ] ; Grab size of buffer into CL (max size) mov ch, cl ; Copy into CH (current count) inc di ; Advance to start of actual buffer NextChar: int 21h ; Input character from "stdin" cmp al, 0Dh ; Is it ENTER? je EndOfInput ; Yes, then terminate early cmp al, 08h ; Is it backspace? jne CarryOn ; No, then skip over backspace processing cmp ch, cl ; Are we at the start of the buffer? je NextChar ; Yes, ignore backspace as we can't go back ; before the beginning of the buffer dec di ; Move back a character in the buffer inc ch ; Increment count back up mov ah, 02h ; Select DOS "display output" mov dl, 20h ; A space to clear old character int 21h ; Print it! mov dl, 08h ; A backspace character moves left ; (non-destructive) int 21h ; Print it! mov ah, 01h ; Restore DOS "input with echo" function jmp NextChar ; Jump to get next character CarryOn: mov [ di ], al ; Store input into buffer inc di ; Advance to next character in buffer dec ch ; Decrement count of characters jnz NextChar ; While there's still room in buffer, ; do it all again EndOfInput: ret (Merry Christmas, to you and your instructor.) |
|||
23 Dec 2010, 03:31 |
|
bitRAKE 23 Dec 2010, 14:45
vicky wrote: Thanks a lot for your copy'n paste code But it didn't work. It didn't give any error too. Should i insert sth in it? Code: lds si,[iBuffer] call Input . . . iBuffer db 42,42 dup ? |
|||
23 Dec 2010, 14:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.