Helpppppp Why won't this compile?
| Author |
Message |
|
R. Offenbech #1 / 12
|
 Helpppppp Why won't this compile?
hi, I can not get the following code to compile on my Borland C++ compiler the error I keep getting is Label not defined, I have tried lots of wierd things trying to get this to work but nothing works. Is there something special that I have to do when using labels, or do I have to set something in my options. Any help would be great!!! void WaitRetrace (){ asm{ mov dx, 3dah l1: in al, dx and al, 08h jnz l1 l2: in al, dx and al, 08h jz l2 } Quote: }
Thanks in advance. ,,,
---------------oOO--<_>--OOo------------------------------------------
"then redefine success."
|
| Tue, 29 Apr 1997 08:06:38 GMT |
|
 |
|
Gerry Mille #2 / 12
|
 Helpppppp Why won't this compile?
Quote: > hi, > I can not get the following code to compile on my Borland C++ compiler > the error I keep getting is Label not defined, I have tried lots of wierd > things trying to get this to work but nothing works. Is there something > special that I have to do when using labels, or do I have to set something > in my options. Any help would be great!!! > void WaitRetrace (){ asm{ > mov dx, 3dah > l1: > in al, dx > and al, 08h > jnz l1 > l2: > in al, dx > and al, 08h > jz l2 > } > }
Yes, in Borland C++, labels cannot be in the asm block. So, you need to rewrite it like this: void WaitRetrace () { asm{ mov dx, 3dah } l1: asm { in al, dx and al, 08h jnz l1 } l2: asm { in al, dx and al, 08h jz l2 } Quote: }
Hope this helps. Gerry Miller
|
| Tue, 29 Apr 1997 23:38:03 GMT |
|
 |
|
akala kennedy ( bs cm #3 / 12
|
 Helpppppp Why won't this compile?
: > hi, : > I can not get the following code to compile on my Borland C++ compiler : > the error I keep getting is Label not defined, I have tried lots of wierd : > things trying to get this to work but nothing works. Is there something : > special that I have to do when using labels, or do I have to set something : > in my options. Any help would be great!!! : > : > void WaitRetrace (){ asm{ : > mov dx, 3dah : > l1: : > in al, dx : > and al, 08h : > jnz l1 : > l2: : > in al, dx : > and al, 08h : > jz l2 : > } : > } : Yes, in Borland C++, labels cannot be in the asm block. So, you need : to rewrite it like this: : void WaitRetrace () { : asm{ : mov dx, 3dah : } : l1: : asm { : in al, dx : and al, 08h : jnz l1 : } : l2: : asm { : in al, dx : and al, 08h : jz l2 : } : } : Hope this helps. : Gerry Miller Actually, labels can be in the asm block, with some restrictions: the labels can only be used locally ( you can't jump to them from anywhere outside the
K.Akala
|
| Wed, 30 Apr 1997 03:21:17 GMT |
|
 |
|
Davor Slamn #4 / 12
|
 Helpppppp Why won't this compile?
Quote:
> hi, > I can not get the following code to compile on my Borland C++ compiler > the error I keep getting is Label not defined, I have tried lots of wierd > things trying to get this to work but nothing works. Is there something > special that I have to do when using labels, or do I have to set something > in my options. Any help would be great!!! > void WaitRetrace (){ asm{ > mov dx, 3dah > l1: > in al, dx > and al, 08h > jnz l1 > l2: > in al, dx > and al, 08h > jz l2 > } > }
You can't have labels in inline assembly blocks in BC 3.1 (I won't comment on the fact, I might use words some people might find offensive). Write it like this: void WaitRetrace() { asm{ mov dx, 3dah } l1: asm{ in al, dx and al, 08h jnz l1 } l2: asm{ in al, dx and al, 08h jz l2 } } } Nice, isn't it? But - a friend told me yesterday you _can_ have labels in inline assembly blocks if the first character of the label is
Slama
|
| Wed, 30 Apr 1997 21:33:26 GMT |
|
 |
|
Andrew Pay #5 / 12
|
 Helpppppp Why won't this compile?
: hi, : I can not get the following code to compile on my Borland C++ compiler : the error I keep getting is Label not defined. This will work (or it is what I do anyway). I don't know if there is a better way. : void WaitRetrace (){ asm{ : mov dx, 3dah} : l1: asm { : in al, dx : and al, 08h : jnz l1} : l2: asm { : in al, dx : and al, 08h : jz l2 : } : } hmmm, messy. For something this small you could just slap in a heap of asm's. void waitretrace() { asm mov dx, 3dah l1: asm in al, dx asm and al, 08h asm jnz l1 l2: asm in al, dx asm and al, 08h asm jz l2 Quote: }
looks better, but it is up to you. anyone know of a way to get around this, cause it is a bit of a pain. andy.
|
| Wed, 30 Apr 1997 00:27:47 GMT |
|
 |
|
Adam Wiggi #6 / 12
|
 Helpppppp Why won't this compile?
