| | |
EMU8086 OS Command Comparison
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2009
Posts: 8
Reputation:
Solved Threads: 0
Okay, this is an annoying problem i'm making a command line operating system bootable from a floppy disk and the way i'm testing it atm is by inputting a command and outputting it.
The reason for this is that i want to know EXACTLY what its doing with the string and how it is being referenced etc so that i can compare it with a list of commands. The code function 'check' doesnt work at the moment and is very messy what with me playing around with it alot.
Code that would compare the inputted string with a command would be very helpful along with a thorough description OR a description of how i would go about it.
Currently the code is:
The reason for this is that i want to know EXACTLY what its doing with the string and how it is being referenced etc so that i can compare it with a list of commands. The code function 'check' doesnt work at the moment and is very messy what with me playing around with it alot.
Code that would compare the inputted string with a command would be very helpful along with a thorough description OR a description of how i would go about it.
Currently the code is:
Assembly Syntax (Toggle Plain Text)
;boot code ;========================================== ;Load boot directive #MAKE_BOOT# ;Set boot memory address org 7c00h push cs ;cs = ds pop ds ;========================================== ;print welcome ;========================================== begin: lea si,welcomeMessage call print ;========================================== ;gets command ;========================================== mov bh,0 getCommand: lea si,message call print mov dx,offset buffer mov ah,0ah ;read string subroutine int 21h ;get string call check jmp getCommand ;========================================== ;reboot ;========================================== ;store 'magic' number at 0040h:0072h ; 0000h = cold reboot ; 1234h = warm reboot mov ax, 0040h mov ds,ax mov w.[0072h],0000h jmp 0FFFFh:0000h ;reboot! ;========================================== ;procedures ;========================================== print proc ;arguments: string is in SI nextChar: cmp b.[si],0 ;check for null termination jz stop mov al,[si] ;get next char mov ah,0eh ;teletype subroutine int 10h ;print inc si ;next lesson jmp nextChar ;type next char stop: ret ;return to caller print endp check proc ;arguments: string must be in SI getNo: lea di,help checkCom: xor bx,bx lea si,help mov bx,offset buffer - 1 mov ah, 09 temp: inc bx mov dx,[bx] int 21h cmp dx,0 jnz temp ret check endp ;========================================== ;vars ;========================================== lfcr equ 13,10,0 welcomeMessage db "Welcome to MYCROS!" db 13,10, "For a list of commands type 'help'" db lfcr message db 13,10, "Command: ",0 buffer db 50,50 dup " " help db "help",0
•
•
Join Date: Sep 2009
Posts: 8
Reputation:
Solved Threads: 0
0
#4 Oct 19th, 2009
thanks wild goose so i assume that you mean some thing like (ignore syntax its pseudo code)
commandsArray(command1,command2,command3) etc
and then it would iincrement through each one to find the code?
i can compare one letter at a time but i'm not sure how i would go about checking it one letter at a time for a whole word :/ any ideas?
commandsArray(command1,command2,command3) etc
and then it would iincrement through each one to find the code?
i can compare one letter at a time but i'm not sure how i would go about checking it one letter at a time for a whole word :/ any ideas?
1
#5 Oct 19th, 2009
There's usually hundreds of commands in a scripting language so would mean more like...
Being alpha sorted, the matching command record can be found quicker.
Then use the eumerationId for a code vector table.
Assembly Syntax (Toggle Plain Text)
iApple = 1 iPear = 2 iCorn =3 iDog = 4 iGrape= 5 xApple db 'Apple',0 xCorn db 'Corn',0 xDog db 'Dog',0 xGrape db 'Grape',0 xPear db 'Pear',0 Food STRUCT Id DWORD ? Name DWORD ? ENDS ; Alpha sorted for speed Label FoodTable Food < offset xApple, iApple > Food < offset xCorn, iCorn > Food < offset xDog, iDog > Food < offset xGrape, iGrape > Food < offset xPear, iPear > LabelFoodTableEnd
Being alpha sorted, the matching command record can be found quicker.
Then use the eumerationId for a code vector table.
Last edited by wildgoose; Oct 19th, 2009 at 2:43 pm.
•
•
Join Date: Sep 2009
Posts: 8
Reputation:
Solved Threads: 0
0
#6 Oct 19th, 2009
So you mean that by creating the commands as you said and asigning them id's i can effectively do this:
sound about right? if it is then i get what you mean otherwise i've somewhat missed the point
Assembly Syntax (Toggle Plain Text)
PSEUDO CODE =] create all commands following a set structure go to first id compare input to the first id's string if not equal increment the id and try again and so on if they are equal jump to the corresponding code block and execute code
sound about right? if it is then i get what you mean otherwise i've somewhat missed the point
1
#7 Oct 19th, 2009
Almost.
That's your initial get the code working step.
Then, once it works, since the text is alpha sorted, and the records are fixed size, do a binary search.
Look a record COUNT/2, Is it, above or below, Divide in 1/2 try again.
So essentially very fast command search since they're alpha sorted.
That's your initial get the code working step.
Then, once it works, since the text is alpha sorted, and the records are fixed size, do a binary search.
Look a record COUNT/2, Is it, above or below, Divide in 1/2 try again.
So essentially very fast command search since they're alpha sorted.
Last edited by wildgoose; Oct 19th, 2009 at 6:25 pm.
0
#10 Oct 20th, 2009
Not familiar with EMU8086 and assuming you can't use an alternate tool you can do it this way!
Taking advantage of the scalar *8; {*2, *4, *8 } and that each record is 8 bytes in length!
NOTE: In that STRUCT I just realized I had the name and string Id's names swapped accidently. It should have been Name for the string offset and Id for the command enumeration that you would use in the function lookup! There are actually many ways you can do this table to function lookup.
Asm Syntax (Toggle Plain Text)
; Alpha sorted for speed Label FoodTable DWORD offset xApple, iApple DWORD offset xCorn, iCorn DWORD offset xDog, iDog DWORD offset xGrape, iGrape DWORD offset xPear, iPear
Asm Syntax (Toggle Plain Text)
; ebx is index 0...Count-1 mov eax,FoodTable[ ebx*8 ] ; Get a 32-bit String offsets mov eax,FoodTable[ ebx*8 + 4 ] ; Get a 32-bit String Id
NOTE: In that STRUCT I just realized I had the name and string Id's names swapped accidently. It should have been Name for the string offset and Id for the command enumeration that you would use in the function lookup! There are actually many ways you can do this table to function lookup.
Last edited by wildgoose; Oct 20th, 2009 at 3:12 pm.
![]() |
Similar Threads
- C command-line I/O question (C++)
- Restarting a windows 2000 computer from the command line (Windows NT / 2000 / XP)
- DOS "ROUTE" command (Visual Basic 4 / 5 / 6)
- command line (OS X)
- Graphics Card issues Stop Command??? (Windows NT / 2000 / XP)
Other Threads in the Assembly Forum
- Previous Thread: Question about arrays
- Next Thread: convert number to ascii in mips?
| Thread Tools | Search this Thread |
Tag cloud for Assembly





