Overview
- What Is 80x86 Assembler?
- This is the native language for most of the world's PCs. It is fast and
dangerous. It gives you a 5-to-10 performance improvement over the best C
compilers.
- Portability
- Very portable to all compatible CPU's. Comes in various varieties,
following the evolution in 80x86 CPU's. The lowest-common denominator is the
16-bit 8086.
- Pros and Cons
- Pros - can't get it faster; can't make it smaller. Cons: multiply your
development and maintenance costs by ten.
- How To Get It
- There are various free and shareware assemblers around, which are not all
compatible in terms of syntax. The 'standards' are the Borland TASM and
Microsoft MASM products.
- Libero Supports
- MS MASM 5.0: .com files, .exe files, and subroutines.
Working With 80x86 Assembler
Example of code
Code fragments:
;**************** MODULE FUNCTION NAME *****************
MODULE module_function_name
ret ; All modules end in 'ret'
ENDMODULE
private_function_name proc near
mov the_next_event,ok_event
raise_exception error_event
endp
A fuller example.
Specific Schema Options
- -opt:model=com - generate code for a .COM program. This is the
default model.
- -opt:model=exe - generate code for an .EXE program.
- -opt:stack_size=nnnn - size of stack for .EXE program; default is
1024.
- -opt:model=lsub - generate code for a large-model subroutine using
the Microsoft/Borland C calling convention.
The schema provides these data items, macros, and functions (above the
standard ones provided by all schemas):
- msg_helptext - example of help message; change to suit (COM, EXE
only).
- arg_text db 128 dup(0) - command line arguments, null-terminated
(COM, EXE only).
- arg_size db 0 - size of arguments (0 = none) (COM, EXE
only).
- arg_help db 0 - 1 if /? was specified on command line, else 0
(COM, EXE only).
- newline db '\n',0 - newline as null-terminated string.
- the_next_event dw 0 - next event from module.
- the_exception_event dw 0 - exception event from module.
- exception_raised db 0 - 1 if exception raised.
- feedback db 0 - return code to system.
- xxxx_event - macro: defined for each event in the dialog, where
'xxxx' is the name used in the dialog.
- terminate_event - macro: when you move this to the_next_event,
the state machine halts.
- raise_exception - macro: raises an exception and sets
the_exception_event to the event specified.
- pushr - macro: push one or more registers onto stack.
- popr - macro: pop one or more registers from stack.
- jmps - macro: short jump.
- echo - function: prints null-terminated message at DS:SI. The
sequence \n is treated as newline. All registers are safe except flags.
- echoch - function: prints character in AL using BIOS tty
function. Does not change any registers except the flags.
- echonum - function: displays the value in AX as a signed decimal
number with one leading space, and optional sign. Does not change any
registers except the flags. Number is in range 32768..32767
- pause - function: waits for a keystroke; if [Esc] pressed, exits
program. Does not change any registers except the flags.
Programming with the COM model
Programming with the EXE model
Programming with the LSUB model
Programming with all models
- Do not rely on registers being safe between modules. The dialog code
uses these freely without saving them.
- You can freely use any of the working registers (AX, BX, CX, DX, ES, DS,
DI, SI) in a module function.
- In a LSUB model program, do not change BP.
- In an EXE or LSUB model program, ES is initialised to be equal to
DS.