Re: Question about jumps




Markus Pitha wrote:


I know exactly what you mean but otherwise I think it's good to
understand how the flags work with the jump commands together,
e.g. important for branching.

Of course it is. But do you need to learn this first? Could it possibly
be that there are other things that are more important to master first?
Things that if you understood them, you would have an easier time
figuring out how flags and conditional instructions work together to
solve real-world problems?


The problem I'm seeing in your posts, though, is *typical* of students
trying to cover too much material at once. While I certainly encourage
you to learn as much as you can from as many sources as possible, it's
pretty clear that you're suffering from the "information overload"
problem (too many new ideas coming at you from too many directions)

That's right, but I think the best way (for me) to learn a programming
language is "learning by doing" and reading the complementary information
additionally or new information first and making the tryings afterwards.

Learning by doing is great, but it's important to learn things in the
right order so that what you learn builds on what you've learned
before. Otherwise, things like the "enter" instruction example you've
given are mysterious to you and you don't know why you're supposed to
be using those instructions. Discovering the appropriate order to
present the material you have to learn in order to master assembly
language isn't as trivial as some people around here seem to think. Now
*you* may be one of the exceptions, but in my experience, putting off
things like flags and conditional branches until people have mastered
basic things like the simple sequential instructions, basic data types,
and basic program organization, works a lot better. Alas, while working
on these things, it's nice to be able to do conditional operations and
loops, hence leveraging your HLL knowledge during this time period.



Maybe in my case it's not that heavy.

Well, I'm not going to argue with you over this other than to say that
the questions you're asking seem to suggest that if you'd learned the
information in a different order you'd probably be having an easier
time of it.

You are surely right that one needs
to know many concepts at once, and I'm sure you know what you're
talking about due to your teaching experience, but I have already some
electronic knowledge due to my first education, I know C and Perl and now
while my second education in an other technical school, I visit almost
every day in the evening, I have to learn Java and C#, so it shouldn't be
a real problem for me to learn everything together instead of step by
step.

So if you already know all these HLLs, whats the problem with using
them while you're beginning to learn assembly? It should be a
no-brainer. You aren't going to learn any less by using your existing
knowledge during the early phases of your assembly education.


And that's what worked for me pretty well every time.

Did your C knowledge not help you when learning Perl? Do you think your
C and Perl knowledge won't help you when you learn Java and C#? Why
should you start completely over when learning assembly language?
That's what you're suggesting that you do?




But if I learn almost everything in HLA style, I don't think I will be
able to decipher something like that that easily

What's to decipher? Are you talking about HLA's syntax? If so, guess
what? All assemblers have a different syntax. So you're faced with the
same problem no matter *what* syntax you learn.

And ultimately, it isn't "assembly language syntax" that you're
learning. It's the assembly language programming paradigm. That is, how
to put the machine instructions together in order to solve real
problems. And that knowledge transcends the syntax of whatever
assembler you're using (or the syntax of the book that is teaching you
assembly language). A MOV instruction does the same thing, and is used
the same way, regardless of whether you're using MASM, NASM, Gas, or
HLA. The exact sequence of characters you type to specify the MOV
instruction is different amongst *all* these assemblers, but the real
knowledge -- knowing how to use the MOV instruction in the first place
-- is exactly the same. *THAT'S* what you're really learning. That's
the thing you want to make as efficient as possible to learn. Learning
the syntax for a new assembler is relatively trivial once you master
the semantics of assembly language.

push cx
push dx
shl ax,4
mov cx,ax ;cycle 16 bits [randomness] times
get_true_rnd_loop:
mov al,06h ;latch counter 0 for word read
cli
out 43h,al ;post request to timer control port
jmp $+2 ;IO delay (JMP to next instruction)
in al,40h ;read LSB of timer count
xor dl,al ;XOR-on LSB
jmp $+2 ;IO delay (JMP to next instruction)
in al,40h ;read MSB of timer count
sti
xor dl,al ;XOR-on MSB
rol dx,1 ;scroll rnd # for uniform randomness
dec cx
jnz short get_true_rnd_loop ;DEC CX+JNZ is usually faster than LOOP
mov ax,dx ;return ax: true random number
pop dx
pop cx
ret

(I found that "random number generator" on the net, but it doesn't work
yet due to an out of memory error. Maybe I'll find the error out soon)

Here's the danger with "finding library code on the internet" and
trying to employ it in your own code -- the code above is almost
certainly 16-bit DOS code. As best I can tell from your other posts,
you're trying to learn assembly under Linux (this would be my guess
because of the presence of INT 0x80 statements in your code). The code
above will *never* work properly under Linux. You'll spend a lot of
time unproductively messing around with the above simply because you
don't realize how different 16-bit code is from 32-bit-flat-model code
like that which Linux uses.

OTOH, if you had kept reading through AoA, you probably would have
learned that you can call one of several nifty little random number
generators that are present in the HLA Standard Library. If you really
needed to see the source code, the HLA stdlib source is available. But,
quite frankly, there is nothing particularly "assembly language" about
a random number generator -- it's just an algorithm that can be
implemented in almost any language (even the hardware-based one found
in your code above).

Again, I would point out, that your hap-hazard way of learning assembly
language is hurting you at this point. No doubt, sooner or later you're
going to figure out that instructions like STI, IN, and OUT don't work
under protected OSes like Windows and Linux (at least, not in user
mode). Therefore, there really is no reason to waste time early on in
your assembly language education to learn about instructions like these
(and why they don't work in your user mode programs); doing so just
gets in the way of learning what's *really* important at this phase of
your education. EVENTUALLY, you'll probably need to know what these
instructions are and why they don't work; but at the stage you're at
now, it's just noise that keeps you from concentrating on the real job
at hand -- mastering assembly language.

Now hacking around from subject to subject as you're doing can be fun
and interesting, but I promise you that by doing so you'll take a
*whole lot longer* to become a reasonably good assembly language
programmer. If you choose to go the "fun and interesting" route,
you'll also wind up with a lot of "holes" in your education.
Cheers,
Randy Hyde

.



Relevant Pages

  • Re: HLA v1.86 is now available
    ... conversion routine is one minute they aren't spending learning machine ... instructions and other true assembly stuff. ... If so, clown, when they are writing an Assembly Routine, ... into an assembly language course wouldn't have a clue about the ...
    (alt.lang.asm)
  • Re: HLA Stdlib v2.2 is now available.
    ... But HLA was written so Randy could teach assembly language ... long time to wait) If not all students make the "descent"... ... The first four chapters really aren't about programming. ... various machine instructions that allow them to learn the basic x86 ...
    (alt.lang.asm)
  • C/C++ Compiler and MASM
    ... assembly language first in the year 1977 while high level language did ... C/C++ Compiler can't provide fewer instructions that I desired so it ... I have repeated to ask the same question about Carry Flag because ... general register might do not be reused. ...
    (comp.lang.asm.x86)
  • Re: Teaching Assembly Language Programming
    ... focusing on learning assembly language. ... distraction for many students: nightly keggers. ... programming projects around the things I wanted the ... The chapter on floating-point instructions would deprecate the use ...
    (alt.lang.asm)
  • Re: Teaching Assembly Language Programming
    ... performance string operations, would use those instructions. ... might say about multithreaded programming in assembly language. ... FASM, and, possibly, NASM. ... NASM and MASM helpful. ...
    (alt.lang.asm)