From: Tom on

Herman Dullink wrote:
> > 1. Why do segment registers hold segments' paragraph numbers rather
> > than their absolute addresses?
> This is Intel's first attempt to break the 64KB limit of a 16-bit
CPU. Using
> paragraph addresses expands the total addressable space to 1MB. This
allows
> definition of several variable sized segments. Because of lack of
> protection, it's possible to address outside the segment...
> This is only the case on 8086 and compatible CPUs, and in Real Mode
on 80286
> and compatible CPUs. In protected mode, segment registers hold an
index in a
> segment descriptor table, which not only hold a base (absolute)
address, but
> also its size (which is checked for every access) and privileges
> (level,read/write/execute).
>
>
> > What does the second
> > "end Main" expression stand for? Why is this procedure not called?
Or
> > is it?
> The "end" is to tell the assembler that this is the end of the source
code.
> The "Main" is to set the entry point. The linker will put this
address in
> the header of the executable file. DOS will then execute from this
address
> when this file is executed.
> If e.g. you would put a 2nd procedure in this source file (MyMain)
and use
> the name of that 2nd procedure after end, then that 2nd procedure is
run,
> and not "Main".

I see. Thank you.

Tom

From: Tom on

Frank Kotler wrote:
> Tom wrote:
> >
> > Hello,
> > For some time now I have been learning assembly on my own using
> > Webster. So far I have managed to build a small paper-and-pencil uP
and
> > read/comprehend most of the material from the 16-bit DOS version of
AoA
> > (I understand DOS is obsolete, but I have found it simpler to start
> > with, hope to do better in the future).
>
> I agree. You'll find some people feel that you shouldn't
> "waste" any time at all learning dos. I'd agree that it
> isn't worthwhile learning "dos", per se, in any depth, but I
> agree with you that it's "simpler" to interface with dos
> than with Windows or Linux. Linux has an "int 80h" interface
> - similar to the dos "int 21h" interface, but Windows
> requires calling a "Dynamically Linked Library". Easy enough
> to *do*, but harder to understand what you're *doing* (IMO).

Yes, thank you. I know, I agree.

> 32-bit programming, in itself, is *easier* than 16-bit
> programming - no worries about segments, and the addressing
> modes are much more flexible. Once you feel ready to make
> the switch (I'd learn how "call" and "ret" work - how to use
> the stack to pass parameters, and keep the stack "sane"), I
> think you'll like 32-bit programming... so don't waste *too*
> much time with dos!

I know this is a good suggestion. Thank you.

> > Would you be kind enough as to help me clarify the following points
> > (regarding real mode programming):
> >
> > 1. Why do segment registers hold segments' paragraph numbers rather
> > than their absolute addresses?
>
> Funny you should ask... (see the thread about ".model" in
> Tasm). It's either:
>
> 1) Because that's the chip the market *demanded* (at *that*
> time). Easy "upgrade path" for 8080 code, and ability to use
> more than 64k without "wasting" much memory. (my theory) Or:
>
> 2) Intel was really stupid. (Beth's theory)
>
> In any case, I think we agree that it wouldn't be a sensible
> way to design a chip *now*. For purposes of *using* it,
> rather than trying to improve on Intel's design, just assume
> "that's the way it is".
>
> > 2. In Chapter 6 of AoA (The instruction set, 6.11.1 Simple
arithmetic
> > I) Mr. Hyde gives an example of code in which he declares a
procedure
> > MAIN, which is duly terminated with "Main endp". What does the
second
> > "end Main" expression stand for?
>
> It isn't really "second" - "end" is different from "ends".
> "end" tells Masm that your code ends - anything after that
> is ignored - *and* the label after "end" defines where the
> entrypoint to the code is - this example probably doesn't do
> it, but you could put subroutines *before* your "Main", and
> execution would still start at "Main:"...
>
> For comparison - a ".com" file always starts at the
> beginning of your code. Other assemblers indicate the
> entrypoint differently - Nasm, for example, uses "..start:"
> and doesn't use "end" or "ends" at all.
>
> > Why is this procedure not called? Or
> > is it?
>
> No, it's not. Personally, I think "Main" is a potentially
> confusing name to use, if it isn't a "C-style" main - that
> is, called (so a "ret" or "retf" will exit it), and with
> argc, argv, and envp on the stack. That isn't the situation
> with an asm program unless you write the code to do it.
> Or... you can write an asm file using "main" (probably have
> to be "_main", actually), assemble it to an .obj file, and
> use a C compiler to link it... *with* C startup code. In
> this case, "main" needs to be named "main". Otherwise, *I'd*
> call it something else.

Right. Thank you.

> > Thank you very much for all kind replies.
>
> You're welcome. Thank *you* for the on-topic question!

Thank YOU.

> Ignore any "less-than-kind" replies you get, and ignore any
> newbie twirps who advise you to take your questions to clax!

:-)

