Introduction

This starter pack is intended to be used by total beginners who need a quick entry to assembly programming particularly using FASM. This pack contains mostly macro routines, one each for 16-bit and 32-bit programming in DOS's environment.

Usage

These macros should be used whenever you need to see the effect of your code while you are programming. They enable you to debug your codes on-the-fly with the hope that in the end you'll be aware of your codes behavior at almost every point - and avoid hard to catch errors. 

It offers various routines and facilities such as checking the content of memory, registers, base conversions and much more so that you don't have to wait until completion to look for any errors. You can make the macro calls at any point of insertion and delete or comment them out once you are sure what happens at that debugged line. In some way, this routines resemble a debugger but you get to use it without having to exit your programming to see the effects.

For example, to see the effect of an XOR instruction against a value in AX register;

mov ax,101110001b
xor ax,0fff0h

Instead of guessing, you can now see its effect by calling prtreg macros, with binary (-b) switch to see what really took place to the bits

mov ax,101110001b
prtreg ax,-b
xor ax,0fff0h
prtreg ax,-b

which yields the following output, plus its binary representation;

ax:0171 [00000001_01110001]
ax:FE81 [11111110_10000001]

These macro routines should not however be used as part of your code or 'solution' as it may introduce performance penalties upon multiple calls to the same macro routines.

To use any of the macro routines, you should use the include directive;

include 'mac16.inc'  ;for 16-bit
include 'mac32.inc'  ;for 32-bit

These files should reside in the same folder/directory as your source file. Both have similar macro names for the same functionalities, although there are certain macros unique only to 16-bit or 32-bit file. Read the internal description.


Recommended Skeleton

In order for you to get along with the routines, you should use these recommended skeletons

For 16-bit Flat (COM format)
-----------------
org 100h
include 'mac16.inc'

<your codes here>

exitp
<your data here>
-----------------


For 16-bit Segmented (MZ format)
-----------------
format MZ
include 'mac16.inc'
entry start:main

segment start
main:
dsinit info
<your codes here>

exitp

segment info
<your data here>
-----------------

For this particular format, you need to define the segment names such as "start" for your code segments and "info" for your data segment. These are programmer-defined identifiers and you can rename it anyway you like it as long as it remains consistent throughout the program.

The "dseg" macro call is required if you need to initialize your data segment into the DS register or else your program will not read the yoour data in the data segment properly.

Another example:

For 16-bit Segmented (MZ format)
-----------------
format MZ
include 'mac16.inc'
entry code:start

segment code
start:
dsinit dseg
<your codes here>

exitp

segment dseg
x dw 45h   ;Sample data
y db 'C'   ;Sample data
-----------------


For 32-bit PE format (Flat)
--------------------
format PE console
include 'mac32.inc'

<your codes here>


exitp
<your data here>

.msimport
<do not add anything beyond this line>
--------------------


For 32-bit PE format (With sections)
--------------------
format PE console
include 'mac32.inc'
entry main

.code
main:
<your codes here>


exitp

.data
<your data here>

.idata
<do not add anything beyond this line>
--------------------

Both .idata and .msimport are required when you need to import all those external libraries from Windows and Microsoft run time services.

For descriptions on the use of each macro calls, you can refer to the header descriptions for each macro.


Terms and Conditions

There are no strict conditions for the use of this macro routines as long as you use it for educational purposes. You are free to duplicate and distribute them and make appropriate modifications to the existing routines. These macro routines are unoptimized and should not be used in a critical environment.

For any bug reports and inquiries, you can e-mail me or contact me via FASM board (fasmnewbie).

Good luck and welcome to Flat Assembler.

June 1st, 2014

soffianabdulrasad @ gmail . com
 