flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > High Level DOS macros

Author
Thread Post new topic Reply to topic
me239



Joined: 06 Jan 2011
Posts: 200
me239 22 Feb 2011, 05:59
Hello everyone! Today I would like to post some macros I made with FASM for, but not limited to, DOS. These macros may not be the most efficient, but they blow QBasic out of the water when it comes to size (obviously). The macros go as the following:
print - accepts either null-terminated string, direct quotes, or numbers in a register to printed as decimal

input(my favorite) - accepts up to 255 characters and stores it in a predefined buffer

createfile - creates files. Accepts either quotes or string followed by permissions

openfile - opens files. Accepts either quotes or string followed by permisstions. handle
returned in BX

writefile - writes to file. Accepts quote marks or string followed by bytes to write and whether to append, prepend, or current location(2, 0, 1 respectively)

exit - exits program

newline - creates newline on the far left

keywait - pauses program and makes user press any key to continue


Here is a sample program using all functions
Code:
 
format MZ ; exe file
include 'macro.inc' ; include our macros
start:
  mov cx, 54d
  print "Hello, ", msg, cx ; prints 2 messages followed by number
  input buffer, 0ffh ; accept input into buffer up to 255 bytes
  createfile "hello.txt", 0 ; create file "hello.txt" as a readable writable file
  openfile "hello.txt", 2 ; open "hello.txt" as read/write permissions
  xchg ax, bx ; put file handle in BX
  writefile buffer, 0ffh, 2 ; append file, write 255 bytes of buffer
  newline
  print "Process Done!"
  exit
msg db "what is your name", 0
counter db 0 ; required as counter for input directive
buffer db 256 dup (0) ; 256 byte buffer. Extra byte is so that the string ends on 0
    

remember, all of this code(except file operations) can be modified to boot. Just replace "format MZ" with org 7c00h and round file off to 512 bytes.
ENJOY!!!


Description: Macros for DOS
Download
Filename: inp.inc
Filesize: 3.1 KB
Downloaded: 324 Time(s)



Last edited by me239 on 23 Feb 2011, 03:30; edited 1 time in total
Post 22 Feb 2011, 05:59
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 22 Feb 2011, 18:30
me239 wrote:

remember, all of this code can be modified to boot. Just replace "format MZ" with org 7c00h and round file off to 512 bytes.
ENJOY!!!

What about the openfile etc, do they not need dos ?.
Post 22 Feb 2011, 18:30
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 23 Feb 2011, 03:29
Dex4u wrote:
me239 wrote:

remember, all of this code can be modified to boot. Just replace "format MZ" with org 7c00h and round file off to 512 bytes.
ENJOY!!!

What about the openfile etc, do they not need dos ?.
Oh ya, nice call. No they are DOS only Sad
Post 23 Feb 2011, 03:29
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4347
Location: Now
edfed 25 Feb 2011, 22:16
fasm macro system as a programming language, to program langages, and then. very cool!
but where are the bloat ( ) % ? Laughing ho yeah, no need because of asm. Very Happy


for create file, openfil, etc... why not implement a basic file system???
make the brigde between DOS and your new file system to import files... and so on... the world don't comes in one day Smile
Post 25 Feb 2011, 22:16
View user's profile Send private message Visit poster's website Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 26 Feb 2011, 03:24
Very nice! I remember seeing something similar in MASM before ... MASMBasic, I think. It would be nice to have a FASM basic as well!
Post 26 Feb 2011, 03:24
View user's profile Send private message Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 172
Location: Maryland, USA
rCX 24 Mar 2011, 03:26
Post 24 Mar 2011, 03:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.