I have to write a program that would filter text lines from the input file. Each line is divided into six columns. Columns are separated from each other by a semicolon.
I implemented 3 filters:
- Second column has to contain no
uorvletters. - Third column has to contain a number so that it's sum of digits is equal to
7. - Last column has to contain number that belongs to the intervar of
[2.34, 4.50]
Here's input file example:
B11;one;16;0;55;2.44
C1;two;8;0;17;3.77
First line would pass all of three filters.
My program works correctly with all of the filters. However, I have an additional task to find the sum of last columns floating point numbers but only on filtered lines.
I am not sure what would be the proper way to do it.
Here I have implemented filter function for the last column. Somehow from here I should put the filtered last column numbers into buffer and add all of them together. Here in this function I go through each character in the line.
procBelongsToInterval
push ax
xor ax, ax
.first:
mov al, [di]
inc di
cmp al, '-'
je .break
cmp al, '2'
je .firstBound
cmp al, '3'
je .belongs
cmp al, '4'
je .secondBound
jmp .break
.firstBound:
mov al, [di]
inc di
cmp al, '.'
je .firstBound
cmp al, '3'
jb .break
ja .belongs
mov al, [di]
cmp al, '4'
jae .belongs
jb .break
.secondBound:
mov al, [di]
inc di
cmp al, '.'
je .secondBound
cmp al, '5'
ja .break
jb .belongs
mov al, [di]
cmp al, '0'
je .belongs
ja .break
.belongs:
mov [numberBelongsToInterval], byte 1
jmp .end
.break:
mov [numberBelongsToInterval], byte 0
jmp .end
.end:
pop ax
ret