If I want to code commandline with .exe file

Started by vasant, April 11, 2006, 04:57:26 AM

Previous topic - Next topic

vasant

I must use .STARTUP ?
Please show example code.

Thank you.

skywalker

Quote from: vasant on April 11, 2006, 04:57:26 AM
I must use .STARTUP ?
Please show example code.

Thank you.

This is just a template that exits returning 0 as your exit code.

 
.model small
      .586
      .stack

      .data

      .code

      .startup

      .exit 0    ; exit code set to 0
end


vasant

Question :

1 All Code for commandline must write after .STARTUP?
2 What is end of .STARTUP ?
3 ".586 " to need?
4 How to code other for program?

Thank you.

skywalker

Quote from: vasant on April 11, 2006, 08:42:34 PM
Question :

1 All Code for commandline must write after .STARTUP?
Yes.

2 What is end of .STARTUP ?

Don't know what you are asking here.

3 ".586 " to need?

No, only if you need .586 features.

4 How to code other for program?

Same answer as for question #2

Thank you.

MichaelW

vasant,

If you are asking how to access the command line after the STARTUP directive, you use segment register ES. The command line is in the Program Segment Prefix (PSP). The program loader sets DS and ES to the segment address of the PSP. For an EXE the STARTUP directive changes the value in DS, but leaves ES as it is. The first character in the command line will be at ES:81h, and the last character will be a Carriage Return character (ASCII code 0Dh). So for example, if the command line were "test", the contents of the memory starting at ES:81h would be:

db " ","t","e","s","t",0dh

And to answer your other thread here, you can do exactly the same for a COM program. The differences for a COM program are that the loader sets all of the segment registers to the PSP, and the STARTUP directive does not alter any of the segment registers.

eschew obfuscation