Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Sirrius

@Sirrius
About
Posts
52
Topics
30
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Help with inheritance
    S Sirrius

    Strange. What was so wrong with that. "concAbstFactory.h" is another class that I am going to need to derive other classes from later. Hmmm. Getting rid of it did help though. Thanks for your eagle eye. Brian.

    C / C++ / MFC help oop

  • Help with inheritance
    S Sirrius

    Yes, I am including the header files. Here is some of the original code.

    #ifndef ABSTRACTFACTORY_H
    #define ABSTRACTFACTORY_H
    #include "concAbstFactory.h"
    #include "abstractFactory.h"
    #include "productA.h"
    #include "productB.h"

    using namespace std;

    class abstractFactory{
    public:

    abstractFactory(){}
     
    productA makeProductA(){
    	
    	return productA();
    
    }
    productB makeProductB(){
    
    	return productB();
    }
    

    };

    #endif

    #ifndef CONCABSTFACTORY_H
    #define CONCABSTFACTORY_H
    #include "abstractFactory.h"
    #include "productA.h"
    #include "productB.h"

    using namespace std;

    class concAbstFactory : abstractFactory{
    public:

    concAbstFactory(){
    
    	cout << "Building concAbstFactory" << endl;
    }
    

    };

    #endif

    C / C++ / MFC help oop

  • Help with inheritance
    S Sirrius

    I am trying to do some simple inheritance with a few classes but keep running into an error at compile time. It is error C2504, 'undefined base class'. What does this mean. My classes are defined, I think they are anyway. This is what it looks like.

    class a{

    ;

    class b : public a{

    };

    I am including the files as well. I am just kind of stumped. Thanks Brian.

    C / C++ / MFC help oop

  • Help with inheritance
    S Sirrius

    I am trying to do some simple inheritance with a few classes but keep running into an error at compile time. It is error C2504, 'undefined base class'. What does this mean. My classes are defined, I think they are anyway. This is what it looks like.

    class a{

    };

    class b : public a{

    };

    I am including the files as well. I am just kind of stumped. Thanks Brian.

    C / C++ / MFC help oop

  • C functions
    S Sirrius

    Are there any C functions that are able to check types of devices on your computer. For example, I already have the CPU_Clock_Cycles() and GetLastMemoryAddress() rolling to identify speed and RAM size. I was wondering if there are any more available to perhaps check CPU manufacturer, Hard Drive size and other periphrials. Thanks.

    C / C++ / MFC performance tutorial

  • embedded/C code help
    S Sirrius

    I have some code here that I have been playing with to implement a elevator's computer. I have everything kind of mapped out in my head how it's going to work but am having a problem with converting a char to an int. I would like to send the char c to the thread "move( )" and use it as an int. So bacically, How do I convert a char to an int using only djgpp compiler and multi-c operating system. Here is what I am working with. void move(char c) { } void getFloor(void) { DWORD32 timeout; short c; for(;;) { BYTE8 floor; SetCursorPosition(8,10); while(!ScanCodeRdy()) MtCYield(); floor=GetScanCode(); if ( !(floor & 0x80) ) { c=ScanCode2Ascii(floor); PutString(" Floor "); PutChar(c); } } }

    Mobile help hardware question

  • Embedded/C question
    S Sirrius

    I have some code here that I have been playing with to implement a elevator's computer. I have everything kind of mapped out in my head how it's going to work but am having a problem with converting a char to an int. I would like to send the char c to the thread "move( )" and use it as an int. So bacically, How do I convert a char to an int using only djgpp compiler and multi-c operating system. Here is what I am working with. void move(char c) { } void getFloor(void) { DWORD32 timeout; short c; for(;;) { BYTE8 floor; SetCursorPosition(8,10); while(!ScanCodeRdy()) MtCYield(); floor=GetScanCode(); if ( !(floor & 0x80) ) { c=ScanCode2Ascii(floor); PutString(" Floor "); PutChar(c); } } }

    C / C++ / MFC question hardware help

  • C code help
    S Sirrius

    All I'm trying to do here is calculate the clock time of the computer with a couple C functions. The author of the book tells me "kind of" how to do it but still kind of vague. I am getting a number, but it doesn't seem to be close to the clock speed of the computer(which is 133mhz, yeah yeah, I know it's slow but it boots my embedded apps okay)instead I'm getting a number like 231851640624.......about 20 digits long. Can somebody tell me what I'm doing wrong with my code? Thanks. #include "libepc.h" int main(void) { ClearScreen(0x07) ; SetCursorPosition(10,20); DWORD32 timeout; long long speed; speed=CPU_Clock_Cycles(); PutUnsigned(speed,10,0); timeout = Now_Plus(1); while(Now_Plus(0) < timeout) { speed=CPU_Clock_Cycles(); } PutUnsigned(speed,10,0); return 0 ; }

    Mobile hardware performance help tutorial question

  • more assembly
    S Sirrius

    Well yet another road block for this rookie in assembly coding. I am getting compile errors that say symbol time is undefined and _ctime,_printf,_LCO as well are undefined. I cant figure out why, I have rearranged the global and text labels with no prevail. Maybe one of you guys can spot the idiot flaw that I can't.

    ; .file "ByteSwap4.c"
    global _ByteSwap4_asm
    section .text
    LC0:
    DB "The date is: %s",0

    _ByteSwap4_asm:
    push ebp ;pushl %ebp
    mov ebp,esp ;movl %esp, %ebp
    sub esp,24 ;subl $24, %esp
    sub esp,12 ;subl $12, %esp
    lea eax,[ebp-4] ;leal -4(%ebp), %eax
    push eax ;pushl %eax
    call time ;call _time
    add esp,16 ;addl $16, %esp
    sub esp,8 ;subl $8, %esp
    sub esp,4 ;subl $4, %esp
    lea eax,[ebp-4] ;leal -4(%ebp), %eax
    push eax ;pushl %eax
    call _ctime ;call _ctime
    add esp,8 ;addl $8, %esp
    push eax ;pushl %eax
    push dword _LCO ;pushl $LC0
    call printf ;call _printf
    add esp,16 ;addl $16, %esp
    mov [ebp-8],0 ;movl $0, -8(%ebp)
    L2:
    mov eax,[ebp-8] ;movl -8(%ebp), %eax
    cmp eax,[ebp+8] ;cmpl 8(%ebp), %eax
    jl L5
    jmp L1
    L5:
    mov eax,[ebp-8] ;movl -8(%ebp), %eax
    lea edx,[eax*4] ;leal 0(,%eax,4), %edx
    mov eax,[ebp+12] ;movl 12(%ebp), %eax
    mov eax,[eax+edx] ;movl (%eax,%edx), %eax
    mov [ebp-12],eax ;movl %eax, -12(%ebp)
    mov al,[ebp-ebp] ;movb -12(%ebp), %al
    mov [ebp-13],al ;movb %al, -13(%ebp)
    mov al,[ebp-11] ;movb -11(%ebp), %al
    mov [ebp-14],al ;movb %al, -14(%ebp)
    mov al,[ebp-10] ;movb -10(%ebp), %al
    mov [ebp-15],al ;movb %al, -15(%ebp)
    mov al,[ebp-9] ;movb -9(%ebp), %al
    mov [ebp-16],al ;movb %al, -16(%ebp)
    mov eax,[ebp-8] ;movl -8(%ebp), %eax
    lea ecx,[eax*4] ;leal 0(,%eax,4), %ecx
    mov edx,[ebp+12] ;movl 12(%ebp), %edx
    mov eax,[ebp-16] ;movl -16(%ebp), %eax
    mov [edx+ecx],eax ;movl %eax, (%edx,%ecx)
    lea eax,[ebp-8] ;leal -8(%ebp), %eax
    inc dword [eax] ;incl (%eax)
    jmp L2
    L1:
    leave
    ret

    ;.ident	"GCC: (GNU) 3.2.3"
    
    IT & Infrastructure data-structures question

  • more assembly
    S Sirrius

    Is there a conversion for this at&t syntax into nasm?

    .LC0:
    .ascii "The date is: %s\0"

    _ByteSwap4_asm:

    I don't know if this is enough code to figure it out. I did'nt want to put the entrie page up. It's just supposed to display the time with call in code. .LCO gets pushed on the stack. Thanks.

    IT & Infrastructure data-structures question

  • Assemby
    S Sirrius

    Is there a compiler out there,perhaps the lcc -win32, that can convert C-code to a .s file in NASM format? And is this sytax here the right conversion between AT&T and NASM? MOV [ecx+ebx*4],edx ;movl %edx, 4(%ecx,%ebx) Sorry for the dumb questions. Just kind of getting desperate. Thanks.

    IT & Infrastructure question

  • assembly studs
    S Sirrius

    How about these conversions, are they okay? LEA edx,[eax+edx] ;leal (%eax,%edx), %edx LEA eax,[ebp-12] ;leal -12(%ebp), %eax INC eax ;incl (%eax) MOV dword [ebp-12],0 ;movl $0, -12(%ebp)

    IT & Infrastructure question

  • assembly studs
    S Sirrius

    I have a bunch of assembly code here that I was trying to convert from AT&T to NASM. Could somebody please see if I have made any obvious mistakes? It doesnt seem to want to generate the output it supposed to. Thanks for your time and advice. B.

    ; .file "ByteSwap8.c"
    global _ByteSwap8_asm
    section .text

    _ByteSwap8_asm:
    PUSH ebp ;pushl %ebp
    MOV ebp,esp ;movl %esp, %ebp
    PUSH ebx ;pushl %ebx
    SUB esp,28 ;subl $28, %esp
    MOV dword [ebp-12],0 ;movl $0, -12(%ebp)
    L2:
    MOV eax,[ebp-12] ;movl -12(%ebp), %eax
    CMP eax,[ebp+8] ;cmpl 8(%ebp), %eax
    JL L5
    JMP L1
    L5:
    MOV eax,[ebp-12] ;movl -12(%ebp), %eax
    LEA edx,[0+eax+8] ;leal 0(,%eax,8), %edx
    MOV eax,[ebp+12] ;movl 12(%ebp), %eax
    LEA edx,[eax+edx] ;leal (%eax,%edx), %edx
    MOV eax,[edx] ;movl (%edx), %eax
    MOV edx,[edx+4] ;movl 4(%edx), %edx
    MOV [ebp-24],eax ;movl %eax, -24(%ebp)
    MOV [ebp-20],edx ;movl %edx, -20(%ebp)

    MOV     al,\[ebp-24\]							;movb	-24(%ebp), %al
    MOV     \[ebp-25\],al							;movb	%al, -25(%ebp)
    MOV     al,\[ebp-23\]							;movb	-23(%ebp), %al
    MOV     \[ebp-26\],al							;movb	%al, -26(%ebp)
    MOV     al,\[ebp-22\]							;movb	-22(%ebp), %al
    MOV     \[ebp-27\],al							;movb	%al, -27(%ebp)
    MOV     al,\[ebp-21\]							;movb	-21(%ebp), %al
    MOV     \[ebp-28\],al							;movb	%al, -28(%ebp)
    MOV     al,\[ebp-20\]							;movb	-20(%ebp), %al
    MOV     \[ebp-29\],al							;movb	%al, -29(%ebp)
    MOV     al,\[ebp-19\]							;movb	-19(%ebp), %al
    MOV     \[ebp-30\],al							;movb	%al, -30(%ebp)
    MOV     al,\[ebp-18\]							;movb	-18(%ebp), %al
    MOV     \[ebp-31\],al							;movb	%al, -31(%ebp)
    MOV		al,\[ebp-17\]							;movb	-17(%ebp), %al
    MOV		\[ebp-32\],al							;movb	%al, -32(%ebp)
    
    MOV     eax,\[ebp-12\]						;movl	-12(%ebp), %eax
    LEA     ebx,\[0+eax+8\]						;leal	0(,%eax,8), %ebx
    MOV     ecx,\[ebp+12\]						;movl	12(%ebp), %ecx
    MOV     eax,\[ebp-32\]						;movl	-32(%ebp), %eax
    MOV     edx,\[ebp-28\]						;movl	-28(%ebp), %edx
    MOV     \[ecx+ebx\],eax						;movl	%eax, (%ecx,%ebx)
    MOV     \[4+ecx+ebx\],edx						;movl	%edx, 4(%ecx,%ebx)
    LEA		eax,\[ebp-12\]						;leal	-12(%ebp), %eax
    INC  	dword \[eax\]							    ;incl	(%eax)
    JMP		L2									;jmp	    L2
    

    L1:
    ADD esp,28 ;addl $28, %esp
    POP ebx ;popl %ebx
    POP ebp ;popl %ebp
    RET ;ret
    ;.ident "GCC: (GNU) 3.2.3"

    IT & Infrastructure question

  • Help with a C bug
    S Sirrius

    I have some code here that is supposed to swap bytes in a word. For some reason it has a bug in it in the ByteSwap2 function or the ByteSwap_c function. It's getting very frustrating and time is running out. Can anyone help me..? The main is on the bottom of the code. Thanks. B

    void ByteSwap2_c(int n, short *a)
    {

    int i;

    for (i=0; i

    #include "stdio.h"

    void ByteSwap2_c(int n, short int *a);
    void ByteSwap2_asm(int n, short int *a);

    void ByteSwap2(int n, short int *a)
    {
    int i;
    short *b = (char *) malloc ( n * sizeof(short int));
    for (i=0; i

    C / C++ / MFC help question

  • assembly help
    S Sirrius

    What does this syntax mean and how may I convert it to NASM?

    leal (%eax,%eax),%edx
    movw (%eax,edx),%ax

    ...Anybody? Thanks. B.

    C / C++ / MFC help question

  • Help with some C
    S Sirrius

    I have some C code here, my teachers, that I'm trying to rifle through and figure out. I am confused on on line of it: The second line down is

    *b = (int*) malloc ( n * sizeof(int));

    does this mean a integer pointer that point to a memory location that is 4 times the size of an integer? Which would be then 16 bytes. So a int pointer that points to 16 bytes of vacant memory. Am I right, close or way off. Please help. the code below is what it is out of. Thanks for your help.

    #include "stdio.h"

    void ByteSwap4_c(int n, int *a);
    void ByteSwap4_asm(int n, int *a);

    void ByteSwap4(int n, int *a)
    {
    int i;
    int *b = (int*) malloc ( n * sizeof(int));
    for (i=0; i

    void ByteSwap4_c(int n, int *a)
    {
    int i;
    for (i=0; i

    C / C++ / MFC performance help question

  • Assembly studs
    S Sirrius

    Hey thanks for your advice... I hope I can get through this class.

    The Lounge help question code-review

  • Assembly studs
    S Sirrius

    could somebody please tell me what this may mean in Intel format.

    andl $-16, %esp

    What a class this is, my teacher is teaching us in Intel format and wants us to use the djgpp compiler for our homework. But when I compile or convert a .c file into a .s file its all in at&t format. huh? And now I'm supposed to take some c code that my teacher gave me and optimize with the assembly..."yeah, right. I'll get right on that teach." What it comes down to is I may need a lot of assembly help until about mid December. Thanks.

    The Lounge help question code-review

  • Assembly Help
    S Sirrius

    Thanks for your help. I hope someday I can figure all of this out. Brian.

    IT & Infrastructure question help learning

  • Assembly Help
    S Sirrius

    I am in an Assembly Language class and am really 'not' having fun. haha. The book is vague as well as the teacher. I am sitting here trying to decipher what is going on with my simple code. I understand some of it, but most of it might as well be written in japanese. Can somebody help me with the lines of code I have comments next to?

    .file	"main.c"
    .section .text
    

    .globl _main
    _main:
    pushl %ebp
    movl %esp, %ebp
    subl $8, %esp //this one
    andl $-16, %esp //this one
    movl $0, %eax //this one
    subl %eax, %esp
    movl 12(%ebp), %eax //this one
    addl 8(%ebp), %eax //this one
    movl %eax, -4(%ebp) //this one
    movl -4(%ebp), %eax //this one
    leave
    ret
    .ident "GCC: (GNU) 3.2.3"

    Okay, darn near all of them. haha. Thank you. It will help me get the ball rolling on our assingment.

    IT & Infrastructure question help learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups