BCOS 80x86 Include FilesProject Map
Common 80x86 Assembly Language Include File
File: 80x86/inc/asm.inc
 

Copyright © Brendan Trotter 2008

This material is provided by Brendan Trotter as a service to interested parties on an "as-is" basis, for informational purposes only. Brendan Trotter assumes no responsibility for any errors or omissions. Brendan Trotter does not make, and expressly disclaims any, representations or warranties, express or implied, regarding this web page and the host web site, including, without limitation, any implied warranties of merchantability or fitness for a particular purpose.

Under no circumstances shall Brendan Trotter, or any associated contributors, volunteers or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with this web page, the host web site, or the materials contained herein.

All materials contained in these files are protected by copyright laws, and may not be reproduced, republished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of Brendan Trotter. You may make one copy of this web page for your personal and non-commercial use only, without altering or removing this copyright notice or any other notice.




Assembler Related Macros

This file contains general assembly related macros and definitions that are used throughout the project (in all CPU modes).


Simple Defines and Macros

These are fairly obvious...

15: %macro clr 1
16:       xor %1,%1
17: %endmacro
18: 
19: 
%define nl 0x0A                     ;New line


Multiple Push/Pop Macros

These macros just make code cleaner. For example, pushes eax, ebx, ecx is easier to read than push eax, then push ebx followed by push ecx. The pops macro does the reverse!

29: %macro pushes 1-*
30: %rep %0
31:           push %1
32: %rotate 1
33: %endrep
34: %endmacro
35: 
36: 
37: 
%macro pops 1-*
38: %rep %0
39: %rotate -1
40:           pop %1
41: %endrep
42: %endmacro


TODO Macro

Sometimes I need to leave certain pieces of code until other things are implemented. When this happens I use this macro so that later on I can define TODOerrors and the assembler will show me every spot where the code still needs work.

54: %macro TODO 0
55: %ifdef TODOerrors
56:       %error 'Needs some work done here.'
57: %endif
58: %endmacro


Macro for Conditional Debugging Markers

This macro inserts some special tokens into the code, and is normally placed before each assembly language subroutine. The kernel's critical error handler will search for the preceding debugging marker and report which source file the critical error occured in. In addition, I have a utility to extract these debugging markers (built into my "System Build Utility").

The idea is to make it easy to find bugs - if something crashes it's nice to have the kernel tell you which source file to look at!

Of course if DEBUG isn't defined the debugging markers are ommitted, so if I'm confident that the code is completely stable I can get rid of the debugging markers (or bring them back when I find out it wasn't as stable as I'd hoped).

Dedicated assembly programmers will note that 0xCC corresponds to the CPU's int3 opcode, and 0x90 corresponds to the nop opcode, so if something goes horribly wrong and the marker itself is executed then the first int3 will cause a breakpoint exception.

81: %macro MARK 0
82: %ifdef DEBUG
83:         dd 0xCCCC9090,__LINE__
84:         db __FILE__,0
85:       dd 0x9090CCCC
86: %endif
87:       align 4
88: %endmacro


Generated on Sun Oct 25 14:05:34 2009