Author Topic: Print an array as a table using Irvine32  (Read 8472 times)

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Print an array as a table using Irvine32
« Reply #15 on: March 05, 2014, 01:32:44 AM »
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
Code: [Select]
    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

Code: [Select]
.until sign?means that the loop is processed until the sign flag is set
the assembler actually generates code like this
Code: [Select]
    jns top_of_loopjump 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

  • Member
  • ****
  • Posts: 946
Re: Print an array as a table using Irvine32
« Reply #16 on: March 05, 2014, 02:03:04 AM »
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

  • Guest
Re: Print an array as a table using Irvine32
« Reply #17 on: March 05, 2014, 02:05:39 AM »
Hello dedndave - the issue I think it is that the table I have is declared as an array
Code: [Select]
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
Code: [Select]
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

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Print an array as a table using Irvine32
« Reply #18 on: March 05, 2014, 03:44:45 AM »
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
Code: [Select]
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

  • Guest
Re: Print an array as a table using Irvine32
« Reply #19 on: March 05, 2014, 03:51:28 AM »
I will give it a try.
Well, THANK YOU everyone for your help!


Mark44

  • Regular Member
  • *
  • Posts: 40
Re: Print an array as a table using Irvine32
« Reply #20 on: March 07, 2014, 05:39:24 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: adrianvas12
And finally please, what about the
Code: [Select]
inkey "--- OK? ---"? Is that just output? I am using Irvine32.lib and I did not see that command.
Usually we use
Code: [Select]
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

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Print an array as a table using Irvine32
« Reply #21 on: March 07, 2014, 06:07:11 AM »
EFLAGS

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: Print an array as a table using Irvine32
« Reply #22 on: March 07, 2014, 06:09:25 AM »
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