News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

anybody help me to compile it?

Started by Ratoo, March 26, 2009, 09:07:09 PM

Previous topic - Next topic

Ratoo

; FUNCOES MACROS
;---------------------------------------------------
DisplayString MACRO modelo
    MOV ah, 09h
    LEA dx, modelo
    INT 21h
ENDM

GetKey MACRO
    MOV ah, 08h ; Recebe o valor
    INT 21h
ENDM

SendKey MACRO modelo
    MOV ah, 02h
    MOV dl, modelo ; Mostra um char na tela
    INT 21h
ENDM

.386
.MODEL FLAT, STDCALL
option casemap:none

.STACK 100h

.DATA
    Msg0 db 10, 13, 9, 9, " ____ FORMATANDO DISQUETE ____$"
    Msg1 db 10, 13, 10, 13, "Insira o disquete e aperte qualquer tecla para continuar...$"
    Msg2 db 10, 13, " Numero de tracks formatados : $"
    Msg3 db 10, 13, " Formatacao do disquete foi um sucesso!$"
    Msg4 db 10, 13, " Desempenhando uma formatacao em baixo nivel... $"
    Msg5 db 10, 13, " Reinializando FAT ... $"
    Blank db 10, 13, "$"
    Fat db 512*09 dup(0)
    Dir db 512*14 dup(0)
    Count db 00h
    IsEven db 01h
    temp dw 0000h
    ErrMsg db 10, 13, 10, 13, "Erro!$"
    ErrFat db 10, 13, "FAT: erro na escrita!$"
    ErrDir db 10, 13, "Dir: erro na escrita!$"
    FormErr db 10, 13, "Erro quando formatava!$"
    FList db 0, 0, 1, 2 ; Os valores armazenados aqui
          db 0, 0, 2, 2 ; estao no formato :
          db 0, 0, 3, 2 ; Track / Head / Sector /
          db 0, 0, 4, 2 ; Bytes por Sector
          db 0, 0, 5, 2 ; onde 2 = 512 Bps
          db 0, 0, 6, 2
          db 0, 0, 7, 2
          db 0, 0, 8, 2
          db 0, 0, 9, 2
          db 0, 0, 10, 2
          db 0, 0, 11, 2
          db 0, 0, 12, 2
          db 0, 0, 13, 2
          db 0, 0, 14, 2
          db 0, 0, 15, 2
          db 0, 0, 16, 2
          db 0, 0, 17, 2
          db 0, 0, 18, 2

.CODE
    inicio:
        mov ax, @data
        mov ds, ax
        mov es, ax

        ; MOSTRA STRINGS
        ; ---------------------------------------------------
            DisplayString Msg0 ; Titulo
            DisplayString Msg1 ; Inserir disquete
            GetKey

        ; LENDO A FAT NO BUFFER
        ; ---------------------------------------------------
            mov ah, 02h ; Chamda da funcao
            mov al, 09h ; Numeros de sectors = 9
            lea bx, Fat ; Atribui bx => Fat Buffer
            mov ch, 00h ; Numero da Track
            mov cl, 01h ; Sector 1
            mov dl, 00h ; Drive A:
            int 13h ; Leitura

        ; FORMATTING DRIVE
        ; ---------------------------------------------------
        FormatDrive:
            mov di, 80*2 ; Count = 80 tracks x 2 heads
            DisplayString Msg4 ; formatacao em baixo nivel...
            DisplayString Blank ; Blank Line
            FormatTrack:
                mov ah, 05h ;
                mov al, 18 ;
                mov ch, FList[0] ;
                mov dh, FList[1] ;
                mov dl, 00h ;
                lea bx, FList ;
                int 13h
                jc ErrorTrap
            CheckHead:
                mov al, FList[1] ;
                cmp al, 00h ;
                je HeadIsZero
            HeadIsOne:
                mov cl, 18 ;
                mov si, 00 ;
                HeadIsOne_Part2:
                    inc FList[si] ;
                    mov FList[si+1], 00h ;
                    add si, 04 ;
                    dec cl ;
                    jnz HeadIsOne_Part2 ;
            jmp DecrMainCount ;

            HeadIsZero:
                mov cl, 18 ;
                mov si, 00 ;
                HeadIsZero_Part2:
                    mov FList[si + 1], 01h ;
                    add si, 04 ;
                    dec cl ;
                    jnz HeadIsZero_Part2 ;
                jmp DecrMainCount ;
                DecrMainCount:
                    dec di ;
                    SendKey 0B1h
                    jnz FormatTrack ;
            jmp ReInitFat ;
            ErrorTrap:
                DisplayString ErrMsg ;
                GetKey
                jmp ProgEnd


            ReInitFat:
                WriteFat:
                    DisplayString Msg5
                    mov ah, 03h ;
                    mov al, 09h ;
                    lea bx, Fat ;
                    mov ch, 00h ;
                    mov cl, 01h ;
                    mov dl, 00h ;
                    int 13h ;
                    jc FatError
                jmp WriteDir
            FatError:
                DisplayString ErrFat
                jmp ErrorTrap2


            WriteDir:
                mov ah, 03h ;
                mov al, 14 ;
                lea bx, Dir ;
                mov ch, 00h ;
                mov cl, 19 ;
                mov dl, 00h ;
                int 13h ; W
                jc DirError
                jmp Success
            DirError:
DisplayString ErrDir
jmp ErrorTrap2
ErrorTrap2:
DisplayString ErrMsg
GetKey
jmp ProgEnd
Success:
DisplayString Msg3
ProgEnd:
mov ah, 4ch ;
int 21h ;

    END inicio


the error, in (mov ax, @data) is: error A2004: symbol type conflict
plz help me

MichaelW

You are trying to mix 16-bit DOS code with a 32-bit flat memory model. There are multiple problems with this, including the one that is causing the first error: in 32-bit code @data returns a 32-bit address that will not fit in a 16-bit register. If I replace:

.386
.MODEL FLAT, STDCALL
option casemap:none


With:

.MODEL SMALL
.386


Then the code will assemble OK, and with a 16-bit linker I can create an EXE.
eschew obfuscation

Ratoo

I replaced the code that you said but:
..\whooa.asm(63) : error A2006: undefined symbol : DGROUP
..\whooa.asm(92) : error A2074: cannot access label through segment registers
..\whooa.asm(93) : error A2074: cannot access label through segment registers
..\whooa.asm(99) : error A2074: cannot access label through segment registers
..\whooa.asm(106) : error A2074: cannot access label through segment registers
..\whooa.asm(107) : error A2074: cannot access label through segment registers
..\whooa.asm(117) : error A2074: cannot access label through segment registers
..\whooa.asm(173) : warning A4023: with /coff switch, leading underscore required for start address : inicio

MichaelW

It looks like you are trying to assemble it with a command line that is intended for 32-bit Windows code. I used this batch file:

ML /c ratoo.asm
pause
LINK16 ratoo.obj;
Pause


With ML.EXE and LINK16.EXE in the current directory. LINK16.EXE is the 16-bit linker available from the forum web site, renamed to LINK16.EXE.
eschew obfuscation

Ratoo

Problem solved, THANK YOUUUUUUUUUU  :clap:
do you could indicate for me books or texts that I can study more in MASM