crsandu icon

5 b)

crsandu | PRO | 09/06/18 10:29:56 AM UTC | 0 ⭐ | 12861 👁️ | Never ⏰ | []
ASM (NASM) |

0 B

|

None

|

0 👍

/

0 👎

.586
.model flat, C
 
includelib msvcrt.lib
extern exit:    proc
extern printf:  proc
extern scanf:   proc
 
public start
 
.data
    sir_valori      dd  100 dup(?)
    
    max_value   dd  ?
    mesaj_out   db  "Introduceti o valoare max: ", 0
    mesaj_in    db  "%d", 0
    float_f     db  "%.3f ", 0
 
.code
    square  proc
        mov EBP, ESP
        
        FLD1
        
        FILD    DWORD PTR [EBP + 4]
        FIMUL   DWORD PTR [EBP + 4] ; <=> val^2
        
        FDIV ; impartim valorile
        ret
    square endp
 
    start:
        push offset mesaj_out
        call printf
        add ESP, 04h
        
        push offset max_value
        push offset mesaj_in
        call scanf
        add ESP, 08h
        
        MOV ESI, 0
        MOV EBX, max_value
        MOV EAX, 1
        
        NotMax:
            push EAX
            call square
            add ESP, 04h
        
            ; - adaugare valori la sir
            FSTP sir_valori[ESI]
            ADD ESI, 04h
            INC EAX
 
            ; - stop condition
            cmp EAX, EBX
            
        JLE NotMax
        
        ; - afisarea lor
        XOR EAX, EAX
        XOR ESI, ESI
        MOV EBP, ESP
        
        Afisare:
            FLD sir_valori[ESI]
            ADD ESI, 4
 
            PUSH EAX
            PUSH EBX
 
            SUB ESP, 8
            FSTP QWORD PTR [EBP-16]
       
            push offset float_f
            call printf
            ADD ESP, 12
            
            POP EBX
            POP EAX
            
            INC EAX
 
            ; - stop condition
            cmp EAX, EBX
        JL Afisare
        
        push 0
        call exit
end start

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