Please asm newbie with few questions 
Author Message
 Please asm newbie with few questions


writes:

Quote:

>Hello to all you assembler gurus out there!

>I have just started learning assembler, and even with all the info I have
>(books, txt files, etc), there are a few questions which I have not been
>able to answer.

>1. When writing new code from scratch, why does it always start at an
>offset of 0100h ? What's in the gap between 0000h and 0100h ?

The examples you have seen must be for writing .COM programs. They start
at 100h because they are in the same segment with the PSP, which is 100h
(256) bytes long.

EXE programs can start at offset 0.

Quote:

>2. How does one do floating point arithmetic if one does not have a math
>coprocessor (on an 80286) for example?

In assembly, without a floating point co-processor, you must write all
the
code to do the floating point arithmetic. (Or get a library). Just to
do
a 32-bit floating point addition, might be several hundred
instructions.

Quote:
>3. How can one support the asm equivalent of C's long int etc???

On the 386 and above the registers are 32-bits. On the 286 and below,
you'll
have to use 2 registers. If you put one value in DX:AX (DX has high
word)
and the other in CX:BX you can add them like this:

  add ax, bx     ; do the equivalent of:    add dx:ax, cx:bx
  adc dx, cx

Subtraction is quite similar, but multiply and divide require writing a
loop
with a dozen or two instructions -- ideal for writing a library
routine.

Mike Schmit

-------------------------------------------------------------------

408-244-6826                    Pentium Processor Programming Tools
800-765-8086                    ISBN: 0-12-627230-1
-------------------------------------------------------------------



Sun, 28 Jun 1998 03:00:00 GMT  
 Please asm newbie with few questions

Quote:
>>3. How can one support the asm equivalent of C's long int etc???

>Long int is the size of eax, as is long unsigned

<snip>

If you don't have a 386+ (i believe you are running a 286), you have
to do multiple precession arithmetic.  You do the work 16 bits at a
time, using the carry (borrow) flag to propagate the carry (borrow)
from the LSW to the MSW.  Muls and Divs a a little harder, but
all you need to do is break them up into parts (just like grade
school long division and multiplication).

Good Luck

Jim Neil



Sun, 28 Jun 1998 03:00:00 GMT  
 Please asm newbie with few questions
Hello to all you assembler gurus out there!

I have just started learning assembler, and even with all the info I have
(books, txt files, etc), there are a few questions which I have not been
able to answer.

1. When writing new code from scratch, why does it always start at an
offset of 0100h ? What's in the gap between 0000h and 0100h ?

2. How does one do floating point arithmetic if one does not have a math
coprocessor (on an 80286) for example?

3. How can one support the asm equivalent of C's long int etc???



Sun, 28 Jun 1998 03:00:00 GMT  
 Please asm newbie with few questions

Quote:

>Hello to all you assembler gurus out there!
>I have just started learning assembler, and even with all the info I have
>(books, txt files, etc), there are a few questions which I have not been
>able to answer.
>1. When writing new code from scratch, why does it always start at an
>offset of 0100h ? What's in the gap between 0000h and 0100h ?

The program segment prefix - contains the command line the program was
invoked with and other stuff.

Quote:
>2. How does one do floating point arithmetic if one does not have a math
>coprocessor (on an 80286) for example?

One shells out 25 big ones and gets an 80287.  Living without an FPU is
more trouble than it's worth.

Quote:
>3. How can one support the asm equivalent of C's long int etc???

Long int is the size of eax, as is long unsigned.  The difference between
the two lies in the interpretation of EFLAGS after an arithmetic or logical
operation.  Disassemble a short C program or step through it with a
de{*filter*}, and you'll see the implementation for yourself.  This is also
a good excercise for a beginner, anyhow.


Sun, 28 Jun 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. A few more newbie questions..

2. A few Topspeed Questions Please Help

3. Few newbie syntax questions

4. A few newbie questions...

5. a few newbie questions...

6. newbie....a few questions

7. Few questions - please help!

8. Newbie here, a few questions

9. A few newbie questions

10. A few more newbie questions

11. A few newbie questions

12. Newbie has a few questions

 

 
Powered by phpBB® Forum Software