I am having trouble understanding how the LEA instruction works on a 4x4 matrix and have try searching the net for some answers. This is my program below.
I am trying to add the 3rd row and output it on the screen. Please help
I have try to only output one of numbers to the screen but not successful

It looks like you are confused about the layout of the memory used to hold the matrix and the offset of the start of the matrix rows. In assembly like in C and C++ you need to understand that arrays and matrixes are zero based but you are assuming the column is 1 based (mov edx,1 ;column). It also looks like you are assuming that each row contains 4 bytes (ecx*4) when in fact they contain 16 bytes (4 dwords).

You also seem confused about how to move the value from the matrix into a register. The 2 instructions mov eax, si and then mov [zyz],eax copy the address of the current matrix element into xyz[0][0] overwriting the existing value with an address.

Here is an example of how to add all of the values in the 3rd row of the matrix to get a total.

It sounds like you might be passing the wrong type of value on the stack to the StdOut function but I can't tell because I don't any way to know what StdOut does. If you post the contents of the c:\MASM32\work\headings2.inc file that your code includes I'll take a look at the StdOut function and see if I can tell you what you need to pass to it.

include \masm32\include\windows.inc ; always first
include \masm32\macros\macros.asm ; MASM support macros

; -----------------------------------------------------------------
; include files that have MASM format prototypes for function calls
; -----------------------------------------------------------------
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

; --------------------------------------------------------------
; This is a prototype for a procedure used in the demo. It tells
; MASM how many parameters are passed to the procedure and how
; big they are. This makes procedure calls far more reliable as
; MASM will not allow different sizes or different numbers of
; parameters to be passed. Note that a C calling convention
; procedure CAN have a variable number of arguments but these
; examples use the normal Windows STDCALL convention which is
; different.
; --------------------------------------------------------------

This is a conflict between the old software my uni was using, so I had to make two files of the headings.inc

So how I can I display the answer to the screen. I use invoke StdOut, addr [ Total]
function and it gives me a character display.

i finally found out how to display the thing , it is using the print command as below this program. Now I need to add the 4th column together and I also need to know how to add the minor diagonal for the matrix -1,7,3,7 . i am still confuse of the row and column??

This example shows how to access and print out each individual element in the matrix. To access a matrix member you need to calculate the byte offset of the element and add this to matrix location in memory. This is what the lea esi,[...] instruction allows you to do. For example to access the individual element Matrix[3][2] you would use the forumla (Matrix address + (bytes per row * 3) + (Bytes per dword * 2)). The operand to the lea instruction in the sample is:

include \masm32\include\windows.inc ; always first
include \masm32\macros\macros.asm ; MASM support macros

; -----------------------------------------------------------------
; include files that have MASM format prototypes for function calls
; -----------------------------------------------------------------
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

Thanks a lot man.. But I am confuse that u said that dword is 16 bytes when I search the internet it is saying that a dword is a 32 bit and which means 4bytes .. as a byte have 8bits ? ? ? ? . However your example program gave me an edge on how to proceed the next one on by own. thanks man.. Do you know if it is possible to split a BCD into a 4 bit when there is a two digit inside like this....

abc db 00100010b ( in binary)

basically I need to split the above array into 0010 and 0010 and add 30h to each to display it separately on the screen '22' I can display it correctly '22 on the screen if I define the array like this 00000010b,00000010b easily. I just want to know if this is possible as most books describe packed BCD but never explain how to unpacked a bcd

I didn't mean to imply that a dword is 16 bytes. A dword is 32 bits or 4 bytes. A row in the matrix consists of 4 dwords which makes the row 16 bytes long. Since addressing in assembly is always done in byte offsets it means that to locate the start of a row in the matrix one needs to multiply the zero based row number by 16 (4 bytes per dword times 4 dwords per row).

I don't really understand what you are trying do with the BCD stored values but unless you are only dealing with unsigned numbers there would be a lot more more than simply adding 30h to each 4 bit value because you would need to handle negative numbers.

If you only want to access the 4 bit BCD values you can load the data from the array into a register and then shift right by 4,8,12, etc. to move the desired 4 bits into the least significant position and then mask them off by anding with 0fh.

Thanks for the input, I get what u mean about the help you gave... I manage to extract 4 bits of the 8bit by the and operation and mov the 4 bit data into another buffer one by one and display it. I have another problem. First this is a macro which is given on the top plus my program.

The question is I was ask to write a program that ask user to enter two numbers decimal numbers(8 digits maximum; means 4 digits each) using the StdIn function and shows their sum on the screen.

The easiest way to do this would be to read, validate and process 1 digit at time rather than trying to process a string. I would suggest using an algorithm such as this to avoid the need for error checking and packing/unpacking BCD numbers. This should be very straightforward to implement with masm32.

No, it is pseudo code just to give you an example of the algorithm. I was trying to give you an idea of how to generate a binary number from user input. Here is some masm32 code that shows how to get generate a binary number from keyboard input. It's basically an implementation of the first while loop from the pseudo code above.

include \masm32\include\windows.inc ; always first
include \masm32\macros\macros.asm ; MASM support macros

; -----------------------------------------------------------------
; include files that have MASM format prototypes for function calls
; -----------------------------------------------------------------
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\msvcrt.inc

THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.