The Art of Assembly Language by Hyde Randall

The Art of Assembly Language by Hyde Randall

Author:Hyde, Randall [Randall Hyde]
Language: eng
Format: epub, mobi
Tags: COMPUTERS / Programming Languages / Assembly Language
ISBN: 9781593273019
Publisher: No Starch Press


Example 5-20. Main program that references external objects

program main; #include( "stdlib.hhf" ); begin main; mov( 2, Var2 ); mov( 3, Var1 ); Add1and2(); stdout.put( "Var1=", Var1, nl ); end main;

The main program references Var1, Var2, and Add1and2, yet these symbols are external to this program (they appear in unit Number1). If you attempt to compile the main program as it stands, HLA will complain that these three symbols are undefined.

Therefore, you must declare them external with the external option. An external procedure declaration looks just like a forward declaration except you use the reserved word external rather than forward. To declare external static variables, simply follow those variables' declarations with the reserved word external. The program in Example 5-21 is a modification to the program in Example 5-20 that includes the external declarations.

Example 5-21. Modified main program with external declarations

program main; #include( "stdlib.hhf" ); procedure Add1and2; external; static Var1: uns32; external; Var2: uns32; external; begin main; mov( 2, Var2 ); mov( 3, Var1 ); Add1and2(); stdout.put( "Var1=", Var1, nl ); end main;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.