Re: Matrix multiplication 3*3



I think you're better off with the dos int (this is bios), but... Biosen
differ in how they handle int 10h/0Eh. My machine doesn't care *what's*
in bx, it does color 7 (white on black) to video "page" zero. Some
biosen use bh for the video page - you want zero, unless you've done
something unusual. More rarely, some biosen (laptops?) ust bl for the
attribute/color. Color zero, black on black, is hard to read :) "mov bx,
7" should cover your ass in any case. But this can't be redirected to a
file - "myprog>matrix.out" - while the dos int can. This can be handy,
so I'd go with int 21h.

Yes, infact I wasn't sure on better solution. But I tried int 21h too.


INT 10h
POP AX
RET
PRINT_NUMBER ENDP

I don't know where is the mistake... maybe I made a mistake not in this
function?

Actually, no. The rest of your code seems to be correct! There's more
than one problem with your PRINT_NUMBER routine - which I feel stupid to
have missed. I saw the "mov dl, dl" and said "What is this, *compiler*
generated code???" I missed the fact that, yeah, you need to add '0'.
And I missed the fact that we're going to need more than one digit per
number to print the result, even though we only allowed single-digit
inputs (this might be a "better" program if we allowed multi-digit
inputs, and perhaps negative numbers, too - first get this working!)

Yes, I will add '0', because I have to add base ASCII chars.
Oh... yeah... I missed that in the results I need to print multible
digits.
By the way, I limited inputs from 0 to 9 because first of all... I want
see a simple program running... and later I'll try to add some better
feautures.

I've replaced your "PRINT_NUMBER" routine with one that prints multiple
digits (but not negative numbers). You only need "bytes", but this
routine prints "words" - it's "easier" (IMO), and more useful(?). That
means we've got to explicitly zero ah before we call it, since al is all
we're interested in.
This gave apparently-correct results, but with the numbers all "smooshed
together" - hard to read. So for a "quickie fix", I printed a newline
after finishing with the number. Just lazy - this is *not* the way you
want to do it! Your PRINT_NUMBER routine should... print the number. The
formatting should happen in the PRINT_MATRIX routine - and you probably
want to print 'em 3 x 3. It would look nicer if the numbers were "right
justified". This routine isn't well-suited to that. You'd probably want
to replace it with an "itoa"-type routine that just fills a buffer with
the "number converted to text", and print the string seperately. We can
help you with that, if you want to put the time/effort into it. Just
printing a space or two between numbers, and a CR/LF every three would
look "okay", and is probably what you should start with. I apologize for
even showing you such a horrible shortcut! :)

I compiled source code with your function... and it works very well.
Thanks thanks thanks a lot....!!! I think that now I have to make some
adjustment:

- Input layout is very poor user-friendly because user can't see what
number is writing (Maybe I have to insert dos echo???umh... how?)
- Output layout, I think that printing CR/LF every 3 numbers can look
ok for now... but I have to understand how make this :)
- Trying to insert input numbers that are > 9

The good news is, the rest of it seems to be right. I haven't tested it
much - I'll bet it'll overflow a byte if you fill both matrices with
nines :) You don't check for overflow, and perhaps you should. (jc
handle_overflow" for unsigned, "jo handle_overflow" for signed, in the
appropriate places) Does the assignment specify anything about valid
inputs, and/or what you're supposed to do about overflow?

Assignment doesn't specify something about overflow and requires that
input numbers are from 0 to 9... but I think that if I make better...my
mark too is better :)

The "blind" input routine isn't too user-friendly. Looks like you're
planning to improve that. A *really* cool routine would draw a "picture"
of the matrix for the user to fill in - maybe even let 'em back up and
edit previous entries.

Yes, as I said... I will try to do that... but... it seems to be a bit
difficult, not?
I think that after inserting matrix I'll print in 3*3 format.
I want something similar:

Insert first matrix:
123456789

123
456
789

Insert second matrix:
123456789

123
456
789

Results:

000
000
000

(Could it be difficult to do something similar?)

This would be a *lot* of work, and would involve
learning stuff that isn't "worthwhile". Dos really *is* kinda "dead",
you know, and this kind of thing would be done differently in Windows or
better. :) Do what you've got time for - something simple that works is
better than something nicer that doesn't!

The command-line switches you use with Tasm and Tlink are perfect for TD
- the debugger. If you're not using it, you might want to start - it'll
help a lot tracking down the problems, if any :)

I have in my possession some code that takes a somewhat different
approach to the same problem - not my code, I forget where I got it -
must have been "helping" someone with it. Curiously, the names seem to
be in Italian. Does your instructor give the same assignment every year? :)

It is possible :) but... the different approach is better than mine?

Best,
Frank




; //Probably error here
; dead giveaway that you're really a C++ programmer! :)

Yes you're right... I'm C/c++ quite advanced programmer...but I'm very
newbie with assembly... as you see :(


Thanks thanksssss!!!!

Anto

.



Relevant Pages

  • [PATCH] 2/2 Prezeroing large blocks of pages during allocation Version 4
    ... Have USERZERO and KERNZERO for different types of zero pages to avoid ... This is a patch that makes a step towards merging the modified allocator ... static inline void inc_reserve_count(struct zone *zone, ... +static inline void prep_zero_page(struct page *page, int order, int gfp_flags) ...
    (Linux-Kernel)
  • Re: edit and continue
    ... > Are you using the same sourcesafe I'm using. ... > safe crashing vb6. ... Zero random rollbacks (I can see why this would be a bad ... > int", the professional works on code daily and would much rather type "int ...
    (microsoft.public.vb.general.discussion)
  • Re: Order of precedence and associativity
    ... Promote 32 from int to float ... Multiply 0.0f by -5.0f yielding zero ... so multiplying by zero gave minus zero. ...
    (comp.lang.c)
  • Re: Order of precedence and associativity
    ... Promote 32 from int to float ... Multiply 0.0f by -5.0f yielding zero ... so multiplying by zero gave minus zero. ...
    (comp.lang.c)
  • Re: Flags in CCR register after...
    ... with regards to what flags are set when the commands listed below are ... TSTA command tests register A for zero or minus -> A - $00 ... because a sub of 0 doesn't generate an overflow, ...
    (alt.lang.asm)