Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Seg fault with hla 1.99 on Fedora 8 linux
Hi

I'm just starting out trying to learn assembler, using HLA and the
"Art of Assembler".  I am having problems executing very simple demo
programs.

A hello world program works, however as soon as I introduce a
variable, I get a segfault.  I have given a working and broken example
below.

Apologies if I have done something stupid(!) , but any help would be
appreciated.  Please let me know if you need anymore information to
help...

Kind Regards
David

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ uname -a
Linux beechwood.home 2.6.23.15-137.fc8 #1 SMP Sun Feb 10 17:48:34 EST
2008 i686 i686 i386 GNU/Linux

====WORKING=====

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ more HelloWorld.hla
program helloWorld;
#include( "stdlib.hhf" );

begin helloWorld;

stdout.put( "Hello, World of Assembly Language", nl );

end helloWorld;
[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ hla -v HelloWorld.hla
HLA (High Level Assembler)
Use '-license' to see licensing information.
Version Version 1.99 build 12923 (prototype)
ELF output
OBJ output using internal FASM back-end
-test active

HLA Lib Path:     /home/david/local/hla/hlalib/hlalib.a
HLA include path: /home/david/local/hla/include
HLA temp path:
Files:
1: HelloWorld.hla

Compiling 'HelloWorld.hla' to 'HelloWorld.o'
using command line:
[hlaparse -level=high  -v -sf -celf -test "HelloWorld.hla"]

----------------------
HLA (High Level Assembler) Parser
use '-license' to view license information
Version Version 1.99 build 12923 (prototype)
-t active
File: HelloWorld.hla
Output Path: ""
Language Level: high

Compiling "HelloWorld.hla" to "HelloWorld.o"
Compilation complete, 14837 lines,   0.214 seconds,   69332 lines/
second
Using flat assembler version C1.66
3 passes, 1499 bytes.
----------------------
Linking via [ld    -o "HelloWorld"  "HelloWorld.o" "/home/david/local/
hla/hlalib/hlalib.a"]
[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorld
Hello, World of Assembly Language

====BROKEN=====

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ more
HelloWorldWithVar.hla
program helloWorld;
#include( "stdlib.hhf" );

static
InitDemo:       int32 := 5;

begin helloWorld;

stdout.put( "Hello, World of Assembly Language", nl );
stdout.put( "InitDemo's value is ", InitDemo, nl );

end helloWorld;
[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ hla -v
HelloWorldWithVar.hla
HLA (High Level Assembler)
Use '-license' to see licensing information.
Version Version 1.99 build 12923 (prototype)
ELF output
OBJ output using internal FASM back-end
-test active

HLA Lib Path:     /home/david/local/hla/hlalib/hlalib.a
HLA include path: /home/david/local/hla/include
HLA temp path:
Files:
1: HelloWorldWithVar.hla

Compiling 'HelloWorldWithVar.hla' to 'HelloWorldWithVar.o'
using command line:
[hlaparse -level=high  -v -sf -celf -test "HelloWorldWithVar.hla"]

----------------------
HLA (High Level Assembler) Parser
use '-license' to view license information
Version Version 1.99 build 12923 (prototype)
-t active
File: HelloWorldWithVar.hla
Output Path: ""
Language Level: high

Compiling "HelloWorldWithVar.hla" to "HelloWorldWithVar.o"
Compilation complete, 15683 lines,   0.223 seconds,   70327 lines/
second
Using flat assembler version C1.66
3 passes, 1644 bytes.
----------------------
Linking via [ld    -o "HelloWorldWithVar"  "HelloWorldWithVar.o" "/
home/david/local/hla/hlalib/hlalib.a"]
[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorldWithVar
Hello, World of Assembly Language
InitDemo's value is Segmentation fault


Report this thread to moderator Post Follow-up to this message
Old Post
DaveR
02-25-08 11:59 PM


Re: Seg fault with hla 1.99 on Fedora 8 linux
On Feb 25, 4:18 pm, DaveR  <spamt...@crayne.org> wrote:
> Hi
>
> I'm just starting out trying to learn assembler, using HLA and the
> "Art of Assembler".  I am having problems executing very simple demo
> programs.
>
> A hello world program works, however as soon as I introduce a
> variable, I get a segfault.  I have given a working and broken example
> below.
>
> Apologies if I have done something stupid(!) , but any help would be
> appreciated.  Please let me know if you need anymore information to
> help...
>
> Kind Regards
> David
>
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ uname -a
> Linux beechwood.home 2.6.23.15-137.fc8 #1 SMP Sun Feb 10 17:48:34 EST
> 2008 i686 i686 i386 GNU/Linux
>
> ====WORKING=====
>
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ more HelloWorld.hla
> program helloWorld;
> #include( "stdlib.hhf" );
>
> begin helloWorld;
>
>     stdout.put( "Hello, World of Assembly Language", nl );
>
> end helloWorld;
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ hla -v HelloWorld.hla
> HLA (High Level Assembler)
> Use '-license' to see licensing information.
> Version Version 1.99 build 12923 (prototype)
> ELF output
> OBJ output using internal FASM back-end
> -test active
>
> HLA Lib Path:     /home/david/local/hla/hlalib/hlalib.a
> HLA include path: /home/david/local/hla/include
> HLA temp path:
> Files:
> 1: HelloWorld.hla
>
> Compiling 'HelloWorld.hla' to 'HelloWorld.o'
> using command line:
> [hlaparse -level=high  -v -sf -celf -test "HelloWorld.hla"]
>
> ----------------------
> HLA (High Level Assembler) Parser
> use '-license' to view license information
> Version Version 1.99 build 12923 (prototype)
> -t active
> File: HelloWorld.hla
> Output Path: ""
> Language Level: high
>
> Compiling "HelloWorld.hla" to "HelloWorld.o"
> Compilation complete, 14837 lines,   0.214 seconds,   69332 lines/
> second
> Using flat assembler version C1.66
> 3 passes, 1499 bytes.
> ----------------------
> Linking via [ld    -o "HelloWorld"  "HelloWorld.o" "/home/david/local/
> hla/hlalib/hlalib.a"]
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorld
> Hello, World of Assembly Language
>
> ====BROKEN=====
>
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ more
> HelloWorldWithVar.hla
> program helloWorld;
> #include( "stdlib.hhf" );
>
> static
>     InitDemo:       int32 := 5;
>
> begin helloWorld;
>
>     stdout.put( "Hello, World of Assembly Language", nl );
>     stdout.put( "InitDemo's value is ", InitDemo, nl );
>
> end helloWorld;
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ hla -v
> HelloWorldWithVar.hla
> HLA (High Level Assembler)
> Use '-license' to see licensing information.
> Version Version 1.99 build 12923 (prototype)
> ELF output
> OBJ output using internal FASM back-end
> -test active
>
> HLA Lib Path:     /home/david/local/hla/hlalib/hlalib.a
> HLA include path: /home/david/local/hla/include
> HLA temp path:
> Files:
> 1: HelloWorldWithVar.hla
>
> Compiling 'HelloWorldWithVar.hla' to 'HelloWorldWithVar.o'
> using command line:
> [hlaparse -level=high  -v -sf -celf -test "HelloWorldWithVar.hla"]
>
> ----------------------
> HLA (High Level Assembler) Parser
> use '-license' to view license information
> Version Version 1.99 build 12923 (prototype)
> -t active
> File: HelloWorldWithVar.hla
> Output Path: ""
> Language Level: high
>
> Compiling "HelloWorldWithVar.hla" to "HelloWorldWithVar.o"
> Compilation complete, 15683 lines,   0.223 seconds,   70327 lines/
> second
> Using flat assembler version C1.66
> 3 passes, 1644 bytes.
> ----------------------
> Linking via [ld    -o "HelloWorldWithVar"  "HelloWorldWithVar.o" "/
> home/david/local/hla/hlalib/hlalib.a"]
> [david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorldWithVar
> Hello, World of Assembly Language
> InitDemo's value is Segmentation fault


Just tried it with v1.97 and it worked without producing a seg-fault.
So this is a bug that was introduced sometime between then and v1.99!

Nathan.


Report this thread to moderator Post Follow-up to this message
Old Post
nbaker2328
02-25-08 11:59 PM


Re: Seg fault with hla 1.99 on Fedora 8 linux
Thanks for that - is there a link to v1.97 , so that I can download it
and try it on my machine?

I look for historical versions on http://webster.cs.ucr.edu and
couldn't find any...

Regards
David


Report this thread to moderator Post Follow-up to this message
Old Post
DaveR
02-25-08 11:59 PM


Re: Seg fault with hla 1.99 on Fedora 8 linux
DaveR wrote:

...
> Version Version 1.99 build 12923 (prototype)

This is really weird! I just now unloaded 1.99... and it's showing build
12922!

This works fine with your test program! So what's build 12923??? You
showing that build, Nathan?

You might try downloading/installing 1.99 again, or I've stuck 1.97 here:

http://mysite.verizon.net/fbkotler/hla-1.97.tar.gz

Grab it quick, it won't be there long.

(I suggest adding version numbers to the filenames you download from
Webster - for exactly this situation! :)

Good hLuck,
Frank


Report this thread to moderator Post Follow-up to this message
Old Post
Frank Kotler
02-26-08 02:59 AM


Re: Seg fault with hla 1.99 on Fedora 8 linux
On Feb 25, 6:11 pm, DaveR  <spamt...@crayne.org> wrote:
> Thanks for that - is there a link to v1.97 , so that I can download it
> and try it on my machine?
>
> I look for historical versions onhttp://webster.cs.ucr.eduand
> couldn't find any...
>

You can typically locate historical versions by editing the number in
the URL:

http://webster.cs.ucr.edu/AsmTools/...la.linux.tar.gz

Nathan.


Report this thread to moderator Post Follow-up to this message
Old Post
nbaker2328
02-26-08 02:59 AM


Re: Seg fault with hla 1.99 on Fedora 8 linux
On Feb 25, 8:06 pm, Frank Kotler  <spamt...@crayne.org> wrote:
> DaveR wrote:
>
> ...
> 
>
> This is really weird! I just now unloaded 1.99... and it's showing build
> 12922!
>

Based on experience, this *probably* means that he actually has 1.100
(which is "reporting" to be 1.99) and this means that the StdLib
version is 3.x and so the bug is likely in the library.  If so, we've
got a Bug Tracker:  http://hla-stdlib.sourceforge.net/

Nathan.


Report this thread to moderator Post Follow-up to this message
Old Post
nbaker2328
02-26-08 02:59 AM


Re: Seg fault with hla 1.99 on Fedora 8 linux
Hi

Thanks for all the help so far.  I downloaded v1.97, and got a
slightly different effect:

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorldWithVar
Segmentation fault (core dumped)

Whereas with 1.99 I had:

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./"HelloWorldWithVar"
Hello, World of Assembly Language
InitDemo's value is Segmentation fault (core dumped)



Is there anything else I can do to give you more information?  I got a
core dump and loaded it into gdb. It didn't have much of a stack
trace , but here it is anyway:

For v1.97:

This GDB was configured as "i386-redhat-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".

warning: core file may not match specified executable file.
(no debugging symbols found)
Core was generated by `./HelloWorldWithVar'.
Program terminated with signal 11, Segmentation fault.
#0  0x080481d5 in BuildExcepts__hla_ ()

For v1.99:

This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".

warning: core file may not match specified executable file.
Core was generated by `./HelloWorldWithVar'.
Program terminated with signal 11, Segmentation fault.
#0  0x0804a02d in ?? ()

Kind Regards
David


Report this thread to moderator Post Follow-up to this message
Old Post
DaveR
02-26-08 11:59 PM


Re: Seg fault with hla 1.99 on Fedora 8 linux
On Feb 26, 4:36 am, DaveR  <spamt...@crayne.org> wrote:
> Hi
>
> Thanks for all the help so far.  I downloaded v1.97, and got a
> slightly different effect:
>

Okay, Dave.  It appears that HLA does not wear a Red Hat.  I am pretty
confident that NASM does, so you might give it a try:

http://nasm.sourceforge.net/

Nathan.
http://del.icio.us/Evenbit/


Report this thread to moderator Post Follow-up to this message
Old Post
nbaker2328
02-27-08 02:59 AM


Re: Seg fault with hla 1.99 on Fedora 8 linux
nbaker2328 wrote:
> On Feb 26, 4:36 am, DaveR  <spamt...@crayne.org> wrote:
> 

(the copy of 1.97 on my site is gone, BTW)

(You didn't, by any chance, overwrite /usr/hla/hlalib/hlalib.a with a
later version? That won't work!)

> Okay, Dave.  It appears that HLA does not wear a Red Hat.  I am pretty
> confident that NASM does, so you might give it a try:
>
> http://nasm.sourceforge.net/

If Nasm had a fan club, I'd be president (maybe "maximum leader", even),
so I won't argue with that suggestion. However... Nasm isn't going to
correspond well with AoA, which is what David would like to do...

If we're content to say "HLA doesn't wear a Red Hat", okay, but *I'd*
like to know *why*! Red Hat got a different instruction set??? I don't
think so!

Is fc 8 a 64-bit system? That would imply a different (G)as (not
relevant with this version of HLA?) and ld. I think ld complains loudly
in this case, and wouldn't link hw-without-int, either, but... The cure
for that, if we encounter it, is to add "-m elf_i386" to ld's command
line. I think HLA will do this... "-l" switch? (someone - not me - RTFM)

I don't think that's what's happening here. Why should HLA 1.97 produce
code that apparently segfaults at a different point than 1.99? The
"internal workings" of HLA differ, to be sure, but they should produce
*identical* code for "print a string, print an integer", I would think.
Possible change in the library code, of course, but I think version 1 of
the library's pretty stable at this point. Easy to check... I don't have
source for either of these versions installed right now... can look if
need be.

David has revealed himself as someone who knows what to do with a core
dump - something I have yet to learn (any tips?). My technique would be
to simply run it in gdb or ald or asmbug and see *where* the segfault
happened. Then I'd probably disassemble the executable with ndisasm to
see what HLA (and ld) really did... There are better ways, I'm sure...

Unless I'm mistaken, HLA using Gas as a back end put debugging symbols
in the executable(?), but HLA with "built-in Fasm" doesn't(?). If this
is so, perhaps we can ask HLA to output Gas code, and assemble and link
it "by hand". Might get more info out of gdb(?).

Since David's the one who's seeing the segfault, he's going to have to
help track it down. Not what I'd consider a "newbie exercise"! (but I
don't know how to read core dumps, so who's the "newbie"?) If you want
to mail me the failing executable(s) - fbkotler at verizon.net - I'll
look and see if I can see anything... No guarantees, of course.

I think I'm going to cc this to the !Yahoo! list, since Randy seems
(wisely, perhaps) to be giving usenet a rest. HLA is really "not my
bag", but I hate to see this left as "well, HLA doesn't work on Red
Hat". That's *really* not supposed to be the case!

Best,
Frank

(I can provide Nasm "print a string, print an int" examples that
"should" work on fc 8 - if it's 64-bit, Chuck can help... if you pefer
to go that route, but it ain't going to match AoA!)


Report this thread to moderator Post Follow-up to this message
Old Post
Frank Kotler
02-27-08 11:58 PM


Re: Seg fault with hla 1.99 on Fedora 8 linux
Ok - thanks for the help guys! - I'll do my best.  As you say, whilst
I'm happy to give NASM a go ( once I know a bit of assembler ) it
would be nice to get HLA working on my linux box, as it would make
following the book a lot easier ( BTW - I'm finding the book really
good and well layed out - only having done high level languages
before, this is all very enlightening... :-> )

Ok - now for the info that you wanted:

First - yes my install of FC8 is 32 bit.
Second - install paths.  I have the following setup

HLA 1.99 installed in /home/david/local/hla1.99
HLA 1.97 installed in /home/david/local/hla1.97
A symlink from /home/david/local/hla -> hla1.9X (depending on which
version I'm testing)

and the following env vars set:
[david@beechwood:~/local ] $ env | grep hla
hlalib=/home/david/local/hla/hlalib/hlalib.a
hlainc=/home/david/local/hla/include
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/david/local/
hla:/home/david/bin

Third - core dumps - I have done a little bit of C programming so have
some experience of gdb and examining core dumps, however , I'm not
really sure how this translates to assembler...

...  Having just written the out the above, whilst trying to get some
more info I have now found a way to make it work , by switching the
assemblers

With internal FASM:

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ hla -xo
HelloWorldWithVar.hla
[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorldWithVar
Hello, World of Assembly Language
InitDemo's value is Segmentation fault (core dumped)


With Gas:

[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ hla -xg
HelloWorldWithVar.hla
[david@beechwood:~/local/AoA/Volume1/Ch02 ] $ ./HelloWorldWithVar
Hello, World of Assembly Language
InitDemo's value is 5


Any thoughts on why this might be ( although now I can get on with
trying the examples :-> ... )?


Many thanks for all your help and advice!
Regards
David


Report this thread to moderator Post Follow-up to this message
Old Post
DaveR
02-28-08 03:01 AM


Sponsored Links




Last Thread Next Thread Next
Pages (3): [1] 2 3 »
Search this forum -> 
Post New Thread

A86 Assembler archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:31 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.