Quote: > I can not get the following code to compile on my Borland C++ compiler >the error I keep getting is Label not defined, I have tried lots of wierd >void WaitRetrace (){ asm{ > mov dx, 3dah > l1:
As I recall Borland is a little lacking when it comes to inline assembly. I believe if you do the following: asm { /* asm code here */ } l1: asm { etc...it should work. ...Boone
|
| Wed, 30 Apr 1997 19:58:57 GMT |
|
 |
|
John Max Skall #7 / 12
|
 Helpppppp Why won't this compile?
Quote:
>This will work (or it is what I do anyway). I don't know if there is a >better way. >: void WaitRetrace (){ asm{ >: mov dx, 3dah} >: l1: >asm { >: in al, dx >: and al, 08h >: jnz l1} >: l2: >asm { >: in al, dx >: and al, 08h >: jz l2 >: } >: } >hmmm, messy. >For something this small you could just slap in a heap of asm's. >void waitretrace() >{ > asm mov dx, 3dah > l1: > asm in al, dx > asm and al, 08h > asm jnz l1 > l2: > asm in al, dx > asm and al, 08h > asm jz l2 >} >looks better, but it is up to you. >anyone know of a way to get around this, cause it is a bit of a pain.
void waitrace(){ while(inportb(0x3da) & 8); while(!(inportb(0x3da) & 8)); } --
Maxtal Pty Ltd, 81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21 NSW 2037, AUSTRALIA Phone: 61-2-566-2189
|
| Wed, 30 Apr 1997 20:35:51 GMT |
|
 |
|
Merle Kemmerly I #8 / 12
|
 Helpppppp Why won't this compile?
Quote: > hi, > I can not get the following code to compile on my Borland C++ compiler > the error I keep getting is Label not defined, I have tried lots of wierd > things trying to get this to work but nothing works. Is there something > special that I have to do when using labels, or do I have to set something > in my options. Any help would be great!!! > void WaitRetrace (){ asm{ > mov dx, 3dah > l1: > in al, dx > and al, 08h > jnz l1 > l2: > in al, dx > and al, 08h > jz l2 > } > }
You can not put labels within a asm { }. Try this void WaitRetrace(void) { asm mov dx,3dah l1: asm { in al,dx and al,8 jnz l1 } l2: asm { in al,dx and al,8 jz l2 } Quote: }
+----------------------+-----------------------------------------------+
| VeriFone Inc. | | | 12830 Earhart Avenue | | | Auburn, CA 95602 | | +----------------------+-----------------------------------------------+
|
| Sun, 04 May 1997 07:03:43 GMT |
|
 |
|
John Palai #9 / 12
|
 Helpppppp Why won't this compile?
Quote:
> You can't have labels in inline assembly blocks in BC 3.1 > (I won't comment on the fact, I might use words some people > might find offensive). Write it like this:
Or better yet, write the function externally as a .asm file and link it in. No limits then :) and you'd be using TASM so you could do stuff like: model small, c ideal proc WaitRetrace C USES ax dx mov dx, 3dah l1: in al, dx and al, 08h jnz l1 l2: in al, dx and al, 08h jz l2 endp WaitRetrace Quote: > But - a friend told me yesterday you _can_ have labels in > inline assembly blocks if the first character of the label is
Somehow, I doubt this... --\Richard Cooley Extraordinaire "Yeah. Arrgh."
"LILO - it's not just a boot loader, it's a way of life" -- me
|
| Mon, 05 May 1997 01:20:53 GMT |
|
 |
|
Julian Nichol #10 / 12
|
 Helpppppp Why won't this compile?
Quote: > hi, > I can not get the following code to compile on my Borland C++ compiler > the error I keep getting is Label not defined, I have tried lots of wierd > things trying to get this to work but nothing works. Is there something > special that I have to do when using labels, or do I have to set something > in my options. Any help would be great!!! > void WaitRetrace (){ asm{ > mov dx, 3dah > l1: > in al, dx > and al, 08h > jnz l1 > l2: > in al, dx > and al, 08h > jz l2 > } > }
Unfortunately this was one of the first things I learnt when switching to (IMHO the far better) Borland from Mickeysoft. The labels must be defined outside of the enclosing asm {}. i.e. void WaitRetrace () { asm { mov dx, 3dah } l1: asm { in al, dx and al, 08h jnz l1 } l2: asm { in al, dx and al, 08h jz l2 } Quote: }
L8r -- Julian Nicholls
My opinions bear no relation to my employer's!
|
| Mon, 05 May 1997 05:49:04 GMT |
|
 |
|
Jerzy Tarasi #11 / 12
|
 Helpppppp Why won't this compile?
Quote:
>> You can't have labels in inline assembly blocks in BC 3.1 >Or better yet, write the function externally as a .asm file and link >it in. No limits then :) and you'd be using TASM so you could do stuff like: >model small, c >ideal >proc WaitRetrace C USES ax dx
No need to save ax,dx if called from C. C requires to restore: cs,ip,ss,sp,ds,bp - always, si,di - if register variables are used (compiler option) Some 32-bit compilers require restore all except aex,ecx,edx.
|
| Thu, 08 May 1997 01:58:48 GMT |
|
 |
|
pixelate #12 / 12
|
 Helpppppp Why won't this compile?
Quote:
>>proc WaitRetrace C USES ax dx >No need to save ax,dx if called from C. >C requires to restore: cs,ip,ss,sp,ds,bp - always, >si,di - if register variables are used (compiler option)
A few comments. 1) I usually save the registers I use in a proc, for safety's sake. You can elide them if you don't need them :) 2) Actually, you should probably say "<compiler xxx> requires to restore yyy registers" for completeness sake, but I'm hardly one to lecture on *that* topic :) 3) I wouldn't save cs or ip--I assume you mean the caller's cs:ip. That's on the stack already. 4) I wouldn't change ss:sp unless I was switching stacks; in this case, I'd be using the same stack. No need to save those regs. 5) The extended call syntax saves bp if you use USES or ARGS or LOCAL; look at a listing file some time--you'll see what I mean. Basically, An external asm program, properly written, shouldn't have to worry about the registers you mentioned, especially if it's written to link into the C program's code segment! -- Richard Cooley Extraordinaire "Yeah. Arrgh."
"LILO - it's not just a boot loader, it's a way of life" -- me
|
| Thu, 08 May 1997 14:09:38 GMT |
|
| |
|