There are a few things that I dont get in NASM, how do I define the entry point and how do I define a procedure?
Thanks,
ExtremeCoder27
NASM OS Dev Problems
A procedure? Well a procedure is a label. An offset in a segment in IA-32. You can simply create a label and think of it as a procedure's entry point like this:
NASM also allows you to have local labels for your procedures like this:
Observe that [.Label1] is defined both in Procedure1 and Procedure2 but NASM differentiates between these since the first label is created after the Procedure1 label and the second Label1 is created after Procedure2. So if you do something like this:
The JMP instruction will jump to .Label1 in Proceudre2.
You could however use some distinctive way of creating your procedures. What I do is that I prefix my procedures' name with double underscores like this:
It is of course a preference. You could then CALL your procedures like this:
I hope that helps.
Code: Select all
MyProcedure:
; void MyProcedure (void); StdCall;
RET
Code: Select all
Procedure1:
; void Procedure1 (void); StdCall;
.Label1:
RET
Procedure2:
; void Procedure2 (void); StdCall;
.Label1:
RET
Code: Select all
Procedure1:
; void Procedure1 (void); StdCall;
.Label1:
RET
Procedure2:
; void Procedure2 (void); StdCall;
.Label1:
JMP .Label1
RET
You could however use some distinctive way of creating your procedures. What I do is that I prefix my procedures' name with double underscores like this:
Code: Select all
__Procedure1:
; void __Procedure1 (void); StdCall;
RET
Code: Select all
; ——————————————————————————————————————————————————
CALL Procedure1
JMP $
; ——————————————————————————————————————————————————
__Procedure1:
; void __Procedure1 (void); StdCall;
RET
; ——————————————————————————————————————————————————
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.