Re: HLA v1.86 is now available



rhyde@xxxxxxxxxx wrote:
Herbert Kleebauer wrote:


Let's start with the instructions Evenbit used in his example:
move, add, addc and bsr (to call the external functions getc,
putc and exit).

These are not sufficient to write your own integer to string conversion
routine. Even if they were, students in a typical assembly course
generally don't have the algorithmic background to write such a routine
on their own.

Don't you always tell us, that they already have learned a HLL
and that's the reason why you use HLL construction in HLA. And
if they have learned a HLL, then they should have the algorithmic
background to write such a routine on their own.


Because the students
also have to learn the other instructions, let us add a few of
them:

And then add a few more, and a few more.

"Then" yes, but for the moment only four.


This is all fine, but the students can't pick all this up
instantaneously.

Therefore I add only for of the simplest.


And there is a lot more to learn in an assembly
language programming course than machine instructions. Unfortunately,
most of that information (e.g., machine organization) needs to be
taught at the *beginning* of the course. When do they learn about
hexadecimal representation, for example? About registers? About memory
organization? Generally, they have to have a decent handle on all
these subjects before they're ready to master a lot of machine
instructions, and certainly before they write a function like puti.

This has nothing to do with the "puti" function. The have to
learn this before writing ANY function.


They already know the instruction to call a subroutine,

Really? When did they learn this? Was this something they already knew
coming into the course? In one respect, you're right -- they do know

I didn't chose this four instruction for a start (I would have selected
some others). It was Evenbit who used this four instructions when he
asked why he doesn't learn the same when using this instructions in HLA
instead of using them in an assembler. And I told him why.


prerequisite courses. This saves them the pain of having to learn about
the stack, the call instruction, the return instruction, and how to
pass parameters to that subroutine during the first few weeks of the

Why do you need to know anything about the stack when you use the
bsr/rts instructions? As long as you not explicitly manipulate
the stack, you don't have to know how the CPU saves and restores
the return address.


so now we also add the instruction to return from a subroutine
(rts) so we not only can use the given subroutines (getc, putc, exit),
but also can write our own subroutines.

Yep. But that occurs later in the course. See the comments above.

What sense does it make to explain that there is a CPU instruction
to call a subroutine but explain them much later that there is also
an instruction to return from the subroutine?


We also add a branch instruction
(br) so we not only can use sequential code.

Oh, and let us not forget the 16 conditional branch instructions.
And don't forget the CMP instruction.

Where did I say anything about the cmp or 16 conditional branch
instructions? You really should read a posting before answering.


And because they already
know about the carry flag (from the addc)

