| | |
Input Characters
Thread Solved |
Hello,
I'm beginning in the OS development(In Assembly, Nasm as Assembler) and i need to implement a command-line on it, but i don't know how to do this, but what i want to say as command-line is like MS-DOS or UNIX:
But i don't know how to do the input method(ver in the command). In the repetition of the
The only thing that i need too know how to do is the input characters method.
Thanks,
Nathan Paulino Campos
I'm beginning in the OS development(In Assembly, Nasm as Assembler) and i need to implement a command-line on it, but i don't know how to do this, but what i want to say as command-line is like MS-DOS or UNIX:
Assembly Syntax (Toggle Plain Text)
> ver BerlOS v.0.0.1 > _
> before the user input things i know, i only need to do a JMP to the section that prints the > and the input method, if it's needed, here is my code: asm Syntax (Toggle Plain Text)
[BITS 16] ; 16 bit code generation [ORG 0x7C00] ; ORGin location is 7C00 JMP short main ; Jump past disk description section NOP ; Pad out before disk description ; ------------------------------------------------------------------ ; Disk description table, to make it a valid floppy ; Note: some of these values are hard-coded in the source! ; Values are those used by IBM for 1.44 MB, 3.5" diskette OEMLabel db "BERL OS" ; Disk label - 8 chars BytesPerSector dw 512 ; Bytes per sector SectorsPerCluster db 1 ; Sectors per cluster ReservedForBoot dw 1 ; Reserved sectors for boot record NumberOfFats db 2 ; Number of copies of the FAT RootDirEntries dw 224 ; Number of entries in root dir LogicalSectors dw 2880 ; Number of logical sectors MediumByte db 0F0h ; Medium descriptor byte SectorsPerFat dw 9 ; Sectors per FAT SectorsPerTrack dw 18 ; Sectors per track (36/cylinder) Sides dw 2 ; Number of sides/heads HiddenSectors dd 0 ; Number of hidden sectors LargeSectors dd 0 ; Number of LBA sectors DriveNo dw 0 ; Drive No: 0 Signature db 41 ; Drive signature: 41 for floppy VolumeID dd 00000000h ; Volume ID: any number VolumeLabel db "BERL OS" ; Volume Label: any 11 chars FileSystem db "FAT12" ; File system type: don't change! ; End of the disk description table ; ------------------------------------------------------------------ main: MOV BX, 0 ; Disable blinking. MOV BH, 00h MOV BL, 07h ; Color settings MOV AL, 1 MOV BH, 0 MOV BL, 02h MOV CX, osmsgend - os_msg ; Calculate message size. MOV DL, 30 MOV DH, 0 PUSH CS POP ES MOV BP, os_msg MOV AH, 13h INT 10h JMP wel wel: MOV BH, 00h MOV BL, 07h MOV AL, 1 MOV BH, 0 MOV BL, 059 MOV CX, welcome_end - welcome ; Calculate message size. MOV DL, 32 MOV DH, 2 PUSH CS POP ES MOV BP, welcome MOV AH, 13h INT 10h JMP osmsgend welcome DB "Welcome !" welcome_end: os_msg DB "BerlOS v0.0.1" osmsgend: JMP $ ; Boot things TIMES 510-($-$$) DB 0 ; Fill the rest of the sector with zeros DW 0xAA55 ; Boot signature
Thanks,
Nathan Paulino Campos
You're using the 0x10 VIDEO BIOS services handler for your video handling so use the 0x16 KEYBOARD BIOS services handler for your keyboard handling!
Assembly Syntax (Toggle Plain Text)
; Get Keyboard value (and wait for press) mov ah,0 int 16h ; KEYBOARD ;ah=scan code al=ASCII character
After data entry, remove carriage return and set a terminator!
Create a master list of commands! A table lookup of string addresses and scan through the list one at a time and do a caseless string to data entered. When you find a caseless match you have your command. Then jump to the code to handle that command!
You could use a structure table that contains the pointer to the string, and address of the function.
Initially just write a string compare function and do a series of if-then's to find your matching string!
Create a master list of commands! A table lookup of string addresses and scan through the list one at a time and do a caseless string to data entered. When you find a caseless match you have your command. Then jump to the code to handle that command!
You could use a structure table that contains the pointer to the string, and address of the function.
Initially just write a string compare function and do a series of if-then's to find your matching string!
One step at a time
Visually inspect buffer to make sure the string is there intact!
Then work on a string compare function
Assembly Syntax (Toggle Plain Text)
xVer db 'Ver',0 Key db dup(128) Kscan db dup(128) xor bx,bx KeyIn: mov ah,0 int 16h ; KEYBOARD ;ah=scan code al=ASCII character mov Key[ bx ],al mov KScan[ bx ],ah inc bx cmp al,0dh ; Carriage return jne KeyIn ; bx = buffer Length mov Key[ bx - 1 ],0 ; Overwrite with terminator ; String now in buffer
Visually inspect buffer to make sure the string is there intact!
Then work on a string compare function
Assembly Syntax (Toggle Plain Text)
mov ax,offset KeyBuf mov dx,offset xVer call StrICmp jnc next ;;; Have a match! jmp done next: done:
Last edited by wildgoose; Aug 25th, 2009 at 3:51 pm.
Hello wildgoose,
Now i'm getting this errors:
http://img253.imageshack.us/img253/3381/errorb.png
Why?
Thanks!
Now i'm getting this errors:
http://img253.imageshack.us/img253/3381/errorb.png
Why?
Thanks!
If it's needed, here is the code:
Thanks!
asm Syntax (Toggle Plain Text)
[BITS 16] ; 16 bit code generation [ORG 0x7C00] ; ORGin location is 7C00 JMP short main ; Jump past disk description section NOP ; Pad out before disk description ; ------------------------------------------------------------------ ; Disk description table, to make it a valid floppy ; Note: some of these values are hard-coded in the source! ; Values are those used by IBM for 1.44 MB, 3.5" diskette OEMLabel db "BERL OS" ; Disk label - 8 chars BytesPerSector dw 512 ; Bytes per sector SectorsPerCluster db 1 ; Sectors per cluster ReservedForBoot dw 1 ; Reserved sectors for boot record NumberOfFats db 2 ; Number of copies of the FAT RootDirEntries dw 224 ; Number of entries in root dir LogicalSectors dw 2880 ; Number of logical sectors MediumByte db 0F0h ; Medium descriptor byte SectorsPerFat dw 9 ; Sectors per FAT SectorsPerTrack dw 18 ; Sectors per track (36/cylinder) Sides dw 2 ; Number of sides/heads HiddenSectors dd 0 ; Number of hidden sectors LargeSectors dd 0 ; Number of LBA sectors DriveNo dw 0 ; Drive No: 0 Signature db 41 ; Drive signature: 41 for floppy VolumeID dd 00000000h ; Volume ID: any number VolumeLabel db "BERL OS" ; Volume Label: any 11 chars FileSystem db "FAT12" ; File system type: don't change! ; End of the disk description table ; ------------------------------------------------------------------ main: MOV BX, 0 ; Disable blinking. MOV BH, 00h MOV BL, 07h ; Color settings MOV AL, 1 MOV BH, 0 MOV BL, 02h MOV CX, osmsgend - os_msg ; Calculate message size. MOV DL, 30 MOV DH, 0 PUSH CS POP ES MOV BP, os_msg MOV AH, 13h INT 10h JMP wel wel: MOV BH, 00h MOV BL, 07h MOV AL, 1 MOV BH, 0 MOV BL, 059 MOV CX, welcome_end - welcome ; Calculate message size. MOV DL, 32 MOV DH, 2 PUSH CS POP ES MOV BP, welcome MOV AH, 13h INT 10h JMP KeyIn ; ------------------------------------------ ; Keyboard input method xVer db 'Ver', 0 Key db dup(128) Kscan db dup(128) xor bx,bx KeyIn: mov ah,0 int 16h ; KEYBOARD ;ah=scan code al=ASCII character mov Key[ bx ],al mov KScan[ bx ],ah inc bx cmp al,0dh ; Carriage return jne KeyIn ; bx = buffer Length mov Key[ bx - 1 ],0 ; Overwrite with terminator ; String now in buffer mov ax,offset KeyBuf mov dx,offset xVer call StrICmp JMP osmsgend ; End of input characters method ; ------------------------------------------ welcome DB "Welcome !" welcome_end: os_msg DB "BerlOS v0.0.1" osmsgend: JMP $ ; Boot things TIMES 510-($-$$) DB 0 ; Fill the rest of the sector with zeros DW 0xAA55 ; Boot signature
Thanks!
Last edited by Nathan Campos; Aug 25th, 2009 at 5:19 pm. Reason: ...
Look at the line number that contains the error and look for things.
Line#35
You may need the label on the same line as instruction. Some assemblers require this, some don't!
main: MOV BX, 0 ; Disable blinking.
Line#70 and #71
;Key db dup(128)
;Kscan db dup(128)
Key db 128 dup(?)
Kscan db 128 dup(?)
Line#81,82 should then be fixed.
Line#88 mov byte ptr Key[ bx - 1 ],0 ; Overwrite with
terminator
Wrong label name
mov ax,offset Key
Don't know about 92
mov dx,offset xVer
Line#35
You may need the label on the same line as instruction. Some assemblers require this, some don't!
main: MOV BX, 0 ; Disable blinking.
Line#70 and #71
;Key db dup(128)
;Kscan db dup(128)
Key db 128 dup(?)
Kscan db 128 dup(?)
Line#81,82 should then be fixed.
Line#88 mov byte ptr Key[ bx - 1 ],0 ; Overwrite with
terminator
Wrong label name
mov ax,offset Key
Don't know about 92
mov dx,offset xVer
![]() |
Similar Threads
- setting an input text field width according to it's font size (HTML and CSS)
- how to count the char you input.. (C++)
- Limit input charachter (C++)
- String Input - Not Happening Second Time (C++)
- Tkinter user-input (Python)
- reading a same input twice from the console (C)
- State abbreviations (C++)
- 10, 20, 0 (C)
Other Threads in the Assembly Forum
- Previous Thread: Assembly Language Resources
- Next Thread: cant get ah = 0ah to work!
| Thread Tools | Search this Thread |





