flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > How to add some spaces to string |
Author |
|
Mac2004 02 Oct 2007, 17:17
Your english is ok, so there is no need to be sorry for that!
You could use second buffer filled with spaces. Then just copy the original string to the new buffer and there you have the filename patched with spaces. regards, Mac2004 |
|||
02 Oct 2007, 17:17 |
|
Dex4u 02 Oct 2007, 18:04
So you should use capitals letters, and put space to make the name up to 8 or 11, if there is no extension, so file1 would be written as
Code: filename db "FILE1 " and file1.bin as Code: filename db "FILE1 BIN" |
|||
02 Oct 2007, 18:04 |
|
gangsta-dogg 02 Oct 2007, 19:09
Quote: You could use second buffer filled with spaces. Then just copy the original string to the new buffer and there you have the filename patched with spaces. please give me some code sample Quote: So you should use capitals letters, and put space to make the name up to 8 or 11, if there is no extension, so file1 would be written as filename db "FILE1 ", filename db "FILE1 BIN" this method is not right for my code, I get filename string from keyboard And I have another problem: I write some GOS(real-time OS), and it's work, I load bin program from kernel to adress 0800h:0000h and jump to this code, it's works, but I can't return to kernel ORG 1600h adress... help me please... |
|||
02 Oct 2007, 19:09 |
|
edfed 02 Oct 2007, 23:33
you can make a call far and then a ret far
or jmp to the kernel address like you jmp to bin be sure that your stack don't override the kernel code too |
|||
02 Oct 2007, 23:33 |
|
gangsta-dogg 03 Oct 2007, 08:21
Quote:
thanks for help |
|||
03 Oct 2007, 08:21 |
|
ManOfSteel 03 Oct 2007, 10:25
Quote: this method is not right for my code, I get filename string from keyboard It should work even if you get the filename from the keyboard and it contains a dot between the name and the extension. It's straightforward, you just have to use string manipulation instructions or the usual cmp and mov instructions to change the input string into a FAT12 filename. eg: 1. you get the filename from the user (eg: "File.asm"); 2. you UPCASE each character and copy them from there to your buffer until you find a dot (eg: "FILE"); 3. you skip the dot; if your buffer is not already 8 bytes long, you pad it with spaces until it is (eg: "FILE "); 4. you UPCASE the first 3 characters after the dot (the extension) and copy them right after the padding (eg: "FILE ASM"). You can also check if there is no extension as Dex4u said. You can begin your search for the extension dot from the end of the filename instead of the beginning so that you wouldn't use parts of the name as an extension if the user typed a dot in his filename (eg: "file.1.asm"); you'd end up with "FILE 1.a" instead of "FILE.1 ASM". |
|||
03 Oct 2007, 10:25 |
|
gangsta-dogg 03 Oct 2007, 14:01
Quote:
please give me code sample |
|||
03 Oct 2007, 14:01 |
|
Mac2004 03 Oct 2007, 19:18
gangsta-dogg: Here's a short (untested) example what I meant. I hope this helps....
Code: ;clear destination buffer ;------------------------ mov bx,destination_buf ;get secondary buffer ptr mov cx,11 ;clear 11 characters clear: mov byte[bx],' ' ;fill up with space char inc bx loop clear ;do 11 chars ;copy the source filename to the destination buffer ;--------------------------------------------------- mov si,source_name ;get source ptr mov di,destination_buf ;get destination ptr mov cx,11 ;11 charcaters is the max copy: mov al,byte[si] ;get a byte from the source cmp al, 0 ;is this the end of the source str? jz done mov byte[di],al ;save the byte into the destination str inc si inc di loop copy done: destination_buf: times 13 db 0 source_name: db "FILE1",0 |
|||
03 Oct 2007, 19:18 |
|
Dex4u 03 Oct 2007, 19:30
gangsta-dogg wrote:
See the source code of MiniDos, it will do all that ManOfSteel listed. http://board.flatassembler.net/topic.php?t=5275&start=0 |
|||
03 Oct 2007, 19:30 |
|
gangsta-dogg 04 Oct 2007, 06:55
Quote:
yea, now i'ts works, big thanks! Quote:
ok, thanks Dex4u! MiniDOS source is realy help me too... P.S. DexOS - is good project, respect! |
|||
04 Oct 2007, 06:55 |
|
Mac2004 04 Oct 2007, 17:12
gangsta-dogg: I'am glad to help!
regards, Mac2004 |
|||
04 Oct 2007, 17:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.