View Full Version : [DOS] .com a 16 bit
sto uscendo scemo (il che è tutto dire).
voglio creare un programma a 16 bit con estensione .com e sto provando a usare MASM32 e NASM, ma con nessuno dei due ci riesco :cry:
in particolare tra i due preferivo il masm; anche se si tratta del masm32, la direttiva .model supporta ancora il modello tiny, quindi dovrebbe comunque essere in grado di generare codice a 16 bit in un file .com
ho provato a fare uno scheletro iniziale di programma (questo in masm):
.model tiny
.code
.startup
.exit
end
ma tutto quello che ottengo è un errore di link che mi comunica l'assenza dell'entry point WinMainCRTStartup, che però non dovrebbe esserci!! i .com non hanno l'entry point!!
dov'è che sbaglio ?? :cry:
qualcuno può dirmi passo passo come fare un programma scheletrico a 16 bit con estensione .com possibilmente in masm32? (sennò al limite va bene il nasm...)
come sempre lavoro su win2k pro
thx
RaouL_BennetH
20-05-2005, 14:08
Non chiedermi cosa vuol dire, l'ho trovato nei gruppi di google, forse tu riesci a decifrarlo:
" If using a module definition (.def) file, these lines should appear in it:
If using a module definition (.def) file, these lines should appear in it:
EXETYPE NT
SUBSYSTEM CONSOLE
Do not use /ENTRY:WinMainCRTStartup in a command to the linker, this specifies a Windows application."
Spero ti sia utile.
ehm... -__________-'''
apprezzo molto la tua solerzia e la tua collaborazione ^^' ma non è esattamente quello che cercavo ^^
ti spiego brevemente che vuol dire: quando crei programmi EXE (quindi non c'entra nulla coi COM) puoi opzionalmente includere un file con estensione .def che contiene le cosiddette definizioni, una serie di informazioni di vario genere; tra queste troviamo il nome dell'entry point (di default "WinMainCRTStartup"), il subsystem usato (cioè se è un programma console, un programma GUI, un driver, ecc.), le eventuali esportazioni, le definizioni delle sezioni, eccetera eccetera.
non so se puo' aiutare...pero' nel codice che hai postato manca l'indicazione dell'indirizzo di partenza del programma. Se non sbaglio per i file .com non deve essere _sempre_ 100h? Quindi ORG 100h?
:mbe: ORG 100h? e chè è? dove lo devo scrivere?
:mbe: ORG 100h? e chè è? dove lo devo scrivere?
vuol dire che i .com devono partire dall'addr 100h, prima di esso c'è spazio riservato per altre cose.
Fatto sta che i com partono da li e se nn lo fanno, nn sono .com ;)
ORG 100h is a compiler directive (it tells compiler how to handle the source code). This directive is very important when you work with variables. It tells compiler that the executable file will be loaded at the offset of 100h (256 bytes), so compiler should calculate the correct address for all variables when it replaces the variable names with their offsets. Directives are never converted to any real machine code.
Why executable file is loaded at offset of 100h? Operating system keeps some data about the program in the first 256 bytes of the CS (code segment), such as command line parameters and etc.
Though this is true for COM files only, EXE files are loaded at offset of 0000, and generally use special segment for variables. Maybe we'll talk more about EXE files later.
:)
vuol dire che i .com devono partire dall'addr 100h, prima di esso c'è spazio riservato per altre cose.
Fatto sta che i com partono da li e se nn lo fanno, nn sono .com ;)
perché secondo te sul mio computer (win2kpro) l'indirizzo fisico 100h è libero??? :D
a parte che non è mai libero neanche in modalità reale perché c'è il bios e subito prima l'IVT... :rolleyes:
:)
adesso è già più chiaro; ma questa direttiva ORG per che assemblatore è? ripeto che vorrei usare il masm32
da http://www.uv.tietgen.dk/staff/mlha/PC/Prog/asm/masm/directives.htm:
ORG
Sets the Location Counter.
In COM programs, ORG 100h leaves room for the DOS PSP.
code SEGMENT
ORG 100h
start: ;code at 100h
ma sta cosa dove va messa? ho provato subito dopo la direttiva .CODE ma non cambia nulla :(
e comunque non credo che sia quello il problema... devo far capire al linker che non sto generando un EXE, ma un COM! il linker mi cerca l'entry point!
CSEG SEGMENT ; code segment starts here.
; #MAKE_COM# ; uncomment for Emu8086.
ORG 100h
start: MOV AL, 5 ; some sample code...
MOV BL, 2
XOR AL, BL
XOR BL, AL
XOR AL, BL
RET
CSEG ENDS ; code segment ends here.
END start ; stop compiler, and set entry point.
Entry point for COM file should always be at 0100h (first instruction after ORG 100h directive), though in MASM and TASM you may need to manually set an entry point using END directive. Emu8086 works just fine, with or without it.
In order to test the above code, save it into test.asm file (or any other) and run these commands from command prompt:
For MASM 6.0:
MASM test.asm
LINK test.obj, test.com,,, /TINY
For TASM 4.1:
TASM test.asm
TLINK test.obj /t
We should get test.com file (11 bytes), right click it and select Send To and emu8086. You can see that the disassembled code doesn't contain any directives and it is identical to code that Emu8086 produces even without all those tricky directives.
che Google sia con te! :)
MWHAUWHAUHUWHAUA COMPILA!!!! ehm, però come dire... è un exe... :-| :doh:
ti ringrazio tantissimo per l'aiuto, ma a questo punto mi sembra chiaro che bisogna cambiare qualche settaggio, qualche impostazione, forse nel linker; aho, ti giuro che le ho provate tutte e proprio non ci riesco... :-|
boh, forse domani ci riuscirò, dato che domani è domenica e quindi dovrei avere la concentrazione di un carciofo, però almeno non è sabato, che ho la concentrazione di una patata :-|
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.