Of course, if they know about the carry, they also know about the zero
flag, the overflow flag, and the sign flag (which implies that they

Where did I say this? Evenbit used the addc instruction and this only
makes sense if you know the carry flag.


we also add the conditional
branch instructions which depends on the value of the carry flag
(bcc, bcs).

As I said earlier, 16 new instructions.

One of us seems not be able to count: for me "bcc" and "bcs"
are 2 and not 16 instructions.


This additional instructions shouldn't be hard to
understand and we now have a total of 8 instructions:

Learn to count. Jcc along is actually *16* different instructions.

But who said they should learn all 16 in the first lesson. Because
they only know about the carry flag (from the addc instruction)
but nothing about the other flags, what sense would it make to
explain the other 14 condition branch instructions?


move: copy data
add: addition
addc: addition with carry
bsr: branch to subroutine
rts: return from subroutine
br: branch
bcc: branch if Carry is clear (execute the next instruction if Carry is not clear)
bcs: branch if Carry is set (execute the next instruction if Carry is not set)

With this 8 instructions the students should be able to write
there own decimal output routine.

Well, it *really* helps to have div in there, too. But let's say that
these eight instructions are enough. What about all the prerequisite
material? Like a discussion of registers, memory, numeric
representation, addressing modes, ... (the list goes on and on)?

Sorry, but what has this to do with the decimal conversion routine.
This information is necessary for any program they have to write.
All I say is, that once they know enough to write their first program,
they also can write the decimal conversion routine, because all
they need for this code are 7 of the simplest CPU instruction and also
only the simplest addressing modes (immediate and register, no memory
addressing).


And if they are not able to
understand this 8 instructions, then they are also not able
to write a program which needs your pre written output routine
for output.

That's where you're wrong. You see, the difference between your
approach and the AoA/HLA approach is that you throw out a *ton* of new
concepts that the students have to master, including a brand new
programming paradigm.

Now, show me the assembler program which the write as the their
first program and which is simpler then the decimal conversion
routine (uses only simpler instructions an simpler addressing modes).


IOW, I *leverage* their existing knowledge so they can, in a few
minutes in their first lab, write a "Hello, World!" program or print

What has a program, which prints "Hello, World!" without using a single
processor instruction to do with assembly programing?


What is a register? What is a ".l" object?

Please show me the ASSEMBLER programs your students write
without knowing anything about registers.


To use bsr, the students better know about the stack.

Why do they need anything about the stack when they use a bsr
but not if they use a stdout.put?


Also, how are the parameters passed to this subroutine. I.e., the
students expect to be able to pass the parameters in a parameter list,
just like their HLLs; you've got to spend time explaining how to pass
parameters in registers, and *which* registers (i.e., why not r0?),
before they can write code like this.

Isn't it the other way? If a value is in a register, then it is
pretty obvious that the value didn't magically disappear when
the subroutine was called. But you have to explain how the CPU
can access the values that are written in parentheses behind
the function name in your source code. And I think you
have to explain very much until they understand how it works.


What is this $FFFFFFFF stuff? Don't forget, students in your course
don't know about hexadecimal representation yet. Of course, you'll
probably want to teach them about binary and other radixes at the same
time. They don't need that information for this project, but generally
it makes sense to teach them about numeric representation all in one
unit. And that consumes more time.

And with HLA they can write ASSEMBLER programs without knowing
anything about number representation? Even in a HLL you have to
know this, so HLA maybe is a UltraHLL where you can write programs
without knowing (and learning) anything about numbers.


move.l #-1000000000,r2

Are these binary numbers I see? If so, you'd better have taught them
about this.

Why should this be a binary number? In any number representation
there exist numbers which only uses 0 and 1.


What's a ".b" object?

Yes, I know in HLA you don't have to worry about the operand
size, the powerful macro system takes care of it.


Of course, to know about bsr and rts, they'd need to be taught about
the stack.

Just repeating it, doesn't make it true.


Although you've demonstrated that you can do a numeric conversion
without a div instruction, the above is an *incredibly* bad algorithm
to do this job. The last thing you want to do with students early in
their education is teach them *really bad* algorithms such as this one.

Whether an algorithm is appropriate or not depends on the instruction set
which is available. Now show me a better algorithm (shouldn't be
to hard to find for an assembly programmer) for a CPU with only
the above 7 instructions (BTW, there are many CPU's which don't have
a div instruction). And yes, it is a good thing that the students
see, that for a CPU with only this 7 instruction the conversion
routine is complicated. This way they understand why a normal CPU
has more instruction and how this more instructions makes it easier
to write the code.


And again, this is not obsolete DOS code,

Who said anything about DOS?

You always associate three posters in this group with obsolete
DOS code. Just read your posting of this day and then you know
"who said anything about DOS". And if somebody says, assembly
programming in DOS is obsolete, then this clearly shows, that
this somebody doesn't understand what assembly programming is.
Assembly programming means to generate a sequence of CPU
instruction and the CPU knows nothing about the OS. You can
say, assembly programming for real or V86 mode is obsolete,
but again that has nothing to do with the OS (you can execute
16 bit code in XP and you can execute 32 bit code in DOS).


And the point I'm making is that you add the external function puti and
the students can start printing numeric data in their first laboratory
session.

But they have to write an assembler program which calls that puti
function. And if they are able to write this program, then they also
are able to write the output routine themselves (which only needs
seven of the simplest instructions and only 2 of the simplest
addressing modes).
.



Relevant Pages

  • Re: Id like to learn asm...
    ... Where did I say that you "should give up the 486+ instructions"? ... for assembly programming) or it is just some text which has nothing ... read the complete processor manuals (ignoring the FP, MMX, SSE ... An assembler is a tool which converts a symbolic representation ...
    (alt.lang.asm)
  • Re: Id like to learn asm...
    ... assembly programming in real mode DOS, so you are able to use these ... books explain how to actually *use* the machine instructions to ... Our whole life is nothing but learning. ... That's the same as with a spoken language. ...
    (alt.lang.asm)
  • Re: this is the time to pray
    ... I'm sure this giant ... is assembly programming. ... > Write an assembler program which inverts three variables a,b,c. ... > only two NOT instructions. ...
    (alt.lang.asm)
  • Re: Win32 help
    ... >> assembly programming means to write instructions for ... user defined macros as you like. ... Just show us your source code (including ...
    (alt.lang.asm)
  • Re: Thinking assembly?
    ... I simply needs to understand the CPU and how it works, ... > understand the instructions, be a good and experienced programmer, ... assembly language is the machine's language (or, at least, ...
    (alt.lang.asm)