News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DosBasic

Started by jj2007, December 20, 2011, 01:39:52 AM

Previous topic - Next topic

jj2007

Here is MasmBasic's little brother for 16-bit nostalgics. Don't expect miracles, but for some very BASIC things I hope it might be useful.

Quoteinclude \masm32\MasmBasic\DosBasic.inc   ; needs link16.exe; download the library
; Warning: The syntax looks like 32-bit MasmBasic, but the functionality of some commands is strongly reduced

  Init
  Print "----- Starting testbed at "
  Print Time$(), " ...", 13, 10
  mov al, 12h
  Print Hex$(al), " = al as Hex$", 13, 10
  mov ch, 34h
  Print Hex$(ch), " = ch", 13, 10
  mov dx, 5678h
  Print Hex$(dx), " = dx", 13, 10
  Print Hex$(12345), "h = 12345d", 13, 10
  Print Hex$("AB")
  Print Hex$("CD"), 'h = "ABCD"', 13, 10
  call MyProc
  Make$ My$, 60000
  Make$ Your$, 4400
  FileRead My$, "MyTest.txt"
  .if Carry?
   Print "FileRead ERROR", 13, 10
  .else
   Print Str$(ax), ' bytes read from "MyTest.txt" - contents:', 13, 10
   Print My$, 13, 10
  .endif
  mov cx, Input$(13, 10, "Type something, then hit Return: ")
  Print cx, " is what you typed", 13, 10
  Print "... testbed ending at "
  Print Time$(), " -----", 13, 10
  Inkey "bye"      ; wait for a key
  Exit         ; ExitProcess, DOS style

MyProc proc
  Open "O", #1, "MyTest.txt"
  Print #1, "Hello", 13, 10, "World", 13, 10
  Print #1, "how are you today?"
  Close #1   
  Open "O", #1, "CON:"   ; CON is a valid filename
  Print #1, 13, 10, "Hello World to CON:", 13, 10
  Close #1
  mov dx, Chr$("DOS is fun", 13, 10, "isn't it?$")   ; display the
  mov ah, 9      ; message the
  int 21h         ; traditional way
  mov cx, Chr$(13, 10, "More fun")   ; display the message
  Print cx, 13, 10   ; using the cx register
  Print Str$(cx), " is cx as ptr to the .data section", 13, 10
  Print "Real fun", 13, 10   ; the simplest option
  mov ax, 123*256
  Print Str$(ah), " is 123", 13, 10   ; even that one works - Str$ takes immediates, ax, al, ah, si, ...
  Print cx, " again (cx is still alive)", 13, 10   ; Print and Str$ do not trash cx
  ret
MyProc endp
end start

Output:
----- Starting testbed at 02:54 ...
12 = al as Hex$
34 = ch
5678 = dx
3039h = 12345d
41424344h = "ABCD"

Hello World to CON:
DOS is fun
isn't it?
More fun
379 is cx as ptr to the .data section
Real fun
123 is 123

More fun again (cx is still alive)
32 bytes read from "MyTest.txt" - contents:
Hello
World
how are you today?

Type something, then hit Return: DosBasic is great!
DosBasic is great! is what you typed
... testbed ending at 02:54 -----
bye



EDIT: MakeIt.bat attached. Use it from qEditor's Project menu.

dedndave

very cool, Jochen   :U