[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - QuakeC bytecode docs?

QuakeC bytecode docs?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

QuakeC bytecode docs?

Postby JasonX » Wed Oct 17, 2012 4:09 am

Is there any docs on the QuakeC bytecode? I'm writing a small language that compiles into QuakeC byte code as an experiment and could not find much info about it.
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: QuakeC bytecode docs?

Postby Seven » Wed Oct 17, 2012 2:37 pm

Hello JasonX,

I am not quite sure what you mean.
If you mean the different existing WRITEBYTE cases, please look into this interesting thread:
viewtopic.php?f=2&t=848
It also links to a site with a list of all variations.

Best regards,
Seven
Seven
 
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: QuakeC bytecode docs?

Postby goldenboy » Wed Oct 17, 2012 5:04 pm

I believe he means the stuff that comes out of a QC compiler, ie the format of the stuff in a progs.dat.
User avatar
goldenboy
 
Posts: 924
Joined: Fri Sep 05, 2008 11:04 pm
Location: Kiel

Re: QuakeC bytecode docs?

Postby Spike » Wed Oct 17, 2012 5:27 pm

seven, no, he means the stuff generated by a qcc inside the progs.dat itself.

read pr_exec.c for 'docs', don't think anyone cared enough to properly document them.
mostly they're just A OP B->C
there's also 2-operand instructions (stores and unary operators) which take their input in A and store into B instead of C, and don't use C.
OP_GOTO stores an instruction count offset (signed) in its A operand. OP_IF/OP_IFNOT contain their condition boolean within A, and their instruction offset in B.

with fteqcc, you can use the -fwrasm commandline argument to get fteqcc to write out a 'qc.asm' file containing a text-based representation of the opcodes generated, if you want to see a readableish example.
you'll need to check the engine or a qcc to get the numerical value of each opcode.

note that you'll still need to figure out the globaldef, function, fielddef, etc sections too.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: QuakeC bytecode docs?

Postby JasonX » Thu Oct 18, 2012 4:11 pm

Thanks, Spike. I didn't know about fwrasm. This will be very useful, since after crawling through qcc's source, i could not find a proper lexer structure to find my way into the opcodes.
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: QuakeC bytecode docs?

Postby taniwha » Fri Oct 19, 2012 2:55 am

The "opcode table" is in pr_parse.c. Look for pr_opcodes. I consider that table to be an abomination, but then, that's part of why II almost completely re-wrote the compiler :) (qfcc)
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: QuakeC bytecode docs?

Postby JasonX » Sat Oct 20, 2012 5:06 pm

There are different opcodes for different types... float, vector, entity and function. This is very strange. But thank you for the file... i'm basing myself on ProQCC: https://github.com/lbsmith/ProQCC/blob/ ... /pr_comp.c
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: QuakeC bytecode docs?

Postby taniwha » Sun Oct 21, 2012 1:36 am

Up until OP_BITOR (last qcc opcode), all compilers will generate the same opcodes, so it doesn't really matter which compiler you study. For that, anyway (eg, qfcc is radically different: flex lexer, bison parser, expression trees, statement blocks, Objective-QuakeC data-structures (in theory, compatible with Objective-C, but I suspect I may have broken a few things there), object files, linker, library files, cpp preprocessing...).
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: QuakeC bytecode docs?

Postby Spike » Sun Oct 21, 2012 3:29 am

proqcc should be readable at least. :P
but yeah, the instruction set is the same regardless of qcc. qfcc and fteqcc both support (separate) extended opcodes for their respective engine, but engine support for these extra opcodes are somewhat rare, and likely not enabled by default.

the exact behavior of the opcodes is not the only thing you have to contend with, but also the function/globaldef/fielddef tables will need to be in place before you can really test anything.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest