Hello i'm trying to show a 640x480 BMP image (16 color bitmap) with inline ASM in c++, it has to be with inline asm because it's a homework. I have this code in assembly code to do that:
cad db 'Error, file not found, press a key to finish.$'
filename db "C:\image.bmp"
handle dw ?
col dw 0
ren dw 479
col1 dw ?
ren1 dw ?
col2 dw ?
ren2 dw ?
buffer db ?
colo db ?
eti0:
mov ah,3dh
mov al,0
mov dx,offset filename
int 21h
jc err
mov handle,ax
mov cx,118d
eti1:
push cx
mov ah,3fh
mov bx,handle
mov dx,offset buffer
mov cx,1
int 21h
pop cx
loop eti1
mov ah,00h
mov al,18d
int 10h
eti2:
mov ah,3fh
mov bx,handle
mov dx,offset buffer
mov cx,1
int 21h
mov al,buffer
and al,11110000b
ror al,4
mov colo,al
mov ah,0ch
mov al,colo
mov cx,col
mov dx,ren
int 10h
mov al,buffer
and al,00001111b
mov colo,al
inc col
mov ah,0ch
mov al,colo
mov cx,col
mov dx,ren
int 10h
inc col
mov ah,0ch
mov al,colo
mov cx,col
mov dx,ren
int 10h
cmp col,639d
jbe eti2
mov col,0
dec ren
cmp ren,-1
jne eti2
Now to put it in inline ASM i'm trying with the next code:
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<dos.h>
#include<stdlib.h>
void main(void)
{
clrscr();
unsigned char buffer,colo;
unsigned int handle,col=0,ren=479,col1,col2,ren2;
int filename=675892105109971031011104698109112;
asm{
mov ah,3dh
mov al,0
mov dx,filename
int 21h
mov handle,ax
mov cx,118d
}
cout<<"si mino1";
for(int i=118;i>0;i++){
asm{
mov ah,3fh
mov bx,handle
mov dx,offset buffer
mov cx,1
int 21h
}
}
asm{
mov ah,00h
mov al,18d
int 10h
}
cout<<"si mino2";
eti2:
asm{
mov ah,3fh
mov bx,handle
mov dx,offset buffer
mov cx,1
int 21h
mov al,buffer
and al,11110000b
ror al,4
mov colo,al
mov ah,0ch
mov al,colo
mov cx,col
mov dx,ren
int 10h
mov al,buffer
and al,00001111b
mov colo,al
inc col
mov ah,0ch
mov al,colo
mov cx,col
mov dx,ren
int 10h
inc col
mov ah,0ch
mov al,colo
mov cx,col
mov dx,ren
int 10h
cmp col,639d
jbe eti2
mov col,0
dec ren
cmp ren,-1
jne eti2
}
cout<<"si mino3";
getch();
}
the code reaches to the first cout and then enters in an infinite loop.
Do you really mean the following line of code:
This initializes
i
to 118, and every iteration, adds 1. It will only ever get larger (untili
overflows). The test for whether the loop should continue isi > 0
, which will always be true (untili
overflows).Are you sure you're in an infinite loop? Maybe the many, many
int 21h
just take a very, very long time.