Given that there are still a lot of 16-bit code fans, I've updated DosBasic, the little brother of MasmBasic. Here is an example:
include \masm32\MasmBasic\DosBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0) the complete MasmBasic library
Init ; open (http://\masm32\masmbasic\dosbasic.inc) the DosBasic include file - inspired by DednDave
mov dx, Chr$("DOS is fun", 13, 10, "isn't it?$") ; display the message
mov ah, 9 ; the traditional DOS way,
int 21h ; ending with the $ delimiter
mov cx, Chr$(13, 10, "More fun") ; display the message
Print cx, 13, 10 ; using the cx register
Print "Real fun", 13, 10 ; the simplest option
Print Str$(123), " is 123", 13, 10 ; even that one works - Str$ takes immediates, ax, al, ah, si, ...
Print cx, " again", 13, 10 ; Print and Str$ do not trash cx
mov cx, Input$("Type something and hit Enter: ")
Open "O", #1, "MyTyping.txt"
Print #1, cx ; save the typed text to file
Close #1
Print cx, " was typed and written to file, now we are reading it back", 13, 10, 10
Make$ My$, 60000 ; let's create a fat buffer
FileRead My$, "MyTyping.txt"
.if Carry?
Print "FileRead ERROR", 13, 10
.else
Print Str$(ax), ' bytes read from "MyTest.txt" - contents:', 13, 10, 10, "["
Print My$, "]", 13, 10, 10
.endif
Inkey "bye" ; wait for a key
Exit ; ExitProcess, DOS style
end start
"Library" attached - it will be integrated into future MasmBasic releases.
The DosBasic library is now integrated - download here (http://masm32.com/board/index.php?topic=94.0).
Update 9 Nov 2013: DosBasic has some new functions, e.g. CL$() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1011), Instr_() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1153), Exist() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1049) and Seek (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1036).
Furthermore, the MasmBasic editor autodetects now a 16-bit program and uses appropriate settings, like e.g. the 16-bit linker; if an int 3 is spotted in the text, RichMasm launches automatically debug.exe MyProgram.exe plus some args if set with OPT_Arg1. PM me for details...
Init Initialise DosBasic; optional: desired stack, e.g. Init 2000h
Exit DOS equivalent to ExitProcess; optional: exit code (default: 0)
Chr$ Print Chr$("Line 1", 13, 10, "Line 2")
CL$ Print CL$(), " is the commandline", 13, 10
Instr_ Print Str$(Instr_("A test", "test", 3)), 9, " is 3", 13, 10 ; startpos n is optional
m2m m2m dest, source ; ok for DWORD & WORD destinations
Inkey Inkey "Hello"
Val32 Val32 pStr/ ValX pStr
Val Val pStr/ ValX pStr
ValX ValX pStr/ push si
Str$ Print Str$(eax) or Print Str$(cx) or Print Str$(al) etc
Hex$ Print Hex$(eax) or Hex$(ax) or Hex$(al) or Hex$(123) etc
Psp mov ax, Psp(0)
Exist .if Exist("MyFile.txt")
Open Open "O", #1, "Test.txt"; modes are Output, Input, Update and Append
Seek Seek #1, ecx ; takes immediate, reg32, reg16, var16, var32
Close Close #n
Print Print "Test", 13, 10
FileRead FileRead dest, fname
Make$ Make$ TheName, Bytes
Time$ Print Time$()
Input$ mov si, Input$("Type something and hit Enter: ")
Jochen,
thank you for providing the stuff. :t
Gunther