Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
Draal
Gerbil First Class
Topic Author
Posts: 179
Joined: Sat Apr 05, 2003 3:04 pm

Beginner Code Question

Sun Feb 29, 2004 5:07 am

Hey,

I've been messing around with Borland C++ but for the most part lost interest.

Now I've started to look at assembly (yes I know that it is the most complicated/pointless/lowlest language) and was wondering if you guys knew a decent program that I could run it through?

Excuse me for being ignorant but it is one of the questions everyones asks but you can never find an answer to.

Program suggestions would be appreciated.

Thank you,

Draal
 
UberGerbil
Grand Admiral Gerbil
Posts: 10368
Joined: Thu Jun 19, 2003 3:11 pm

Sun Feb 29, 2004 5:32 am

Well, it's good to learn a little about assembly to better understand what's really going on -- it's a bit like learning some Latin to better understand where some of our spoken language comes from -- but unless you're writing compilers or device drivers there's not much call to use it anymore.

I'm not sure what you're asking -- are you looking for an assembler or development environment? In the old (pre-GUI) days we used masm, and you can still do command line assembly, but most C++ compilers have a provision for "inline" assembly, where you write a regular function body but then "drop into" assembler within it. If you still have your Borland C++ compiler you should be able to use that. Nice thing about that is that it saves you from a lot of tedious setup and teardown code to run a few assembly instructions within Windows.

Alternatively, if putting together an all-up command line asm program is what you want, there are various linux/gnu tools for pure assembly (and the C compilers generally allow for inline as well).

Or are you looking for sample code?
 
Draal
Gerbil First Class
Topic Author
Posts: 179
Joined: Sat Apr 05, 2003 3:04 pm

Sun Feb 29, 2004 2:27 pm

What happened is that I'm still new to the whole programming scene in general. I'm one of the schmucks who got an outdated version of Borland with a big hefty manual that would tell me how to do everything and need and decided to was a good thing to try.

A few months expierence but I'm still looking to see where up and down is for the whole thing.

I was looking for an all command line asm program. Looked for a bit but any links would be appreciated. A site for sample C++ and Assembler code (where has the scene gone to as of late?) would be appreciated as well.

What happens when you arn't exposed to anything but QBasic for a long number of years..

Thanks man,

Draal

PS Aside from Borland, are there any free/open alternatives to thier program/compiler? Like I said, I'm using an outdated version of the program and would like to move onto something else.
 
UberGerbil
Grand Admiral Gerbil
Posts: 10368
Joined: Thu Jun 19, 2003 3:11 pm

Sun Feb 29, 2004 5:33 pm

I haven't had any call to use ASM lately, and the last few times I did it was inline. So it's been a LOOONG time since I used MASM or any true assembler. It looks like this is a good page to start
http://webster.cs.ucr.edu/
MASM is very long in the tooth now but most books you're going to find probably refer to it. And there are sample files out there for it as well. I'm not familiar with the others.

Much to my surprise, it appears Microsoft makes MASM available for free these days. More here: http://webster.cs.ucr.edu/AsmTools/MASM/index.html

Jumping from QBasic to assembly can be done, but it takes some mental stretching. Plain old C (not C++) is in many ways not much more than structured assembly language in an architecture-independent wrapper. When you're done with assembly, that might be your next stop (or jump all the way to a less-hybridized object-oriented language than C++, like Java or C# or Smalltalk).
 
alimansoorahmad
Gerbil
Posts: 34
Joined: Fri Feb 06, 2004 2:46 am

Sun Feb 29, 2004 11:56 pm

.model tiny
.code
org 100h
start:
push cs
pop ds

push 0b800h
pop es

xor bx,bx
xor dx,dx
mov cx,80
step1:
mov ax,es:[bx]
push ax
add bx,2
loop step1
sub bx,160
mov cx,80
step2:
pop ax
mov es:[bx],ax
add bx,2
loop step2

mov cx, 80
inc dx
cmp dx,25
jne step1

mov ax,4c00h
int 21h
end start

i have used borlandc 3.1 which is a good compiler to learn assembly for beginers. this compiler contains TASM (assemblers), seems that ur using the same.
what i think is, u need Nortan Guid (NG).
any how the code is a working code run it in tasm, but think it must also work with masm.
this will invert dos screen.
i assume that u know how to run the asm code using cammand prompt.
knowledge has no limits so always be a student.
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Mon Mar 01, 2004 6:56 am

Dunno much ASM, but i know that the file which is assembled into is simply an exe file.

On the other hand, if you want to run pure asm code, type "debug" in the command prompt and play with it from there. "debug" is the built in ASM assembler which comes with windows.
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Mon Mar 01, 2004 7:54 am

For general programming C/C++ or Java are your best bets; for scripting, Perl or Python are the way to go.

Assembler is one of those things that I think everyone should try at some point, but which is not particularly useful today unless you want to make a living porting embedded OS kernels to proprietary hardware platforms.

There's a decent freeware (Open Source) x86 assembler available here:
http://sourceforge.net/projects/nasm
Nostalgia isn't what it used to be.
 
alimansoorahmad
Gerbil
Posts: 34
Joined: Fri Feb 06, 2004 2:46 am

Mon Mar 01, 2004 9:22 am

Although I have mailed the code, but jbi is right.
Even if you learn assembly, u will have to learn C (at least) for more interesting applications.
I am not saying that assembly is not an independent language but it becomes very easy to create a big & interesting program using the combination of C and assembly.
So I recommend u to learn structured C ++ first than go for object oriented concepts and after that u can jump to learn other tools like VC++ (win console and MFC).
Once u learned Object Oriented C++ then java will not be much difficult to learn.
u can use to read "C++ How To Program" third edition by Deitel & Deitel or "C++ from the Ground Up" by Herber Schildt but "Ground Up" takes u from the very begining.
knowledge has no limits so always be a student.
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Thu Mar 04, 2004 9:46 am

