Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailemVyřešeno Assembler - jc nefunguje ako ma

Zdravim mam jeden velky problem v mojom kode, kde mam nalinkovanu proceduru s hl. programom kde mam menu. Obe maju zdielane procedury v include no v procedurach som pouzival jmp hl. menu ale akonahle som zlinkoval s externou procedurou ona hl. menu nepozna nakolko je iba v hlavnom subore. Preto som sa rozhodol upravit kod takto:

;PROCEDURA OTVORI SUBOR
FILE_OPEN PROC 
    PRINT newLine
    xor dx,dx
    mov ah,3dh                        ; DOS funkcion to open a file
    xor al,al                         ; clearing al register
    lea dx,filename                   ; set file name                          
    clc                               ; clear carry flag
    int 21h                           ; interrupt   
    jc  ERROR                         ; if a problem appears jump to ERROR
    mov handle,ax                     ; save file handle           
    ret
ERROR:                                  ; if problem appeared, info message will be thrown and procedure will end
    CALL CLRSCR
    PRINT err_file_open
    PRINT newLine
    ret            ;TU BOLO namiesto RET JMP HL.MENU
ENDP

Tuto proceduru pouzivam v procedure tuto:

FILE_PRINT PROC 
    CALL CLRSCR
    CALL FILE_OPEN
    jc ERROR3  
READ:
    mov ah,3fh                   ; reading from file
    mov bx,handle                ; handle is where my file is placed
    mov cx,1024                   ; reading 50 chars                                 
    lea dx,readBuff              ; moving begining of {at fist empty) string to dx
    int 21h                      ; interrupt  
    mov cx,ax                    ; number of the read chars is moved to cx
    xor si,si                    ; to be sure, the index will start at 0th position
    cmp ax,1024                   ; was 50 chars read?
    jnz LAST                     ; if less than 50 chars was read, I'm reaching end of file, last print is going to happen
CYCLE:  
    mov ah,02h                  ; DOS funkcion to print char
    mov dl,readBuff[si]         ; what is going to be print, si is pointer to the exact location in input_string 
    int 21h                     ; interrupt (now, the letter appears)
    inc si                      ; moving pointer further 
    loop CYCLE                     ; looping while cx is not 0, the value in cx is subtracting
    jmp READ                    ; when all 50 chars are already written, next 50 chars are going to be read
ERROR3:
    ret
LAST:                           ; LAST_PRINT does the same thing as GO, but after cx reaches 0, procedure ends
    mov ah,02h
    mov dl,readBuff[si]
    int 21h
    inc si  
    loop LAST
    PRINT newLine
    call FILE_CLOSE
    ret
ENDP

Tato procedura by sa mala pri zle otvorenom subore vratit a po jej ukonceni ma byt zavolane v hl. subore menu takze by to malo problem vyriesit no FILE_OPEN zaznamena chybu ale v druhej procedure JZ po zavolani FILE_OPEN neskoci. Kde je chyba? Dakujem za odpovede :)

Jsou zobrazeny jen nové odpovědi. Zobrazit všechny
Předmět Autor Datum
Diky moc si mi pomohol som nevedel ze taketo finty su paradne :) poslední
Parker 22.03.2017 22:21
Parker

Zpět do poradny Odpovědět na původní otázku Nahoru