简体   繁体   中英

DB ASM variable in Inline ASM C++

I'm trying to figure out how to use DB variables from ASM into Inline ASM C++

I have this ASM code:

filename db "C:\imagen.bmp"
eti0:
mov ah,3dh 
mov al,0 
mov dx,offset filename 
int 21h  

and in C++:

//ASCII of C:\imagen.bmp plus zero in the end because of int 21h
int filename=6758921051099710310111046981091120;

asm{
    mov ah,3dh 
    mov al,0 
    mov dx,offset filename
    int 21h
}

Is this is correct?

The type int can only hold a 16-bit signed integer and the number you tried to assign to filename is way outside its range. As int variables are two bytes long, they're not all that useful for storing file names. Instead you should store the name in an array of char like this:

char filename[] = "C:\\imagen.bmp";

The array will include a zero byte as its final element, as normal for strings in C++.

You could also replace entire thing with:

int handle;
_dos_open("C:\\imagen.bmp", 0, &handle);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM