Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input_to_ax macro
- local _input, _not_first_symbol, _incorrect, _correct, _clear_symb, _input_end, _process_number, _neg_flag, _end_of_processing
- push bx
- push cx
- push dx
- xor cx, cx
- xor bx, bx
- xor dx, dx
- _input:
- xor ax, ax
- mov ah, 01
- int 21h
- cmp al, 0Dh
- je _correct
- cmp al, 08h
- je _correct
- cmp cx, 0
- jg _not_first_symbol
- cmp al, 2Dh
- je _correct
- _not_first_symbol:
- cmp al, 30h
- jl _incorrect
- cmp al, 39h
- jg _incorrect
- jmp _correct
- _incorrect:
- mov dl, 08h
- mov ah, 02h
- int 21h
- mov dl, 20h
- mov ah, 02h
- int 21h
- mov dl, 08h
- mov ah, 02h
- int 21h
- jmp _input
- _correct:
- cmp al, 0Dh ; ENTER
- je _input_end
- cmp al, 08h ; BACKSPACE
- je _clear_symb
- mov ah, 0
- push ax
- inc cx
- jmp _input
- _clear_symb:
- cmp cx, 0
- je _input
- pop ax
- dec cx
- mov dl, 20h
- mov ah, 02h
- int 21h
- mov dl, 08h
- mov ah, 02h
- int 21h
- jmp _input
- _input_end:
- xor dx, dx
- mov bx, 1
- cmp cx, 0
- jne _process_number
- mov ax, 0
- jmp _end_of_processing
- _process_number:
- pop ax
- cmp al, 02dh ; - sign
- jne _neg_flag
- neg dx
- jmp _end_of_processing
- _neg_flag:
- sub al, 30h
- mov ah, 0
- push dx
- mul bx
- pop dx
- add dx, ax
- mov ax, bx
- mov bx, 10
- push dx
- mul bx
- pop dx
- mov bx, ax
- loop _process_number
- _end_of_processing:
- mov ax, dx
- pop dx
- pop cx
- pop bx
- endm input_to_ax
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement