LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-16-2014, 05:58 PM   #181
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241

I finally got the translator handling arrays - and did some code clean up too.

Now to do some documentation before I forget it (need test cases for validation), and start looking at changes for the vm.
 
1 members found this post helpful.
Old 01-21-2014, 03:47 PM   #182
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
About a week and a half ago I found out about gdb. I had always used printf to debug but I was getting segmentation faults and I asked on linux questions how to read a dump and they suggested gdb. Now I have found out about ddd but I do not know how to specify arguments. I can do it with command line version gdb by saying gdb --args apsbasic pt01.bas for argv[0] being the routine called and argv[1] being the basic program to interpret which is pt01.bas . Any ideas as to how to specify arguments with ddd? Thanks. Alvin...
 
Old 01-21-2014, 05:06 PM   #183
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
I've used gdb for the most part (actually like you, I like printf), but used gdb to look at stack traces.

Since ddd (from http://www.gnu.org/software/ddd/manu..._mono/ddd.html) is a front end to gdb, I expect it to be pretty much the same- there appears to be a menu entry to start the program running, which is supposed to put up a window for entering parameters. (look for "Program => Run", so Run should be a menu entry on the "Program" menu.

It does look like an interesting front end.
 
Old 01-21-2014, 08:28 PM   #184
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Googling ddd leads to their website where you can get a 230+ page manual with pictures - some of the pictures are destroyed but I have copied it to dvd and plan to get it printed out (using both sides of the paper) tomorrow. Kinkos will do spiral binding which will lay flat when opened. doing gdb in command line and then help all leads to an almost infinite list of commands. had to apt-get the ddd package as it did not come with ubuntu. It also does java which I hope to write the PC side ide in. I have never written a java program (wrote a small print to screen routine but that is it. ) Using java so it will work on WIN UNX and MAC. Wrote an abstract machine using the context sensitive STAGE II macro processor in 1985 so I am pro java for the portability aspect.
 
Old 01-22-2014, 08:46 AM   #185
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Thats the advantage of basing the development on a stack based virtual machine.

The downside is the speed. The way the JVM accomplishes/overcomes that is to put everything and the kitchen sink in the JVM (in my opinion). Doing that is also error prone.
 
Old 01-25-2014, 01:09 PM   #186
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
You might enjoy this. It is a BBC doc on toy gliders. http://www.flightrc.info/index.php?p...mart&Itemid=55
 
Old 01-26-2014, 12:38 AM   #187
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
That was a really good show. And a nice glider too.
 
Old 01-26-2014, 11:19 PM   #188
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Glad you liked it.
 
Old 01-31-2014, 07:42 AM   #189
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
So how is it going? You are a better programmer than I from what progress I see you are making. I am still trying to get my first command working as I wrote all the code before testing. Just made some debugging routines last night to display function name and line number with the errors generated by the program for user entered code. I am a believer in God and Jesus as he has always given me just the right things in my life to aid me in doing my job - like my meeting you and all the great help you have given me. Recently I have been living on $806 a month of SS and a small annuity plus meager savings and running over my budget each month. Stupidly I turned to the lottery to see if that would work. About 4 weeks ago I quit thinking that I was not pleasing God with it. Then a week and a half after I quit I found out that I had almost $14,000.00 of dividends built up in a $10,000.00 insurance policy (53 years worth). God provided for me again! I hope you are doing well in all of this. Your stack machine sounds like the right approach to portability of User code to many different types of machines. Do you plan to use a specific micro processor to implement it on?
 
Old 01-31-2014, 10:34 AM   #190
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
I finally realized how I can get the source code line included in the annotation - and added that. The generated assembly code listing now looks like:
Code:
	                         # assembler code generated from test.code
	                         
		                 .data
	                         
	0000:                    value:	.block	2		# [  1] short	value;
	0002:                    char:	.block	1		# [  2] byte	char;
	0003:                    str:	.block	20		# [  3] byte	str[20];
	0017:                    fvalue:	.block	4		# [  4] float	fvalue;
	                         
		                 .code
	                         
	0000:                    main:				# [  6] int function main (int c, byte str2[20])
	0000: 82 FB FF           	PUSHX	-5[2]		# [  8]     value = c;
	0003: 09 00 00           	POP2	value
	0006: 03 00 00           	PUSH2	value		# [  9]     fvalue = value;
	0009: 22                 	CVTIF
	000A: 0A 17 00           	POP4	fvalue
	000D: 05 05              	PUSHI	5		# [ 10]     fvalue = 5 * 3 + 2;
	000F: 05 03              	PUSHI	3
	0011: 1E                 	MUL
	0012: 05 02              	PUSHI	2
	0014: 1C                 	ADD
	0015: 22                 	CVTIF
	0016: 0A 17 00           	POP4	fvalue
	0019: 82 FB FF           	PUSHX	-5[2]		# [ 11]     if c then
	001C: 1A                 	ADJ	
	001D: 40 2F 00           	JMPEQ	$1
	0020: 05 03              	PUSHI	3		# [ 12] 	fvalue = 3 + 2.0;
	0022: 22                 	CVTIF
	0023: 07 00 00 00 40     	PUSHI4	2.0
	0028: 35                 	ADDF
	0029: 0A 17 00           	POP4	fvalue
	002C: 48 35 00           	JMP	$2
	002F:                    $1:				# [ 13]     else
	002F: 05 03              	PUSHI	3		# [ 14] 	fvalue = 3;
	0031: 22                 	CVTIF
	0032: 0A 17 00           	POP4	fvalue
	0035:                    $2:
	0035:                    $3:				# [ 16]     while c;
	0035: 82 FB FF           	PUSHX	-5[2]
	0038: 1A                 	ADJ	
	0039: 40 48 00           	JMPEQ	$4
	003C: 82 FB FF           	PUSHX	-5[2]		# [ 17]       c = c - 1;
	003F: 05 01              	PUSHI	1
	0041: 1D                 	SUB
	0042: 8E FB FF           	POPX	-5[2]
	0045: 48 35 00           	JMP	$3
	0048:                    $4:
	0048: 05 03              	PUSHI	3		# [ 20] 	c = str2[3] + 1;
	004A: 82 FA FF           	PUSHX	-6[2]
	004D: 1C                 	ADD
	004E: 9D                 	POPR	1
	004F: 81 00 00           	PUSHX	0[1]
	0052: 05 01              	PUSHI	1
	0054: 1C                 	ADD
	0055: 8E FB FF           	POPX	-5[2]
	0058: 82 FB FF           	PUSHX	-5[2]		# [ 22]     str2[4]=c;
	005B: 05 04              	PUSHI	4
	005D: 82 FA FF           	PUSHX	-6[2]
	0060: 1C                 	ADD
	0061: 9D                 	POPR	1
	0062: 8D 00 00           	POPX	0[1]
	0065: 82 FB FF           	PUSHX	-5[2]		# [ 23]     return c;
	0068: 8E 00 00           	POPX	0[2]
	006B: 5B                 	RETURN	
	006C:                    test:				# [ 25] int function test (int a, int b, int c)
	006C: 82 F9 FF           	PUSHX	-7[2]		# [ 27]    if c then
	006F: 1A                 	ADJ	
	0070: 40 7C 00           	JMPEQ	$1
	0073: 82 FA FF           	PUSHX	-6[2]		# [ 28] 	a = b;
	0076: 8E FB FF           	POPX	-5[2]
	0079: 48 82 00           	JMP	$2
	007C:                    $1:				# [ 29]    else
	007C: 82 FB FF           	PUSHX	-5[2]		# [ 30] 	b = a;
	007F: 8E FA FF           	POPX	-6[2]
	0082:                    $2:
	0082: 82 FB FF           	PUSHX	-5[2]		# [ 32]    c = test(c,b,a);
	0085: 82 FA FF           	PUSHX	-6[2]
	0088: 82 F9 FF           	PUSHX	-7[2]
	008B: 5A 6C 00           	CALL	test
	008E: 1B FD              	ADJN	-3
	0090: 98                 	PUSHR	0
	0091: 8E F9 FF           	POPX	-7[2]
	0094: 5B                 	RETURN	


	Program allocation:  149 bytes.
	Memory allocation:   27 bytes.
	Total errors:        0.
This should make using it in a tutorial mode much easier to follow.

As a side note, this is how I first learned assembly - a PDP-10 FORTRAN compiler would output the generated assembly code following the line of Fortran in the listing. It made it easy to extend my understanding of FORTRAN expressions into how the machine could interpret what the formula was for.

Granted, the code is NOT optimal (no constant folding, no replacing POP/PUSH pair using the same variable reference with a "STORE...", there is no recursion elimination, or algebraic simplification - though with this simple test there wouldn't be any).

NOTE: this is not a valid program even now (it will cause a stack underflow when the "main" function terminates, as well as not being a valid program anyway). This is just for illustration/testing of the translator. The "missing" source lines (like the ENDIF...) are things
that don't generate any code (the parse tree just has a NULL reference), so they aren't present. I may be able to get them included - probably by using the line number to output any preceding lines not yet output and just copy them into the generated assembly. That way any comments would also get included.

Documentation is slow going though (as are the validation tests... I've got one, but it needs a lot more).

Last edited by jpollard; 01-31-2014 at 10:39 AM.
 
Old 01-31-2014, 11:23 PM   #191
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
That looks great! Would like to try your system on my 32 bit hardware when I get it going - or you could have one of my boards. I plan to have some sort of IDE to load programs into the computer and the PIC32 will have a built in boot loader to load from the IDE through USB to the PIC32.
 
Old 02-02-2014, 08:17 AM   #192
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
I found a few things I still need to add (forgot to generate code for relational expressions, but did for expressions...) Along with all the documentation...
 
Old 02-12-2014, 04:54 PM   #193
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
Finally making some progress debugging with gdb. Tried to find a book on gdb at the va tech librery but it was too simplistic. I asked a question on linuxquestions and a guy immediately shot me a url of the documentation. 727 pages. I unpacked it and put it on dvd but when I went to the printer he was closed due to the snow. At 0.07 a page it will cost $50.89 to print it out duplex. FEDEX here does spiral binding so it will lay flat. I like to read paper manuals. Now I can at least set breakpoints and display variables as well as step through the source code. So things should speed up from now on. What progress are you making?
 
Old 02-12-2014, 07:01 PM   #194
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Gumption issues... I need to concentrate better... sorry about that.

It would have seemed cheaper to print locally, then take it for binding.

It seems I'm going to be snowed in shortly, so hopefully I'll be able to actually do stuff again.

Last edited by jpollard; 02-12-2014 at 07:03 PM.
 
Old 02-14-2014, 08:28 AM   #195
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 308

Original Poster
Rep: Reputation: Disabled
The glibc Reference Manual in .pdf form can be found at: http://www.gnu.org/software/libc/manual/pdf/libc.pdf if you are interested. I may print that out and spiral bind that too. Some of our communications are general and may be more appropriate if sent by email. We have each others email; what do you think
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions nova49 Linux - Newbie 4 07-13-2011 08:05 AM
Regular Expressions Wim Sturkenboom Programming 10 11-19-2009 02:21 AM
regular expressions. stomach Linux - Software 1 02-10-2006 07:41 AM
Regular Expressions overbored Linux - Software 3 06-24-2004 03:34 PM
help with REGULAR EXPRESSIONS ner Linux - General 23 11-01-2003 12:09 AM


All times are GMT -5. The time now is 02:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration