Загрузка данных


dosseg
.model small
.stack 200h

.data
    height dw ?
    width  dw ?
    length dw ?
    volume dw ?
    msgH db 'Input height: $'
    msgW db 0ah, 'Input width: $'
    msgL db 0ah, 'Input length: $'
    msgV db 0ah, 'Volume = $'
    cr   = 0dh
    lf   = 0ah
    string db 255, 0, 255 dup(?)
    errmsg db 'Invalid character, use digits only', cr, lf, '$'
    negflag dw ?

.code

IntegerIn proc
start:
    mov ah, 0ah
    lea dx, string
    int 21h
    xor ax, ax
    lea si, string+2
    mov negflag, ax
    cmp byte ptr [si], '-'
    jne m2
    not negflag
    inc si
    jmp m3
m2:
    cmp byte ptr [si], '+'
    jne m3
    inc si
m3:
    cmp byte ptr [si], cr
    je ex1
    cmp byte ptr [si], '0'
    jb err1
    cmp byte ptr [si], '9'
    ja err1
    mov bx, 10
    mul bx
    sub byte ptr [si], '0'
    add al, [si]
    adc ah, 0
    inc si
    jmp m3
err1:
    lea dx, errmsg
    mov ah, 9
    int 21h
    jmp start
ex1:
    cmp negflag, 0
    je ex
    neg ax
ex:
    ret
IntegerIn endp

IntegerOut proc
    xor cx, cx
    mov bx, 10
    cmp ax, 0
    jge m
    neg ax
    push ax
    mov ah, 2
    mov dl, '-'
    int 21h
    pop ax
m:
    inc cx
    xor dx, dx
    div bx
    push dx
    or ax, ax
    jnz m
m1:
    pop dx
    add dl, '0'
    mov ah, 2
    int 21h
    loop m1
    ret
IntegerOut endp

Volume proc near
    push bp
    mov bp, sp
    mov ax, [bp+6]
    mul word ptr [bp+4]
    mul word ptr [bp+2]
    pop bp
    ret 6
Volume endp

Begin:
    mov ax, @data
    mov ds, ax

    mov ah, 09h
    lea dx, msgH
    int 21h
    call IntegerIn
    mov height, ax

    mov ah, 09h
    lea dx, msgW
    int 21h
    call IntegerIn
    mov width, ax

    mov ah, 09h
    lea dx, msgL
    int 21h
    call IntegerIn
    mov length, ax

    push length
    push width
    push height
    call Volume
    mov volume, ax

    mov ah, 09h
    lea dx, msgV
    int 21h
    mov ax, volume
    call IntegerOut

    mov ah, 09h
    lea dx, msgH
    int 21h
    call IntegerIn
    mov height, ax

    mov ah, 09h
    lea dx, msgW
    int 21h
    call IntegerIn
    mov width, ax

    mov ah, 09h
    lea dx, msgL
    int 21h
    call IntegerIn
    mov length, ax

    push length
    push width
    push height
    call Volume
    mov volume, ax

    mov ah, 09h
    lea dx, msgV
    int 21h
    mov ax, volume
    call IntegerOut

    mov ax, 4c00h
    int 21h

end Begin