sgratton

possible inline literals issue and calclAssembleObject/calclDisassembleObject

Discussion created by sgratton on Apr 1, 2008
Latest reply on Apr 2, 2008 by MicahVillmow
Hi there,

I've been experimenting with the cal compiler and there seems to be something strange somewhere with inline literals and calclAssembleObject and/or calclDisassembleObject. Following the assembly language format document, I think such literals should be specified as e.g. (287.3f).x. However, when I try this and assemble and then disassemble a simple program, this doesn't seem to be quite working (code at bottom). It looks like the float is being converted to an integer whose bit pattern is then being reinterpreted as a float:

Original program:

;Testing inline literals
00 ALU: ADDR(32) CNT(5)
0 x: MOV R0.x, 1.0f
y: MOV R0.y, 0.0f
z: MOV R0.z, (4096f).x
w: MOV R0.w, (8.3f).y
01 EXP_DONE: PIX0, R0
END_OF_PROGRAM


Disassembly:

; -------------- PS Disassembly --------------------
00 ALU: ADDR(32) CNT(5)
0 x: MOV R0.x, 1.0f
y: MOV R0.y, 0.0f
z: MOV R0.z, (0x00001000, 5.739718510e-42f)
w: MOV R0.w, (0x00000008, 1.121038771e-44f)
01 EXP_DONE: PIX0, R0
END_OF_PROGRAM
...

Special select constants seem to work okay though.

Also, what should be the difference between calclCompile with the language set to CAL_LANGUAGE_ISA and calclAssembleObject? In any case I couldn't get the former to work.

Thanks,
Steven.

************

#include <iostream>
#include "calcl.h"

using namespace std;

void disp(const char* msg)
{
cout << msg;
}

int main()
{
const char R600prog[] =
";Testing inline literals \n"
"00 ALU: ADDR(32) CNT(5) \n"
" 0 x: MOV R0.x, 1.0f \n"
" y: MOV R0.y, 0.0f \n"
" z: MOV R0.z, (4096f).x \n"
" w: MOV R0.w, (8.3f).y \n"
"01 EXP_DONE: PIX0, R0 \n"
"END_OF_PROGRAM\n";

cout << endl << "Original program: " << endl << endl;
disp(R600prog);

CALobject object = NULL;
calclAssembleObject(&object,CAL_PROGRAM_TYPE_PS,R600prog,CAL_TARGET_670);

cout << endl << endl << "Disassembly: " << endl;
calclDisassembleObject(&object,disp);
calclFreeObject(object);

return 0;
}

Outcomes