Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- .data
- a dt ?
- b dt ?
- c dt ?
- str1 db 13,"Enter a = ",'$'
- str2 db 13,"b = ",'$'
- str3 db 13,"c = ",'$'
- length dw 0
- after_poin dw 0
- fminus dw 0
- .code
- read_fun PROC
- mov ax, 0
- mov length, ax
- mov after_poin, ax
- mov fminus, ax
- cin:
- mov ah, 08h
- int 21h
- cmp al, '0'
- jl next ;<
- cmp al, '9'
- jg next ;>
- inc length
- mov ax, '0'
- sub al, ax
- push al
- mov ax, 0
- cmp after_poin, ax
- je read ;=
- inc after_poin
- read:
- next:
- cmp al, '-'
- je minus
- cmp al, 8
- je bsckspace
- cmp al, '.'
- je p
- bsckspace:
- mov ax, 1
- cmp length, ax
- je delete_minus
- mov ax, 0
- cmp length, ax
- jg out
- mov ax, 1
- cmp after_poin, ax
- je del_poin
- del_poin:
- mov ax, 0
- mov after_poin, ax
- delete_minus:
- mov ax, 0
- mov fminus, ax
- out:
- pop al
- p:
- mov ax, 0
- cmp fminus, ax
- jge check ; >=
- mov ax, 2
- cmp length, ax
- jge write_point
- mov ax, 0
- cmp after_poin, ax
- jne cin ;!=
- inc after_poin
- mov ah, 02h
- mov dl, '.'
- int 21h
- jmp cin
- check:
- mov ax, 1
- cmp length, ax
- je write_point
- jmp cin
- write_point:
- inc after_poin
- inc length
- mov ah, 02h
- mov dl, '.'
- int 21h
- jmp cin
- minus:
- mov ax, 0
- cmp fminus, ax
- jmp cin
- mov ax, 1
- mov fminus, ax
- mov ah, 02h
- mov dl, '-'
- int 21h
- jmp cin
- ret
- read_fun endp
- count_x PROC
- ret
- count_x endp
- output PROC
- ret
- output endp
- start:
- mov ax, @data
- mov ds, ax
- mov es, ax
- mov ah, 09h
- mov dx, offset str1
- int 21h
- call read_fun
- mov ax, 4c00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement