2014-11-30 2 views
0

버퍼에서 다음 바이트를 가져 오는 프로 시저를 작성 중입니다. 버퍼가 이미 분석 될 때 더 많은 바이트가 필요할 경우 파일에서 자세한 정보를 읽습니다. 그러나 그것은 효과가 없습니다. 왜 그런지 전혀 모릅니다. 이 함수는 al 레지스터에 char을 출력하는 루프에서 사용되지만 필요한 것은 얻지 못합니다 (실제로 무한 루프가 발생합니다. 왜 이런지? 깨닫지 못합니다). 나는 그것이 항상 점프를 수행한다고 생각한다. 이유를 모르겠다. 어떤 아이디어? 미리 감사드립니다. 코드는 다음과 같습니다.TASM 버퍼에서 다음 바이트 가져 오기

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 
+0

인쇄 된 값은 모두 괜찮아 보이지만, 내 PC와 다르게 생각할 수도 있습니다. – Tomas

답변

1

충분히 간단합니다!

jge @@not_less 

이것은 사용자 의견에 해당하지 않습니다! jle을 사용하십시오.

+0

jle도 작동하지 않습니다. jge를 사용하면 첫 번째 문자로 무한 루프가 발생하고, jle에는 아무 것도 없습니다. – Tomas

관련 문제