Assembler - String einlesen
|
|
Seite: 1 |
| Autor |
|
|
Koj |
Assembler - String einlesen - Beitrag verfasst:
12.07.2007, 18:58 Uhr |
|
[ Gastposter ]
|
Moin,
kann mir jemand sagen, wie man mit den BIOS-Ints einen String von der Tastatur einlesen kann?
|
| |
|
Nach Oben  |
|
|
Koj |
Assembler - String einlesen - Beitrag verfasst:
29.07.2007, 14:56 Uhr |
|
[ Gastposter ]
|
Hab was gefunden:
| Code: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
jmp end_data
strCmd dw 256
nCmdSize db 1
cmdLen db 255
end_data:
_get_cmd:
mov BYTE[nCmdSize],0x00 ; set 0 cmd length
mov di,strCmd
_get_cmd_begin:
mov ah,0x10 ; read a char
int 0x16
cmp al,0x08; check back space
je _backspace
cmp al, 0x0D ;check if Enter pressed
je _enter_key
mov bh,[cmdLen]
mov bl,[nCmdSize]
cmp bh,bl ; is max len reached ?
je _get_cmd_begin
mov [di],al ; add it to buffer
inc di
inc BYTE[nCmdSize] ;increment counter
mov ah,0x0E ; Display char
mov bl,0x07
int 0x10
jmp _get_cmd_begin;
_backspace:
mov bh,0x00
mov bl,[nCmdSize]
cmp bh,bl ; if counter = 0 do nothing
je _get_cmd_begin
dec BYTE[nCmdSize]
dec di
mov ah,0x03 ; read cursor position
mov bh,0x00
int 0x10
cmp dl,0x00
jne _move_back
dec dh
mov dl,79
mov ah,0x02
int 0x10
mov ah,0x09 ;display
mov al,' '
mov bh,0x00
mov bl,0x07
mov cx,1
int 0x10
jmp _get_cmd_begin
_move_back:
mov ah,0x0E
mov bh,0x00
mov bl,0x07
int 10h
mov ah,0x09
mov al,' '
mov bh,0x00
mov bl,0x07
mov cx,1
int 0x10
jmp _get_cmd_begin
_enter_key:
mov BYTE[di],0x00
ret
|
|
Aber wo stehts jetz der string drinne?
|
| |
|
Nach Oben  |
|
|
Ich |
schnelle antwort - Beitrag verfasst:
23.01.2008, 8:56 Uhr |
|
[ Gastposter ]
|
> Hab was gefunden:
fast korrekt...
| Code: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
use16
org 0x0100 ; !!! DOS only !!!
jmp @f
strCmd rb 256
nCmdSize db 0 ; OUT
cmdLen db 255 ; IN: Max
@@:
_get_cmd:
mov BYTE[nCmdSize],0 ; set 0 cmd length
mov di,strCmd
_get_cmd_begin:
mov ah,0x10 ; read a char
int 0x16
cmp al,8; check back space
je _backspace
cmp al, 0x0D ;check if Enter pressed
je _enter_key
mov bh,[cmdLen]
mov bl,[nCmdSize]
cmp bh,bl ; is max len reached ?
je _get_cmd_begin
mov [di],al ; add it to buffer
inc di
inc BYTE[nCmdSize] ;increment counter
mov ah,0x0E ; Display char
mov bl,7
int 0x10
jmp _get_cmd_begin;
_backspace:
cmp BYTE [nCmdSize],0 ; if counter = 0 do nothing
je _get_cmd_begin
dec BYTE [nCmdSize]
dec di
mov ah,3 ; read cursor position
mov bh,0
int 0x10
cmp dl,0
jne _move_back
dec dh
mov dl,79
mov ah,2
int 0x10
mov ah,9 ;display
mov al,' '
mov bh,0
mov bl,7
mov cx,1
int 0x10
jmp _get_cmd_begin
_move_back:
mov ah,0x0E
mov bh,0
mov bl,7
int 10h
mov ah,9
mov al,' '
mov bh,0
mov bl,7
mov cx,1
int 0x10
jmp _get_cmd_begin
_enter_key:
mov BYTE[di],0 ; Terminate string with 0
ret
|
|
> Aber wo stehts jetz der string drinne?
Im buffer "strCmd"
|
| |
|
Nach Oben  |
|
| Information |
| Wo bin ich? |
|
Programming Community » Sprachen » Rund um die Programmierung » Assembler - String einlesen |
| Rechte |
|
Du darfst:
Beiträge lesen,
Themen eröffnen,
auf Beiträge antworten und hier
keine Umfragen erstellen |
| Statistik |
|
Seit dem 31.07.2002 (3476 Tage) wurden 7013 Beiträge in 1977 Themen verfasst. |
|
Wir haben 1278 User und begrüßen unser neustes Mitglied:
g.schief
|
Rekord: 8 registrierte waren gleichzeitig hier (27.07.2006, 14:54 Uhr). Im Moment: 0 registrierte Benutzer und 1 Gast online!
|
|