JavascriptProva

domenica 20 maggio 2012

Rispolverando Assembly: generazione del listato dall'assemblatore

Un veloce ripasso di Assembly (dovrei averlo già riposto in un angolo remoto del cervello...)

Le procedure che si chiamavano con INT... vediamo... Tabella dei vettori, ecco...

INT 10H sono le funzioni per la gestione del video.
Ripassiamo...
text SEGMENT
MOV AH,00H
MOV AL,03H
INT 10H

MOV AH,00H
INT 16H

MOV AH,4CH
INT 21H


text ENDS
END
Una cosa brevissima...

Quello che mi interessa è rivedere un po' il listato, con la tabella dei simboli.

Come si fa per far generare il listato dall'assemblatore? Ecco, per simulare il vecchio MASM, viene eseguito ML con queste opzioni:
C:\Arch-Lab\Lavoro>masm mio.asm
Microsoft (R) MASM Compatibility Driver
Copyright (C) Microsoft Corp 1993.  All rights reserved.

 Invoking: ML.EXE /I. /Zm /c /Ta mio.asm

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: mio.asm

C:\Arch-Lab\Lavoro>
Un ripasso di queste opzioni:
C:\Arch-Lab\Lavoro>ml /help
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.


        ML [ /options ] filelist [ /link linkoptions ]

/AT Enable tiny model (.COM file)         /nologo Suppress copyright message
/Bl<linker> Use alternate linker          /Sa Maximize source listing
/c Assemble without linking               /Sc Generate timings in listing
/Cp Preserve case of user identifiers     /Sf Generate first pass listing
/Cu Map all identifiers to upper case     /Sl<width> Set line width
/Cx Preserve case in publics, externs     /Sn Suppress symbol-table listing
/coff generate COFF format object file    /Sp<length> Set page length
/D<name>[=text] Define text macro         /Ss<string> Set subtitle
/EP Output preprocessed listing to stdout /St<string> Set title
/F <hex> Set stack size (bytes)           /Sx List false conditionals
/Fe<file> Name executable                 /Ta<file> Assemble non-.ASM file
/Fl[file] Generate listing                /w Same as /W0 /WX
/Fm[file] Generate map                    /WX Treat warnings as errors
/Fo<file> Name object file                /W<number> Set warning level
/FPi Generate 80x87 emulator encoding     /X Ignore INCLUDE environment path
/Fr[file] Generate limited browser info   /Zd Add line number debug info
/FR[file] Generate full browser info      /Zf Make all symbols public
/G<c|d|z> Use Pascal, C, or Stdcall calls /Zi Add symbolic debug info
/H<number> Set max external name length   /Zm Enable MASM 5.10 compatibility
/I<name> Add include path                 /Zp[n] Set structure alignment
/link <linker options and libraries>      /Zs Perform syntax check only


C:\Arch-Lab\Lavoro>
Ecco:
  • L'opzione /I. è relativa al percorso (me la rivedrò dopo);
  • L'opzione /Zm abilita la compatibilità con MASM 5.10 (non ho mai capito bene cosa sia);
  • L'opzione /c significa assemblare senza linkare;
  • L'opzione /Ta significa "assemblare files non .ASM": forse abilita ML ad assemblare files senza l'estensione esplicitamente specificata...


L'opzione richiesta per generare il listato è /Fl.
Proviamo...
C:\Arch-Lab\Lavoro>ml /c /Zm /Fl mio.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: mio.asm

C:\Arch-Lab\Lavoro>dir mio*
 Il volume nell'unità C è ACER
 Numero di serie del volume: AC40-F131

 Directory di C:\Arch-Lab\Lavoro

20/05/2012  13.22               111 mio.asm
20/05/2012  13.22               526 mio.exe
20/05/2012  15.35               666 mio.lst
20/05/2012  15.35                65 mio.obj
               4 File          1.368 byte
               0 Directory   5.926.289.408 byte disponibili

C:\Arch-Lab\Lavoro>
Ecco il listato!
Ora me lo analizzo un po'...

E che accidenti vuoi analizzare? Non ho simboli in questo microprogrammino idiota!
Così andrà meglio:
text SEGMENT

inizio:
MOV AH,00H
MOV AL,03H
INT 10H

MOV AH,00H
INT 16H

MOV AH,4CH
INT 21H


text ENDS
END inizio
Ecco il listato:
Microsoft (R) Macro Assembler Version 6.14.8444      05/20/12 15:42:29
mio.asm            Page 1 - 1


 0000    text SEGMENT

 0000    inizio:
 0000  B4 00   MOV AH,00H
 0002  B0 03   MOV AL,03H
 0004  CD 10   INT 10H

 0006  B4 00   MOV AH,00H
 0008  CD 16   INT 16H

 000A  B4 4C   MOV AH,4CH
 000C  CD 21   INT 21H


 000E    text ENDS
    END inizio
 Microsoft (R) Macro Assembler Version 6.14.8444      05/20/12 15:42:29
mio.asm            Symbols 2 - 1




Segments and Groups:

                N a m e                 Size     Length   Align   Combine Class

text . . . . . . . . . . . . . . 16 Bit  000E   Para   Private 


Symbols:

                N a m e                 Type     Value    Attr

inizio . . . . . . . . . . . . . L Near  0000   text 

    0 Warnings
    0 Errors
Ed ecco la tabella dei simboli:
Symbols:

                N a m e                 Type     Value    Attr

inizio . . . . . . . . . . . . . L Near  0000   text 
in cui c'è un simbolo solo, l'etichetta inizio.

Non male come inizio!

Nessun commento:

Posta un commento