Subject: Re: Help for a newbie on a simple graphics call Date: 24 Mar 1998 06:35:09 GMT From: silva@dowco.com (Silva) Organization: dowco.com internet (ISP) Newsgroups: comp.lang.asm.x86 "Steven Talbott" wrote: >I need someone's help to figure this one out. I pulled this straight out of >a book, and am compiling under tasm 5.0 I am trying to pass parameters to >the program, but it gives me the errors: >9: Extra Characters on line >13: Undefined symbol VMODE I don't have TASM, but I would expect it to be confused, there should be a leading blank (or better yet, a TAB) in front of instructions, otherwise the assembler may think some of your instructions are Labels. For example you have: >mov ah,0 ; function 0:set video mode >mov al, BYTE PTR vmode ; set the mode we want to change to >int 10h ; use BIOS to set the mode with a TAB becomes.... mov ah,0 ; function 0:set video mode mov al, BYTE PTR vmode ; set the mode we want to change to int 10h ; use BIOS to set the mode Also, somtimes it's easier to understand if you have everything out in the open where you can see it rather than more cryptic with all these codes, so instead of using these... >.MODEL MEDIUM,C ; use medium model with C parameter passing >.CODE ; this is the beginning of the code >PUBLIC Set_Mode ; this let's the linker have access to the function > ; name so that it can be exported >Set_Mode PROC FAR C vmode:WORD ; the function takes one parameter ...You may want to check-out the code below since everything is out in the open where you can follow it step-for-step. Hope it helps. note: The 'C' used here didn't require saving AX,BX,CX,DX so you'll see that the PUSH/POPs are absent, you may need to add them. ---------------------------------------- page 59,132 title Video assembler routines public _Cls,_GetMode,_SetMode,_PutDot CodeSeg_Video segment dword public 'CODE' assume cs:CodeSeg_Video SCREEN_WIDTH equ 320 ;VGA screen pixel dimensions SCREEN_HEIGHT equ 200 ;void far pascal _Cls(char far *screen) ; clear video memory or offscreen buffer at screen to zeroes align 2 _Cls proc far screen equ ss:[bx+4] ;location of 'screen' mov bx,sp push di push es les di,screen ;point ES:DI at screen .386 sub eax,eax ;store zero values mov ecx,SCREEN_WIDTH/4 * SCREEN_HEIGHT ;count pixels rep stosd ;32bit store .8086 pop es ;restore registers and exit pop di ret 4 _Cls endp ;short far pascal _GetMode(void) ; get current video adapter mode from BIOS align 2 _GetMode proc far mov ah,0Fh ;request current video mode int 10h sub ah,ah ;only need al ret _GetMode endp ;void far pascal _SetMode(short mode) ; set VGA adapter to BIOS mode MODE align 2 _SetMode proc far mode equ ss:[bx+4] ;location of 'mode' mov bx,sp mov ax,mode ;ax=video mode sub ah,ah ;ah=function 0 int 10h ;call video BIOS ret 2 ;cleanup and exit _SetMode endp ;void far pascal _PutDot(int xPos,int yPos,char far *screen) ; Put a Dot at xPos/yPos align 2 _PutDot proc far xPos equ +12 ;word, location of xPos from BP yPos equ +10 ;word buf_Seg equ +8 ;word (note: we'll do something else..) buf_Off equ +6 ;word (..instead of les this time) push bp ;(remember BP=2bytes, far call=4bytes) mov bp,sp ;point to stack variables push es ;'C' wants these registers preserved push di mov ax,[bp].buf_Seg ;point ES:DI to Screen mov es,ax mov ax,[bp].buf_Off ;(...we didn't do les this time) mov di,ax mov ax,[bp].yPos ;move yPos rows down screen mov dx,SCREEN_WIDTH mul dx ;result in DX:AX, result of DX=0 here add ax,[bp].xPos ;move xPos columns over add di,ax mov ax,15 ;let's stick something at xPos/yPos mov es:[di],ax pop di ;now cleanup and exit pop es pop bp ret 8 _PutDot endp CodeSeg_Video ends end ---------------------------------------- #include #define VGA256 0x13 extern void far pascal _Cls(char far *screen); extern short far pascal _GetMode(void); extern void far pascal _SetMode(short mode); extern void far pascal _PutDot(int xPos,int yPos,char far *screen); void main(void); void main(void) { int t,old_mode; char far *screen; screen = 0xA0000000; /*we force pointer to video screen*/ /* set video mode to 320x200 256 color mode */ old_mode = _GetMode(); _SetMode(VGA256); _Cls(screen); /* put a dot on the screen */ _PutDot(100,50,screen); /* wait for keyboard to be hit */ while(!kbhit()); /* go back to previous mode */ _SetMode(old_mode); }