flat assembler
Message board for the users of flat assembler.
Index
> DOS > what is the problem with this code it doesn't open file. |
Author |
|
ManOfSteel 17 Apr 2010, 14:32
|
|||
17 Apr 2010, 14:32 |
|
rCX 17 Apr 2010, 14:45
I happen to have this example demonstrating what ManOfSteel said
open.asm Code: org 100h use16 MaxFileSize = 256 ;Open the file. mov ah,3Dh mov al,00h ;Open file as read only mov dx,FileName ;dx = file name int 21h ;returns: ax = file handle ;Read its text. mov bx,ax ;bx = file handle mov ah,3Fh mov cx,MaxFileSize ;cx = max number of bytes to read mov dx,FileData ;dx = place to put text int 21h ;returns: ax = ActualFileSize ;"$" terminate text. mov di,ax ;di = ActualFileSize add di,FileData ;di = FileData + Actual File Size mov al,"$" ;al = "$" terminator stosb ;Print text. mov ah,9h mov dx,FileData int 21h ;End the program and close all files. mov ah,4Ch mov al,00h ;return 0 to DOS int 21h FileName db "test.txt",0 FileData db MaxFileSize+1 dup (?) test.txt Code: Hello, World! Remember, Ralf Brown's interrupt list is your friend |
|||
17 Apr 2010, 14:45 |
|
ring0 21 Apr 2010, 00:04
Thankyou ManOfSteel and rCX. I have a question concerning the use of this type of code under Windows.
I have an old DOS game. It has the ability to save and load the state of play. I run this game under WindowsXP on a FAT32 partition. The filenames in use are all 8.3 and everything works normally. Since this is a DOS game it occurs to me that the game code will use DOS INT 0x21 for the file operations. I understand that Windows can trap and redirect interrupts. Now, in relation to my work I sometimes have the need to open a data file, make a few changes to the raw data and resave the file for processing by some windows application. So to my question: Can I reliably use a simple com file with int 0x21 and execute it under Windows to accomplish this type of task? What are the issues surrounding this approach? e.g. are there particular functions that should be avoided? |
|||
21 Apr 2010, 00:04 |
|
ManOfSteel 21 Apr 2010, 00:20
I haven't coded for MSDOS in years, and for frequent (or rather infrequent) use I stopped at Windows 2000 due to my machines' low specs, so I don't really know for sure how XP and later behave with MSDOS programs. But on all older systems I've never had any problem running my old MSDOS programs or 15 years old programs (and games) and I expect XP to be very similar to 2000 in that area.
So is your work related to this game or what, because if you're using Windows, then why not also code for it using its API? |
|||
21 Apr 2010, 00:20 |
|
ring0 21 Apr 2010, 22:52
The game is not related to my work. The scenario is:
I want to be able to write a small application very quickly to make some changes to a data file. The computers at work do use XP so yes I could use the Windows API but that would require a bit of learning on my part. So I was asking is it possible to just throw it together as a DOS com and run that under windows - I guess I will just give it a try. Thanks. |
|||
21 Apr 2010, 22:52 |
|
baldr 22 Apr 2010, 04:51
ring0 wrote: …I could use the Windows API but that would require a bit of learning on my part. |
|||
22 Apr 2010, 04:51 |
|
rugxulo 22 Apr 2010, 21:06
ring0, you should have no problem on 32-bit Windows, but it's 64-bit that won't allow DOS at all. Well, and since you're talking about games, Vista and 7 don't allow DOS graphics at all, so yeah, you will need DOSBox.
It might actually be easier to just use C or Pascal or some other HLL that can be easily compiled for whatever platform (including Windows) in this case. |
|||
22 Apr 2010, 21:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.