Click here to Skip to main content
16,011,611 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dependency Walker lists a DLL as missing. However, program works without Error. Why? Pin
David Crow12-Apr-04 5:15
David Crow12-Apr-04 5:15 
GeneralRe: Dependency Walker lists a DLL as missing. However, program works without Error. Why? Pin
Prakash Nadar12-Apr-04 4:01
Prakash Nadar12-Apr-04 4:01 
AnswerRe: Dependency Walker lists a DLL as missing. However, program works without Error. Why? Pin
Tim Smith12-Apr-04 6:26
Tim Smith12-Apr-04 6:26 
GeneralNewbie GDI question Pin
Indrawati12-Apr-04 2:21
Indrawati12-Apr-04 2:21 
GeneralRe: Newbie GDI question Pin
David Crow12-Apr-04 3:53
David Crow12-Apr-04 3:53 
GeneralFile reading Pin
perozbabu12-Apr-04 2:10
perozbabu12-Apr-04 2:10 
GeneralRe: File reading Pin
David Crow12-Apr-04 3:58
David Crow12-Apr-04 3:58 
GeneralForm Width/Height & Pointer problem Pin
uus9912-Apr-04 2:02
uus9912-Apr-04 2:02 
Hi, how to set form/control width and height in VC++ IDE or in code? I mean, if i want it
to be exactly 100x200pixels, how do i do that? Is there anything similar to Visual Basic?


I have a simple program that adds two numbers in array using MMX (inline assembly), the program works fine, the code as shown below,

The result on screen is :
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
which is correct,

however, if i change the line

char incamt[]={u,u,u,u,u,u,u,u};

to

char *incamt;
incamt=new char[8];
for(int j=0;j<8;j++) incamt[j]=u;

the program compiles but the result is wrong! Why is that?
Output:
9 82 117 68 17 18 19 20 17 90 125 76 25 26 27 28 25 98 -123 84 33 34 35 36



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

void main()
{
const u = 5;

//an array of increment amounts to aid SIMD-style operation
char incamt[]={u, u, u, u, u, u, u, u};

//instr is an array of 24 bytes
char instr[]={65,66,67,68,69,70,71,72,73,74,75,
76,77,78,79,80,81,82,83,84,85,86,87,88};

//the following is an embedded assembly code which
//uses MMX instructions to add in parallel the
//amount u to all the bytes of the array instr
__asm
{
movq mm1,incamt //mm1 has value u in all its 8 bytes
mov cx, 3 //initialize loop count
mov esi, 0 //initialize index register
L: movq mm0, instr[esi] //mm0=next 8 bytes from instr
paddb mm0,mm1 //parallel add 8 bytes of mm0 & mm1
movq instr[esi],mm0 //move result to instr
add esi, 8 //update index register
loop L //loop back
emms //empty MMX state
} //end of assembly code

//C++ code to output the results for verification
for (int i=0;i<24;i++) cout<<int(instr[i])<<" ";
="" cout<<endl;

="" just="" to="" pause="" the="" screen
="" cin="">>i;

} //end of main
GeneralCompiler Error Pin
Kash12-Apr-04 1:58
Kash12-Apr-04 1:58 
GeneralRe: Compiler Error Pin
Nitzan Shaked12-Apr-04 2:47
Nitzan Shaked12-Apr-04 2:47 
GeneralRe: Compiler Error Pin
Kash12-Apr-04 3:24
Kash12-Apr-04 3:24 
GeneralRe: Compiler Error Pin
Nitzan Shaked12-Apr-04 7:05
Nitzan Shaked12-Apr-04 7:05 
GeneralRe: Compiler Error Pin
Kash13-Apr-04 23:05
Kash13-Apr-04 23:05 
GeneralSplitters! Message Box Pin
ZoomBoy2712-Apr-04 1:49
ZoomBoy2712-Apr-04 1:49 
GeneralRe: Splitters! Message Box Pin
ZoomBoy2712-Apr-04 2:00
ZoomBoy2712-Apr-04 2:00 
QuestionHard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
Freddie Code12-Apr-04 1:15
Freddie Code12-Apr-04 1:15 
AnswerRe: Hard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
Milton Karimbekallil12-Apr-04 1:57
Milton Karimbekallil12-Apr-04 1:57 
AnswerRe: Hard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
David Crow12-Apr-04 4:12
David Crow12-Apr-04 4:12 
AnswerRe: Hard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
Darshan Jani12-Apr-04 7:47
Darshan Jani12-Apr-04 7:47 
GeneralTrouble with _variant_t Pin
yanuart12-Apr-04 1:08
yanuart12-Apr-04 1:08 
GeneralRe: Trouble with _variant_t Pin
Milton Karimbekallil12-Apr-04 1:48
Milton Karimbekallil12-Apr-04 1:48 
QuestionAre there somewhere good articles about MTS ? Pin
vgrigor12-Apr-04 0:53
vgrigor12-Apr-04 0:53 
Generalunsigned chars Pin
packetlos12-Apr-04 0:10
packetlos12-Apr-04 0:10 
GeneralRe: unsigned chars Pin
John R. Shaw12-Apr-04 0:37
John R. Shaw12-Apr-04 0:37 
GeneralRe: unsigned chars Pin
packetlos12-Apr-04 1:21
packetlos12-Apr-04 1:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.