Help!! (Beginner) 
Author Message
 Help!! (Beginner)

I'm trying to learn asm from a library book I got today.  I am using
a86, which I downloaded today.  Anyway, I tried an example from the
book and it doesn't seem to work right.  When I use 'debug' to trace,
I get odd results.  I noticed that the CS and DS registers are equal-
shouldn't they be different?

Anyways, here's the example.  The book is pretty old ('85).

data    segment
        a       dw      2
        c       dw      3
        result  dw      ?
data    ends
;
code    segment
;
main    proc    far
;
        assume cs:code,ds:data
;
        push    ds
        move    ax,0
        push    ax
;
        mov     ax,data
        move    ds,ax
;
        mov     ax,a
        add     ax,c
        mov     result,ax
        ret
main    endp
code    ends
        end

Thanks for any help.

Jim



Sun, 08 Aug 1999 03:00:00 GMT  
 Help!! (Beginner)

Quote:

> I'm trying to learn asm from a library book I got today.  I am using
> a86, which I downloaded today.  Anyway, I tried an example from the
> book and it doesn't seem to work right.  When I use 'debug' to trace,
> I get odd results.  I noticed that the CS and DS registers are equal-
> shouldn't they be different?

> Anyways, here's the example.  The book is pretty old ('85).

> data    segment
>         a       dw      2
>         c       dw      3
>         result  dw      ?
> data    ends
> ;
> code    segment
> ;
> main    proc    far
> ;
>         assume cs:code,ds:data
> ;
>         push    ds
>         move    ax,0
>         push    ax
> ;
>         mov     ax,data
>         move    ds,ax
> ;
>         mov     ax,a
>         add     ax,c
>         mov     result,ax
>         ret
> main    endp
> code    ends
>         end

> Thanks for any help.

> Jim

Hi Jim,

well, the program is written as a procedure. This can be 1 of the
problems because you don't really terminate the program. Unless the first
instructions cooperate with the ret at the end to return to DOS; I don't
know the old way.
In any case, the following should work:
--------------cut here
 data    segment
         a       dw      2
         c       dw      3
         result  dw      ?
 data    ends

 code    segment
         assume cs:code,ds:data

start:   mov     ax,data
         mov    ds,ax

         mov     ax,a
         add     ax,c
         mov     result,ax

        mov     ah,4ch
        int 21h
 code    ends
         end start
---------------------------cut here
This will produce an EXE-file after assembly and linking. And hence your
CS and DS values will be different. To have the same values in all
segment registers, you should produce a .COM file. There are some options
that can produce this kind of file, but there are also conditions to be
fulfilled by your program: basically, it should start with an org 256
statement (I think, not sure though, so be careful).
Hope this helps.
--
Regards,
---------------------------------------------------
Danny Hendrickx   |                               |
Alcatel Telecom   |                               |

-----------------------------------------------------------------
I wanted to take my wife on a world trip for the holidays,
but she wanted to go somewhere else...
-----------------------------------------------------------------



Sun, 08 Aug 1999 03:00:00 GMT  
 Help!! (Beginner)

Quote:

> book and it doesn't seem to work right.  When I use 'debug' to trace,
> I get odd results.  I noticed that the CS and DS registers are equal-
> shouldn't they be different?
> Anyways, here's the example.  The book is pretty old ('85).
> data       segment
>    a       dw      2
>    c       dw      3
>    result  dw      ?
> data       ends
> ;
> code       segment
> ;
> main       proc    far
...
>    end

I don't know what is segment order in produced executable, and
what executable you produced. Unless code is first, the program
cannot start at valid address if it is not specified on "end"
instruction (use "end main" instead "end"). In EXE CS=DS+10h on
start, in COM they are equal. DS: there is too much possibilities
to write about all. Look on linker map and check segment order.
If you have problems with A86, why not to use ARROWASM+VAL?
They are MASM-compatible and free.


Mon, 09 Aug 1999 03:00:00 GMT  
 Help!! (Beginner)

Quote:

>> main    proc    far
>> assume cs:code,ds:data
>> push    ds
>> move    ax,0
>> push    ax
...
>> ret
>> main    endp
> well, the program is written as a procedure. This can be 1 of the

It is correct: such a program returns to INT 20h opcode in PSP.


Tue, 10 Aug 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP!! BEGINNER HERE

2. HELP!! beginner question on how to read in a line of numbers....

3. Need Help. Beginner!

4. Help! Beginner!

5. Asm beginner-NEED HELP

6. Beginner needs help with namespaces

7. Help Beginner (ReduceReplicate)

8. Help Beginner

9. help a beginner

10. Beginner needs help!

11. Help a beginner?

12. beginner needs help

 

 
Powered by phpBB® Forum Software