JavascriptProva

giovedì 19 settembre 2013

Procedura nello stesso modulo

Andiamo avanti...

;definiamo il segmento
text segment 
;inizio del programma
start:
 mov ah,00h
 mov al,03h
 int 10h
 
 mov ah,09h
 mov al,'A'
 mov bh,00h
 mov bl,0ch
 mov cx,1
 int 10h
 
 mov ah,00h
 int 16h
 
 mov ah,4ch
 int 21H
 
text ends
end start
C:\Assembly>ml /Zm /c uno.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: uno.asm

C:\Assembly>link uno

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Run File [uno.exe]:
List File [nul.map]:
Libraries [.lib]:
Definitions File [nul.def]:
LINK : warning L4021: no stack segment

C:\Assembly>
A
C:\Assembly>


Il ciclo LOOP

Adesso mi condenso l'istruzione per la stampa in una procedura...
;definiamo il segmento
text segment 
;inizio del programma
start:
 mov ah,00h
 mov al,03h
 int 10h
 
 call X
 mov ah,00h
 int 16h
 
 mov ah,4ch
 int 21H
 
 
X: mov ah,09h
 mov al,'A'
 mov bh,00h
 mov bl,0ch
 mov cx,1
 int 10h
 ret

text ends
end start
 
Non ho usato la sintassi con PROC, ma da vaghe reminiscenze mi sembra di ricordare che per le procedure vicine, ossia nello stesso segmento, si possa usare anche una semplice LABEL...

A
C:\Assembly>
funziona lo stesso.

Meglio poter scegliere in anticipo il carattere, no?
;definiamo il segmento
text segment 
;inizio del programma
start:
 mov ah,00h
 mov al,03h
 int 10h
 
 mov al,'X'
 call X
 
 mov ah,00h
 int 16h
 
 mov ah,4ch
 int 21H
 
 
X: mov ah,09h
 mov bh,00h
 mov bl,0ch
 mov cx,1
 int 10h
 ret

text ends
end start
 
sarebbe meglio scegliere in anticipo anche il colore, ma adesso quello che mi interessa è ripassare l'uso delle procedure.
X
C:\Assembly>
Bene.

Infatti, quello che mi interessa è usare le procedure esterne.
Riscrivo tutto con la sintassi PROC...
;definiamo il segmento
text segment 
;inizio del programma
start:
 mov ah,00h
 mov al,03h
 int 10h
 
 mov al,'X'
 call X
 
 mov ah,00h
 int 16h
 
 mov ah,4ch
 int 21H
 
X proc near
 
 mov ah,09h
 mov bh,00h
 mov bl,0ch
 mov cx,1
 int 10h
 ret
X endp

text ends
end start
 
E adesso si viene alle librerie...

Nessun commento:

Posta un commento