> We *do* discuss assembly language around here...
> sometimes...

Yes, you do, and I am always most happy to read them.

Thank you.
Tom

From: Tom on

Beth wrote:
> Hi :)

Hello Beth,

> > For some time now I have been learning assembly on my own using
> > Webster. So far I have managed to build a small paper-and-pencil uP
and
> > read/comprehend most of the material from the 16-bit DOS version of
AoA
> > (I understand DOS is obsolete, but I have found it simpler to start
> > with, hope to do better in the future).
>
> Cool :)

The coolest of all thinks one can do. I know. :-)

> > Would you be kind enough as to help me clarify the following points
> > (regarding real mode programming):
> >
> > 1. Why do segment registers hold segments' paragraph numbers rather
> > than their absolute addresses?
>
> Well, 16-bits (the size of the original 8086's registers) can only
address
> 64KB maximum (2^16 = 65536 bytes or 64KB)...some means is, therefore,
> required to "extend" the accessible range to beyond the 64KB that
16-bits
> alone can address...
>
> As to why Intel used _this particular method_ of doing it rather than
some
> other schemes...well, goodness knows why...

I see. :-)

> it doesn't seem particularly sensible to me at all...

Right. :-)

[snipped the stuff I learnt from AoA]

> Absolute address = (segment * 16) + offset

Yes. Why "the miserable 16"? Rather than:

> Absolute address = segment + offset

[...]

> Right...basically because "endp" is for ending the procedure..."end"
is for
> ending the source file...different purposes (though, admittedly, the
way
> they read, it does seem very odd indeed...the way the "end" directive
> specifies the _start_ of all things is, indeed, a rather confusing
facet of
> this kind of syntax...the NASM assembler (and others similar to it)
don't
> bother with the "end" directive at all because it is kind of
confusing and
> seems "unnecessary" with modern machines to have to put "end" at the
end of
> the source file, rather than simply using the "end of file" as the
end
> :)...

Yes. Thank you.

> In generic terms:
>
> <label> endp - ends procedure called "label"
>
> end [<label>] - ends source file and optionally specifies the
> "entry-point" - start address - for execution of the code

That's it! Thank you! Loud and clear! :-)

> Simply, the two serves completely different purposes...and it's just
> "confusing phrasiology" that it does, indeed, _LOOK_ like they seem
to be
> saying the same thing...just a poor choice of name for the
directives,
> really...yes, as weird as it is, "end Main" is NOT actually saying
"end of
> main", it's saying "end of source file...oh, by the way, start the
program
> at Main"...but, yeah, it sure doesn't "read" that way, does it? Just
a
> "quirk" of this style of syntax...

This is just that I am still a novice, imho.

Thank you very much for taking your time with me.

Tom

From: Tom on

'\\o//'annabee wrote:

> Theres a very good explaination of this on Alex's homepage, here :
> http://alexfru.narod.ru/os/c16/c16.html#SegOfsPair

He calls that a trick.

Thank you very much indeed for the link.
Tom

From: Betov on
"Tom" <tmyslovsky(a)yahoo.com> ýcrivait news:1110648637.261048.308660
@l41g2000cwc.googlegroups.com:

>> I agree. You'll find some people feel that you shouldn't
>> "waste" any time at all learning dos. I'd agree that it
>> isn't worthwhile learning "dos", per se, in any depth, but I
>> agree with you that it's "simpler" to interface with dos
>> than with Windows or Linux. Linux has an "int 80h" interface
>> - similar to the dos "int 21h" interface, but Windows
>> requires calling a "Dynamically Linked Library". Easy enough
>> to *do*, but harder to understand what you're *doing* (IMO).
>
> Yes, thank you. I know, I agree.

.... and this is all of the sad problem: You agrea
with something that is utterly wrong and completely
absurd. Simply, as DOS is evidently "simpler", at a
technology point of view, you fall easily into the
illusion that it should be easier to program and easier
to understand. This is wrong and the reverse is true.

There is absolutely nothing different between calling
a DOS interruption, that is a Black Box, doing some
operation, and calling a Win32 Api, that is also a Black
Box, doing some operation. Whatever you _call_ for, be it
an INT or an API, black is black. DOS INTs are, in no
way lesser black than black.

Plus, the developements under a modern OS are incomparably
easier than with DOS. Because of the Tools environements.
Because of the various Debug thingies (including the default
OS securities). Because of the real power of these various
"Black Boxes". And so on.


Betov.

< http://rosasm.org/ >



First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Prev: stricmp
Next: Killing Explorer