Another good assembler is MASM32
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
yarbo
Gerbil Elite
Posts: 687
Joined: Thu Jun 13, 2002 11:16 pm
Location: Southern California
Contact:

Sat Mar 20, 2004 12:37 am

if you want a free/open compiler, check out the GNU compiler collection
http://gcc.gnu.org/
<a href=http://www.gentoo.org>Gentoo GNU/Linux</a>
 
liquidsquid
Minister of Gerbil Affairs
Posts: 2661
Joined: Wed May 29, 2002 10:49 am
Location: New York
Contact:

Sat Mar 20, 2004 9:28 am

Don't forget that assembly is still very much in use in embedded controllers and small microcontrollers. Yes you can do the same with C, but when you have 1K of code space, assembly lets you optimize as you write.

Many of my projects at http://www.ramseyelectronics.com are written in assembly. However the COM3010 is not, it was in C since it was so complex.

You may find if you are interested in programming that playing with small microcontrollers may be of great interest. Check out PIC chips and Motorola's microcontrollers. I prefer Mot, but you have to make an investment with the hardware target thought he software is free. My company sells a really inexpensive PIC development set that may be what you are looking for. You can't get much less expensive.

-LS
Last edited by liquidsquid on Mon Mar 22, 2004 8:44 am, edited 1 time in total.
 
fc34
Minister of Gerbil Affairs
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Sun Mar 21, 2004 9:40 pm

liquidsquid wrote:
Don't forget that assembly is still very much in use in embedded controllers and small microcontrollers. Yes you can do the same with C, but when you have 1K of code space, assembly lets you optimize as you write.


We're working with GBs of space and you are worried about having 1k of space?
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
 
liquidsquid
Minister of Gerbil Affairs
Posts: 2661
Joined: Wed May 29, 2002 10:49 am
Location: New York
Contact:

Mon Mar 22, 2004 8:48 am

Yeah, 1K programming space is actually a lot of fun to work with! It is a challange to optimize enough to squeeze things in sometimes, though usually scanning four buttons and acting on them does not take even that much space... However the blinkeye kit I wrote the code for (really neat by the way) had to require a 3K table because of the size of the tables needed to store the scripts.

I wince every time I write a VB utility and try to distribute it. Just a few simple tasks can amount to a 2M download. Good 'ol MS... VB should be a really lightweight output, but with thier DLL entanglement you are stuck having to distribute piles of crap.

-LS
 
SecretSquirrel
Minister of Gerbil Affairs
Posts: 2726
Joined: Tue Jan 01, 2002 7:00 pm
Location: North DFW suburb...
Contact:

Mon Mar 22, 2004 7:09 pm

In todays world of desktops with gigabytes of RAM and gigaHertz of CPU speed it is easy to forget just how dependent the world is on tiny embeded systems. How much memory do you thing is in the remote that unlocks your car, or open your garage door? How about the computer that makes your car run.

One of my biggest complaints about up and coming programmers these days is that very few have any idea how a computer actually works. There are many layers of abstraction between a programmer and the hardware the code will finally run on. Don't get me wrong, this isn't completely a bad thing. It makes it much easier to write useful programs and get stuff done. Unfortunately, it also makes it much easier to write lousy code. Why do I need a gigahertz CPU and hunders of megabytes of RAM just to run the web browser I'm using to write this response? Because hardware is cheap and cheap hardware allows for sloppy code.

It doesn't matter what programming language you begin with. I started with GWBASIC because that's really all I had available at the time. I would suggest starting with a structured fairly language (C, C++, Java, etc). I would also suggest you start with command line programs. Not because GUIs are bad, just complex. Somewhere along the way, my recommendation to every programmer would be to pick up an old book on x86 assembler and study it. Write a program that turns the screen upside down (text mode isn't hard) or something like that. You don't have to become an expert, just grasp the basic concepts.

That's just my two cents. And for those that may be curious, here is my progression of programming languages: GWBasic, QuickBasic, Intel Assembler, C, C++, VisualBasic, Perl.

--SS
 
SecretSquirrel
Minister of Gerbil Affairs
Posts: 2726
Joined: Tue Jan 01, 2002 7:00 pm
Location: North DFW suburb...
Contact:

Re: Beginner Code Question

Mon Mar 22, 2004 7:23 pm

Draal wrote:
Hey,

I've been messing around with Borland C++ but for the most part lost interest.

Now I've started to look at assembly (yes I know that it is the most complicated/pointless/lowlest language) and was wondering if you guys knew a decent program that I could run it through?

Excuse me for being ignorant but it is one of the questions everyones asks but you can never find an answer to.

Program suggestions would be appreciated.

Thank you,

Draal


I don't have a program for you, but I do have a book suggestion: "Assembly Language Programming for the IBM PCAT". ISBN 0-89303-484-3 I'm sure it is long out of print, but if you can find a copy, it will give much insight into assembly programming on the x86 architecture. One thing to remember, with assembly more so than with any other language, example programs only help so much. To really be able to do much you have to understand the underlying concepts. Unfortunately with assembly this means you have to understand the processor internals: registers, addressing modes, etc.

Actually, I went digging and I do have a program for you. You can browse it here: http://www.supersecret.org/code/SPLITTER.ASM

That was written very long ago by yours truely and is probably pretty lousy code, but it does (or did) work.

--SS

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On