News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Print an array as a table using Irvine32

Started by adrianvas12, March 01, 2014, 07:17:33 AM

Previous topic - Next topic

dedndave

hi Adrian

"inkey" is a masm32 macro
it displays the string provided, then waits for a keypress before continuing
if no string is provided, "Press any key to continue..." is used
it's often used so that the console window does not disappear before the user sees the result

Irvine32 does not have an exact match for that macro
but, it does have a similar function named WaitMsg
    call    WaitMsg

Sign?.....
in assembly language, decisions are often made by use of conditional branches
JE jump if equal
JA jump if above
and so on
they branch, based on the condition of various processor status flags

.until sign?
means that the loop is processed until the sign flag is set
the assembler actually generates code like this
    jns top_of_loop
jump if no sign to top of loop
when the sign flag is set, the branch is not taken and execution falls out of the loop

FORTRANS

Hi,

   If you generate a listing of a program, you can see the code
that is produced by the .Until Sign construct.  If you see something
new, a listing may explain what it is by examining the actual code
and comparing it to the program text.

Regards,

Steve N.

adrianvas12

Hello dedndave - the issue I think it is that the table I have is declared as an array

NUMS WORD 09EEBh, 0B0CFh, 061E5h, 089EDh, 0AF17h, 0D8D1h, 06C1Dh, 0594Eh, 0CF55h
     WORD 03767h, 063C6h, 0AE84h, 0412Fh, 0B226h, 046C1h, 0879Bh, 076B6h, 093FFh

vs. what is provided in the code submited by jj2007

NUMS   WORD 09EEBh,0B0CFh,061E5h, 089EDh, 0AF17h, 0D8D1h, 06C1Dh, 0594Eh, 0CF55h,
   03767h, 063C6h, 0AE84h, 0412Fh, 0B226h, 046C1h, 0879Bh, 076B6h, 093FFh


I also don't have the included library - all we have available is irvine (attached)

dedndave

i have the Irvine32 library
which, it would seem you are missing a few include files that go with it
you should also have:
floatio.inc
graphwin.inc
macros.inc
smallwin.inc
virtualkeys.inc

the difference between what you and Jochen have is fairly simple
if you use the LENGTHOF or SIZEOF operator, Jochen's will account for the entire array
yours will only account for the elements in the first line

you can also do it this way
NUMS WORD 09EEBh, 0B0CFh, 061E5h, 089EDh, 0AF17h, 0D8D1h, 06C1Dh, 0594Eh, 0CF55h
     WORD 03767h, 063C6h, 0AE84h, 0412Fh, 0B226h, 046C1h, 0879Bh, 076B6h, 093FFh
NUMSEND EQU $

then, use (NUMSEND-NUMS) to get the size of the array in bytes
or (NUMSEND-NUMS)/WORD to get the number of elements

Jochen's method is simpler   :P

adrianvas12

I will give it a try.
Well, THANK YOU everyone for your help!


Mark44

Quote from: adrianvas12 on March 05, 2014, 01:07:47 AM
OK - what does it do?
I'm assuming that "it" here refers to the sign flag. The CPU has a register named FLAGS (more recently it's called EFLAGS). It has a variety of flags, such as ZF (zero flag), CF (carry flag), OF (overflow flag) and some others. SF, the sign flag, is bit 7. After certain instructions, the sign flag is set to the most significant bit of the result. For a signed integer, the most significant bit is 1 for a negative number, and 0 for a positive number.

In assembly programming branches and loops are usually controlled by one of the flags in the flags register.
Quote from: adrianvas12And finally please, what about the
inkey "--- OK? ---"? Is that just output? I am using Irvine32.lib and I did not see that command.
Usually we use call WriteString
All that's happening here is that the string "---OK? ---" is being displayed. You can use whatever you're used to to do this.

dedndave


dedndave

Conditional Branches

it is important to understand how different instructions affect the flags
mainly, the math and logic operations
some do not behave the way you might think - lol
but - it is one of the most important things to learn for assembly programming

there are also a few instructions that branch, based on whether or not CX/ECX is zero