PDA

View Full Version : [nasm asm] file exe non com


okay
03-10-2006, 19:42
conosco bene tasm 5.0 volevo riuscire a fare qualcosa con nasm 0.98 ... sempre per hobby e capire l'affascinante pc.

uso nasmide i listati com li compilo OK, sempre tramite ide, mentre i listati exe, tramite ide non riesco a compilarli mi dice che ..start: è errata.

qualcuno ne sà qualcosa??

ho cercato nelle opzioni del compilatore nasmide ma ho visto solo l'opzione per i com non per l'exe.

oppure devo digitare da riga di comando? ... se si quale è la sintassi? ..intanto googlooo un pò.


il listato che stavo provando e non mi builda tramite l'ide: (per nasm16.exe)


[BITS 16] ; 16 code

; this is actually optional; the code segment
; gets set up for us.
SEGMENT junk

..start: ; '..' tells linker to tell DOS to start executing
; here. This is needed for the segmented model
; because segments can get shuffled around by the linker
; and this may not be the first nor only segment


; Each segment has a name, and the names are identifiers of their
; segment addresses.

; Note you can't move an address directly into a segment register.
; You must first move it into a GP register.

mov ax, data_seg ; load the data's segment address. Note,
; mov ds, data_seg would be illegal.

mov ds, ax ; DOS needs DS to be set right for the INT 21h
; call. It assumes DS is the segment for the
; offset in DX

mov ax, stack_seg ; load the stack's segment address
mov ss, ax

mov sp, stacktop ; point SP to top of the stack

mov dx, eatmsg ; same as before
mov ah, 9
int 0x21

mov ax, 0x04c00
int 0x21


SEGMENT data_seg

eatmsg db "Eat at Joe's!", 13, 10, "$"


SEGMENT stack_seg stack

resb 64 ; reserve 64 bytes

stacktop: ; this label points to the LAST of the




ciao



p.s. altre differenze con tasm 5.0 diciamo l'allineamento ecc ecc. diciamo il code dataseg datacode e lo stack questo è quello che dal mio tasm o msso nel comp nasm ma mi dà errori sui dataseg e code nonchè stack e sempre ..start:


;--------------------------------------------------;
; File okaynasm ;
; Verifica a run-time di un programma EXE ;
;--------------------------------------------------;

;########### direttive per l'assembler ############

CPU 386 ; set di istruzioni a 32 bit


;%include "exelib.inc" ; inclusione libreria di I/O

;######### dichiarazione tipi e costanti ##########

%assign STACK_SIZE 0400h ; 1024 byte per lo stack

;################ segmento dati ###################

;SEGMENT DATASEGM ALIGN=16 PUBLIC USE16 CLASS=DATA
;segment .data align=16
SEGMENT data_seg ;align=16

;segment .text use16

;----- inizio definizione variabili statiche ------

menu0 db '(Esc) Exit',13,10,0
chiudi db 'Exit: Premi un tasto',0

Prompt db 'digita',0
Message db 'Premi un tasto...',0
;strExit db 'Premere un tasto per terminare', 0

;------- fine definizione variabili statiche ------

;############### segmento codice ##################

;segment .seg user16 class=code
;SEGMENT CODESEGM ALIGN=16 PUBLIC USE16 CLASS=CODE
;segment .code align=16

[BITS 16]
SEGMENT junk

start: ; entry point

mov ax, data_seg ; trasferisce DATASEGM
mov ds, ax ; in DS attraverso AX



MOV AX,menu0
MOV DS,AX
MOV DX, menu0

MOV AH,9
int 21h

;http://www.mattwalsh.com/twiki/bin/view/Main/MyFirstDOSAssemblyProgram

ripeti:

mov ah,7

int 21h ;get a key, returned in AX
;AL is the ASCII part
;AH is the SCAN CODE
mov dl,al

; cmp al,'0' ;was the character a '0'?
; je CreaFile




cmp al,1bh ;was the character a ESC?
je Exit0


jmp ripeti


Exit0:

MOV AX, chiudi
MOV DS,AX
MOV DX,chiudi

MOV AH,9
int 21h

;------- inizio blocco principale istruzioni ------



;-------- fine blocco principale istruzioni -------

; mov ah, 4ch ; servizio Terminate Program
; mov al, 00h ; exit code = 0
; int 21h ; chiama i servizi DOS

;################# segmento stack #################


SEGMENT stack_seg stack

resb STACK_SIZE ; 1024 byte per lo stack

;##################################################








... ecco le prove che stavo facendo...

okay
04-10-2006, 10:09
tutto ok.

per linkare un exe in nasm bisogna portare l'obj nella bin del tasm e linkarlo con tlink.

Con idenasm si linkano solo i .com