writing relocatable modular assembly program
Posted: Thu Jan 25, 2007 4:39 pm
Hello
I know how to write in asm when I decide where to store variables etc.
The easiest way for me is to write directly with POKE, I am not experienced in assemblers.
Now I want examples of asm code for modular programming using relocatable code.
for instance I need examples howto define hidden and exported variables in .data and .bss segments, I also want to have example of pointer to struct.
In other words I am very interested in examples of howto hide and export variables
encapsulated in .o relocatable. And how to use (import) that variables from another relocatable.
How to pass variable to subroutine in another .o by reference.
May be it will be easier for someone just translate the following oberon source to xa65 or ca65 asm syntax so I could understand
MODULE M1;
VAR a*,b,e- : SHORTINT; (* signed byte*)
(* note that a is exported and could be seen rw from other module *)
(* b is hidden*)
(* e is exported read only*)
PROCEDURE p*( VAR l : INTEGER); (*this procedure is exported*)
(*it could be called from other module *)
(* l is passed by reference or via pointer if you like to call it that way *)
VAR a, f : INTEGER; (* signed int *)
BEGIN
a := 5; (*assigning to local variable*)
b := 7;
END p;
PROCEDURE p1; (* hidden procedure, cannot be called from outside *)
BEGIN
END;
BEGIN
a := 7;
e := 9;
END M1.
------------------------------
MODULE M2;
IMPORT M1;
VAR a : INTEGER;
BEGIN
a := M1.a;
M1.p(a);
END M2
Thank you very much
I know how to write in asm when I decide where to store variables etc.
The easiest way for me is to write directly with POKE, I am not experienced in assemblers.
Now I want examples of asm code for modular programming using relocatable code.
for instance I need examples howto define hidden and exported variables in .data and .bss segments, I also want to have example of pointer to struct.
In other words I am very interested in examples of howto hide and export variables
encapsulated in .o relocatable. And how to use (import) that variables from another relocatable.
How to pass variable to subroutine in another .o by reference.
May be it will be easier for someone just translate the following oberon source to xa65 or ca65 asm syntax so I could understand
MODULE M1;
VAR a*,b,e- : SHORTINT; (* signed byte*)
(* note that a is exported and could be seen rw from other module *)
(* b is hidden*)
(* e is exported read only*)
PROCEDURE p*( VAR l : INTEGER); (*this procedure is exported*)
(*it could be called from other module *)
(* l is passed by reference or via pointer if you like to call it that way *)
VAR a, f : INTEGER; (* signed int *)
BEGIN
a := 5; (*assigning to local variable*)
b := 7;
END p;
PROCEDURE p1; (* hidden procedure, cannot be called from outside *)
BEGIN
END;
BEGIN
a := 7;
e := 9;
END M1.
------------------------------
MODULE M2;
IMPORT M1;
VAR a : INTEGER;
BEGIN
a := M1.a;
M1.p(a);
END M2
Thank you very much