You'll have to show us where your parsing your input...
Also try this
new \> ello.txt
< and > are meta-chararters
You'll have to show us where your parsing your input...
Also try this
new \> ello.txt
< and > are meta-chararters
and my question is .....what -ggdb actual do
Produce debugging information for use by GDB
As for warnings, you'll have to post any warnings if you want them explained..
hi
when I use this with my program i have msg tell me about the warning in my programplease any one explain it
thanks
ggdb
`-ggdb'
Produce debugging information for use by GDB. This means to use
the most expressive format available (DWARF 2, stabs, or the
native format if neither of those are supported), including GDB
extensions if at all possible.
GDB, the GNU symbolic debugger
Im mid way through writting my own c shell and having trouble with my redirecting,
i use strtok to spilt the input into 2 parts, argv0 being command and argv1 being cmd
i have this for redirecting so far
if(strcmp(cmd,">")==0) { strcpy(filename, command); filein = open(filename, O_RDONLY); dup2(filein,0); close(filein); break; } else if(strcmp(cmd,"<")==0) { strcpy(filename, command); fileout = open(filename, O_WRONLY); dup2(fileout,1); close(fileout); break; }
any help?
What's the question or what's the problem?
Unfortunately, I am not using Linux. I am using Windows 7 and using Cygwin to compile. The professor wanted us to use a UNIX environment and since I am using Windows I have to use CYGWIN to get what he wants.
Here's the web site for man wait
I'm assuming your running some version of Linux, right?
If you are then open a terminal window and type 'man 2 wait'
It should display something like below
WAIT(2) Linux Programmer's Manual WAIT(2)
NAME
wait, waitpid, waitid - wait for process to change stateSYNOPSIS
#include <sys/types.h>
#include <sys/wait.h>pid_t wait(int *status);
pid_t waitpid(pid_t pid, int *status, int options);
int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
Now while still in the terminal scroll down until you see the example code...It will be towards the bottom
Do you have access to man or info?
IF i write to file REGISTRATION NUMBER :1001 how can read back from the file the 1001.
Thank you for all your help,i have gotten other hints but they don't seem to work
Well lets see what you've done with some of your hints.
Or you could try Gawk/Awk
awk '{for (i = 2; i <= NF; ++i){printf("%s ",$i);{if (i==NF){printf("\n");}}}}' filename
hi, i'm beginner in assembler, i'm just start study this language...
please can someone explain me, what do this two functions?
cbr flags, (1<<pressed) ;Clear status flag
sbr flags,(1<<pressed) ;Set status flagplease if you insert example, it will be only better...:)
These above instructions...which machine do they go with?
scanf("%f", restart);
should be
scanf("%f", &restart);}
Try setting
hold[0] = '\0';
Or you may try using buffer[0] == '|'
Try using an if statement
Thanks for the reply and advice Aia...
Are you giving up before achieving an one-liner?
No...
Isn't funny how languages strive for coherency and function while 'some' programmers strive for one line esoteric marvels...That said, one line esoteric marvels are a wonder to create and show off...
. . And will more than likely look nothing like it would if you wrote it.
Yeah your probably right but is a starting point...I usually block off the code in question with two inline assembly sections, one at the start of the code in question and on at the end of the code in question..The inline code just has a nop so as not to changed the code
__asm__ ("nop\n\t");
...code in question
__asm__ ("nop\n\t");
The rule is - for every malloc you call, you have to call free..
Well I think this is the last version...I think or hope. I starting to get a love/hate relationship with shell scripting...its really something but I'm not really sure what...;)
script cnvt
#! /bin/sh
if [ $# -ne 3 ]
then
echo "usage error - cnvt value inbase outbase"
exit 1
fi
if which tr > /dev/null 2>&1 && which bc > /dev/null 2>&1
then
myupper=$(eval "echo $1 | tr '[:lower:]' '[:upper:]'")
getconvert="echo 'obase=$3;ibase=$2;$myupper' | bc"
eval $getconvert
else
echo "could not find the application(s) 'tr' or 'bc'"
echo "please check to make sure they are installed correctly"
exit 1
fi
exit 0
Most C++ compilers offer a setting to stop compiling..
In GNU its
g++ file.cpp -S
`-S'
Stop after the stage of compilation proper; do not assemble. The
output is in the form of an assembler code file for each
non-assembler input file specified.
Just tried your code on my machine(64 bit) and it worked...
Actually I decided on this as a final version unless someone can see any problems with it...
#! /bin/sh
slash="/"
filename1="tr"
filename2="bc"
value=$1
inbase=$2
outbase=$3
if [ $# -ne 3 ]
then
echo "usage error - cnvt value inbase outbase"
echo "cnvt - program name"
echo "value - numeric value to convert"
echo "inbase - numeric base of the value to convert"
echo "outbase - numeric base of the converted value"
exit 1
fi
IFS=':'
set $PATH
searchit()#see if required programs - tr and bc can be found
{
for mypath in $PATH
do
if [ -f $mypath${slash}${1} ]
then
#echo "found it - $mypath${1}"
return 0
fi
done
echo "could not find $1"
echo "please check to see that $1 is installed"
return 1
}
if searchit "$filename1" && searchit "$filename2"
then
:
else
exit 1
fi
unset IFS
#parameter 1 needs to be uppercase for hex..
val="echo ${value} | tr '[:lower:]' '[:upper:]'"
y=$(eval $val)
bcstr="echo 'obase=${outbase};ibase=${inbase};${y}' | bc"
eval $bcstr
exit 0
Hi, I wrote this simple bash script(yeah simple now that its done) and it uses bc - 'The arbitrary precision calculator language' and tr - 'translate or delete characters'. Now the script works, it will take input values and convert them to the proper output values. Now my question is..is this the proper way to do it? I'm not very experienced with shell scripting...well anything complicated.
script usage:
cnvt value inbase outbase
example:
cnvt ff 16 2
cnvt takes value ff of base 16 and converts it to base 2.
cnvt
#! /bin/sh
if [ -f /usr/bin/bc ]
then
:
else
echo "Could not find the 'bc' calculator"
echo "please install bc - The arbitrary precision calculator language"
echo "or you may have to create a link - /usr/bin/bc"
exit 1
fi
if [ $# -ne 3 ]
then
echo "usage error - cnvt value inbase outbase"
echo "cnvt - program name"
echo "value - numeric value to convert"
echo "inbase - numeric base of the value to convert"
echo "outbase - numeric base of the converted value"
exit 1
fi
#parameter 1 needs to be uppercase for hex..
val="echo ${1} | tr '[:lower:]' '[:upper:]'"
y=`eval $val`
bcstr="echo 'obase=${3};ibase=${2};${y}' | bc"
eval $bcstr
exit 0
Scanf isn't clearing the input buffer of the new line character..
i.e. When you enter an operator you enter the operator character plus you hit the return key...So two characters are placed in the input buffer, the one you want plus the newline character and scanf only picks up the operator character leaving the newline in the buffer.
Here's a very simple example of executing a line of code(the inline code) and jumping over the data which is contained in the same section...Note this is 64 bit assembler not 16 bit..
#include <stdio.h>
#include <stdlib.h>
void myfunc(void)
{
__asm__
(
" pushq %rax \n\t"
" pushq %rdi \n\t"
" pushq %rsi \n\t"
" pushq %rdx \n\t"
" call tohere \n\t"
" tohere: \n\t"
" popq %rsi \n\t"
" .equ myoff, . - mydata \n\t"
" addq $-myoff + 0x1, %rsi \n\t"
" movq $1, %rax \n\t"
" movq $1, %rdi \n\t"
" movq $mylen, %rdx \n\t"
" syscall \n\t"
" jmp tohere2 \n\t"
" mydata: .ascii \"this is the message to pass along!\n\" \n\t"
" .equ mylen, . - mydata \n\t"
" tohere2: \n\t"
" popq %rdx \n\t"
" popq %rsi \n\t"
" popq %rdi \n\t"
" popq %rax \n\t"
);
}
int main(int argc, char**argv)
{
myfunc();
exit(EXIT_SUCCESS);
}
Is this the new format for posting code? What happen the code tags?
Certainly...What's the problem?
So...What do you have so far.
Hello,
I've an external/global array that is used every where in my code.
// global.h file short is_valid[10];
I initialize my array somewhere in the code and I want to check if everything works. When I try to print the values of the array, I get segmentation fault.
// .c file short *pValid = is_valid; memset(&pValid, 1, 10 * sizeof (short)); for (i = 0; i < 10; i++) printf("%d ", *(&pValid[i])); // the seg fault is here printf("\n");
What do you recommend?
Thank you!
Why are passing the address of the pointer?
memset(&pValid, 1, 10 * sizeof (short));
shouldn't you be passing the pointer value..
memset(pValid, 1, 10 * sizeof (short));
Thanks a lot :).
I've written a basic kernel in C, that'll pretty much just tell me that the kernel has been started. And I think I got the right Assembly code for booting/implementing this kernel as well.
Otherwise, I'm sure I'll return to these forums for more great advice ;).
I just need to know: Where can I find gcc.exe and ld.exe, as I can't find neither of them on Google, and I've also installed CygWin. But I can't find gcc.exe nor ld.exe in CygWins bin folder. So could someone please help me on that as well?
I find it really hard to believe that you wrote a kernel in C, yet your here trying to get a simple boot image going and your looking for - gcc.exe and ld.exe...etc
Are you talking about a variable length argument list? If you are then google "C variable length argument list".
Thanks. I have a few questions:
1) If I were to program, a small and simple 16-bit OS, would the boot loader then start the kernel?
2) Could I write this kernel in C, and then implement it into the boot loader, so that the boot loader would start the execution of the kernel?
For question like these I like to reference the Intel/AMD reference manuals...
http://www.amd.com/us-en/Processors/DevelopWithAMD/0,,30_2252_739_7044,00.html
http://www.intel.com/products/processor/manuals/
Like I said a lot of knowledge to get a little done...I would check the sections on "Processor Initialization and Long Mode Activation". Maybe someone here has a better answer.
I'm not sure... but I suppose it's because it'll try to move undeclared bytes into si otherwise.
Writing code at this level requires a lot of knowledge to get a little done. Try reading this for starters
Woohooo :). I figured it out. It was because I forgot to initialize the offset of my data register.
This is the code that did the job:[bits 16] [org 0x7c00] booter: mov ax, 0x0000 mov ds, ax mov si, message call output jmp $ output: mov ah, 0x0e mov al, [si] cmp al, 0 jz hang mov bh, 0x00 mov bl, 0x07 int 0x10 inc si jmp output hang: ret booter message db "Hello, world!", 0 times 510 - ($ -$$) db 0 dw 0xaa55
I'm not quite sure if this was what sysop_fb wanted me to do. If it was, then sorry. I thought you meant, declare a data segment like this:
[section .data]
So if that was the case, sorry for my ignorance :P.
Yes that's all good...but do you know why you had to place the data at the end of your code?
>Its urgent
For future reference, stating that your problem is urgent will likely be counterproductive. A lot of us are perverse enough to ignore you solely because you're in a rush.
Sad but true...
I have two libraries with two different queue implementations. but with same structure name as "queuetype".
Question - are the structures queuetype the same in both files(besides the name)?
It would probably help if you disclosed which Windows and what error..
Is there a question hidden in your posting?
Thanks. I'll post an objdump when I get home from school. I just have
one litte question about objdumping. To objdump this file would I just
type: "objdump -Dslx bootloader.bin"?
With GCC utilities use
objdump -D assembler>testfile
the file testfile now contains your assembler code..
By stop do you mean the program exits?
You really should try running your code with a debugger...
If you not comfortable running a debugger then place a printf right after the scanf
and check the value of max
printf("Enter an integer between 2 and 50,000: ");
scanf("%ld", &max);
printf(check value of max);
why do you define your int like this
long int &max;
with the "&"...
Don't you mean
long int max;
I figured my stupid silly mistake. children[i+degree] is not a pointer. What punishment do you suggest to give johndoe for such a moronic act?
How about getting you to post this in the C++ section
Note: I used g++ to compile this. How to change things to compile without error for g++?
Can you post an objdump of the code? I want to see how Nasm is addressing
message db "Hello, world!", 0
If you can't provide an objdump of the code then try moving message db "Hello, world!", 0 to the end of your code....Initially your instruction pointer may be trying to execute
message db "Hello, world!", 0
This is a guess since I'm not sure how Nasm handles memory for 16 bit code...
Why can't you send integers with write....
int myint = 1234;
write(fd, (char*)&myint, sizeof(int));
How do I convert it into a Qemu boot image?
If you compiled it correctly then it should be ready to go...I used gcc/Gas, a linker script and a hexeditor/objdump to compile and then strip my bootimage but with Nasm the functionality should be wrapped up in the compile/link lines.
I would check the Nasm docs to make sure your compiling/linking correctly and then download/install qemu. After you accomplished that open a console window go to your working directory(the one with your boot file) and type qemu bootimage..
Note I'm assuming you called your boot file bootimage...
Is this me or does this look like C++
list<item_set> candidate_set;
Your original C code uses cout?
Download/install qemu and then use it like
qemu bootimage
Can't believe this went without any comments...a real testimony to all the Linux user..
Do you mean calling a function or defining a function.
I would check out this link
http://en.wikipedia.org/wiki/C_preprocessor
especially the section 'Conditional compilation'