I am writing procedure that gets next byte from buffer and if we need more bytes when buffer is already analysed, it reads from file for more information. But it doesn't work. Don't know why at all. This function is used in loop which prints char in al register, but I don't get what I need (actually I get infinite loop, I was like wtf? Can't realise why). I think that it always performs the jump. Don't know why. Any ideas? Thank you in advance. Here is the code:
proc get_byte
mov ah, read_buffer_length ; read_buffer_length - actual amount of bytes read from file
sub ah, 1 ; subtracting one since read_position is calculated from 0
; and read_buffer_length from 1
cmp read_position, ah ; comparing current position in buffer and buffer length
jle @@not_less ; if read_position <= ah then we jump to @@not_less
@@read_input_buffer: ; we need more bytes, since we dont have anything in buffer
call read_input_buffer ; function does everything good, tested
mov read_position, 0 ; nullify position
mov ch, 0h ; ch=0
mov cl, read_buffer_length ; putting cl for loop. this function is used in loop
mov si, offset read_buffer ; putting beginning of buffer
@@not_less: ; in this case we dont need extra reading to buffer, it has enough bytes
mov al, [si] ; i want result in al
inc si ; increasing value of pointer
inc read_position ; increasing position number
ret
endp
Simple enough!
This does not correspond to your comment! Use
jle
.