不需要时屏幕上会显示消息(c:/tasm/cin)

问题描述 投票:0回答:1
start:

    mov ax, @data
    mov ds, ax
    
    mov ax, 13h ;Graphic mode
    int 10h     ;Graphic mode
    
    
    jmp image1
    image2:
    ; Back to text mode
    ;mov ah, 0
    ;mov al, 2
    ;int 10h
    function_call:
    ; Graphic mode
    ; Process BMP file
    call OpenFile2
    call ReadHeader2
    call ReadPalette2
    call CopyPal2
    call CopyBitmap2
    call CloseFile2
    ; Wait for key press
    wait_for_input:
    mov ah, 07h
    int 21h
    cmp al , 62h
    je image1
    jmp wait_for_input


    
    ; Graphic mode
    mov ax, 13h
    int 10h
    ; Process BMP file
    image1:
    call OpenFile1
    call ReadHeader1
    call ReadPalette1
    call CopyPal1
    call CopyBitmap1
    call CloseFile1
     ;Wait for key press
    wait_for_input2:
    mov ah, 07h
    int 21h
    cmp al , 69h
    je function_call
    cmp al , 73h
    je image3
    jmp wait_for_input2
    
    
    image3:
    ;mov ax, 13h
    ;int 10h
    call CleanScreen
    call CloseFile1
    call OpenFile3
    call ReadHeader3
    call ReadPalette3
    call CopyPal3
    call CopyBitmap3
    ;wait_for_input3:
    ;mov ah, 1
    ;int 21h
    ;cmp al, 112
    ;je continue
    ;jmp wait_for_input3    
mov ax, 0h
int 33h
mov ax, 1h
int 33h
mov ax, 3h
int 33h

    


    





    
        
‏exit:
    mov ax, 4c00h
    int 21h
END 
proc OpenFile3
; Open file
mov ah, 3Dh
xor al, al
mov dx, offset filename3
int 21h
jc openerror3
mov [filehandle3], ax
ret
openerror3 :
mov dx, offset ErrorMsg3
mov ah, 9h
int 21h
ret
endp OpenFile3
proc ReadHeader3
; Read BMP file header, 54 bytes
mov ah,3fh
mov bx, [filehandle3]
mov cx,54
mov dx,offset Header3
int 21h
ret
endp ReadHeader3
proc ReadPalette3
; Read BMP file color palette, 256 colors * 4 bytes (400h)
mov ah,3fh
mov cx,400h
mov dx,offset Palette3
int 21h
ret
endp ReadPalette3
proc CopyPal3
; Copy the colors palette to the video memory
; The number of the first color should be sent to port 3C8h
; The palette is sent to port 3C9h
mov si,offset Palette3
mov cx,256
mov dx,3C8h
mov al,0
; Copy starting color to port 3C8h
out dx,al
; Copy palette itself to port 3C9h
inc dx
PalLoop3:
; Note: Colors in a BMP file are saved as BGR values rather than RGB .
mov al,[si+2] ; Get red value .
shr al,2 ; Max. is 255, but video palette maximal
; value is 63. Therefore dividing by 4.
out dx,al ; Send it .
mov al,[si+1] ; Get green value .
shr al,2
out dx,al ; Send it .
mov al,[si] ; Get blue value .
shr al,2
out dx,al ; Send it .
add si,4 ; Point to next color .
; (There is a null chr. after every color.)
loop PalLoop3
ret
endp CopyPal3
proc CopyBitmap3
; BMP graphics are saved upside-down .
; Read the graphic line by line (200 lines in VGA format),
; displaying the lines from bottom to top.
mov ax, 0A000h
mov es, ax
mov cx,200
PrintBMPLoop3 :
push cx
; di = cx*320, point to the correct screen line
mov di,cx
shl cx,6
shl di,8
add di,cx
; Read one line
mov ah,3fh
mov cx,320
mov dx,offset ScrLine3
int 21h
; Copy one line into video memory
cld ; Clear direction flag, for movsb
mov cx,320
mov si,offset ScrLine3
rep movsb ; Copy line to the screen
 ;rep movsb is same as the following code :
 ;mov es:di, ds:si
 ;inc si
 ;inc di
 ;dec cx
;loop until cx=0
pop cx
loop PrintBMPLoop3
ret
endp CopyBitmap3
proc CloseFile3
mov ah,3Eh
mov bx,[filehandle3]
int 21h
ret
endp CloseFile3
proc CleanScreen
push cx
push dx
mov bh,0h
mov cx,[x]
mov dx,[y]
mov al,[color]
column:
mov ah,0ch
int 10h
inc dx
cmp dx, 200
jne column
mov dx, 0
inc cx
cmp cx, 320
jne column
pop cx
pop dx
ret
endp CleanScreen

有我的代码和在屏幕上加载图片的函数(我重复了 3 次),当我的代码到达第三个图像时(在我调用了有效的 CleanScreen 函数之后),这条消息(c:/ tasm/bin)出现无论如何

我尝试清除屏幕但没有运气并在互联网中搜索

提前致谢:)

graphics message x86-16 tasm
1个回答
0
投票

不要关闭 file1 两次

 call CopyBitmap1
 call CloseFile1      <<<<
wait_for_input2:
 mov ah, 07h
 int 21h
 cmp al , 69h
 je function_call
 cmp al , 73h
 je image3
 jmp wait_for_input2
image3:
 call CleanScreen
 call CloseFile1      <<<< Produces DOS error, so may do TERMINATE

以相反顺序从堆栈恢复寄存器

proc CleanScreen
 push cx
 push dx
 ...
 pop cx               <<<< Wrong, should be POP DX
 pop dx               <<<< Wrong, should be POP CX
 ret
endp CleanScreen

我建议你不仅要保留CX和DX,还要保留BX。不过,您可以将破坏性的东西留在 AX 上。

© www.soinside.com 2019 - 2024. All rights reserved.