Author Topic: MasmBasic  (Read 153698 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #120 on: August 28, 2013, 03:01:45 PM »
Yeah :t
The problem is to find out on which drive the valid Masm32 installation sits (and there should be one, otherwise go google for VB, script kiddie :lol:)
So the installer checks for a qeditor installation, if that fails, it asks how asm files are being opened. And you open them with a prog outside the Masm32 path, that's why it failed. So I added the "last chance" ;)

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #121 on: August 28, 2013, 10:21:03 PM »
Code: [Select]
@echo off
for %%X in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%X:\masm32\qeditor.exe set MyDrive=%%X:\
MbInstall %MyDrive%

 :P

i know - you don't want a batch file

qWord

  • Member
  • *****
  • Posts: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #122 on: August 29, 2013, 01:45:46 AM »
Great, now I've got a "last" chance! However, a bit strange because I didn't realized that I've had any chance before that one ;)
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #123 on: August 29, 2013, 03:31:44 AM »
i know - you don't want a batch file

That's brute force, Dave :eusa_naughty:

Great, now I've got a "last" chance! However, a bit strange because I didn't realized that I've had any chance before that one ;)

You found the elifo, so you had more than one chance ;-)

Update 30 August:
- default buffer for GetRegVal is now 128k
- The Gf...() family returns for index=-1 or no argument the values for the file identified by the last Exist():

GfSize, GfDate$, GfTime$, GfAgeHours, GfAgeMinutes, GfAgeMs, GfLastWrite
        GetFiles *.asm        ; get all sources in the current folder and its subfolders
        xchg eax, ecx        ; save #files
        For_ ebx=0 To ecx-1
                .if GfAgeHours(ebx)<=24                ; pick your latest code
                        mov esi, Cat$(Files$(ebx)+Space$(20))        ; we simulate LSET
                        Print Str$("\n#%i ", ebx+1), GfDate$(ebx), ", ", GfTime$(ebx), Spc2$, Str$("%i bytes", edx::GfSize(ebx))        ; edx::eax for QUADWORD size
                .endif
        Next
Rem        - all GetFiles special arrays return a DWORD in eax, except for GfLastWrite, which returns
          in xmm0 the ftLastWriteTime FILETIME member of the WIN32_FIND_DATA structure
        - GfSize returns the high quad in edx
        - Gf....(-1I or Gf...(), i.e. index -1 or no arg: all functions return data for the last Exist()
        - GfAge...() is calculated from the moment when GetFiles was launched, except for index=-1, which returns age
          relative to the time of the last Exist() call
« Last Edit: August 30, 2013, 07:33:21 PM by jj2007 »

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #124 on: September 27, 2013, 11:08:21 PM »
Update 27 September 2013:
- Fixed a rare bug in Hex$()
- Clip$(): the optional parameter is now working properly
- QSort works now also for dynamic string arrays
- ShEx for those who can't memorise the 5 ShellExecute args (=myself :biggrin:)

include \masm32\MasmBasic\MasmBasic.inc        ; download
  Init
  Dim My$()        ; create a dynamic string array
  xor ecx, ecx
  .Repeat
        Let My$(ecx)=Str$("String %i", Rand(20)+1000)
        inc ecx
  .Until ecx>=20
  QSort My$()                ; sort all elements allocated so far
  For_ ebx=0 To ecx-1
        PrintLine Str$("Line %i =\t", ebx), My$(ebx)
  Next


  if 0        ; New: ShellExecute for dummies
        FileWrite "~tmp.txt", Cat$("Hello, it's "+Time$)        ; create a text file
        ShEx "~tmp.txt"        ; you can add e.g. SW_MAXIMIZE if needed
  endif

  Exit
end start

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #125 on: October 02, 2013, 06:42:00 PM »
i know this isn't where it started....

but, Bresenham circles are pretty simple
if you develop an ASM algo, you can plot 8 points with each calculation
for elipses, 4 points - and a little "flip" on the second group of octets

maybe some day, i will play with a full set of Bresenham lines and conics   :P
but, this will get you started...

http://people.cs.uchicago.edu/~kaharris/15200/Labs/lab3/circle.html

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #126 on: October 02, 2013, 08:10:10 PM »
but, Bresenham circles are pretty simple

You are the expert :t

But are they simpler than this? Or at least faster, in case it matters??

; This application draws a circle to the console
include \masm32\MasmBasic\MasmBasic.inc        ; download the library
  Init
  Enum 24:xScale, 16:yScale         ; define width and height of the circle
  push 0        ; start with zero degrees
  .Repeat
        fld FP4(0.0174533)        ; load 360/(2*PI)
        fimul stack        ; multiply with decimal degrees
        fsincos        ; get sinus and cosinus simultaneously
        push yScale        ; create a stack slot containing the vertical scale
        fimul stack        ; cosinus * yScale
        fistp stack        ; save to...
        pop eax        ; ... eax
        push xScale        ; create a stack slot with the horizontal scale
        fimul stack        ; sinus * xScale
        fistp stack        ; save to...
        pop ecx        ; ... ecx
        add eax, yScale+2
        add ecx, xScale+3
        Locate(ecx, eax)
        Print "#"
        inc stack
  .Until stack>=360        ; loop until the circle is complete
  pop eax        ; restore stack balance
  Locate(xScale/2+7, yScale/2+9)
  ConsoleColor cRed
  Inkey "Masm32 is great"
  Exit
end start

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #127 on: October 02, 2013, 08:17:58 PM »
i would guess faster
well - in the old days, they were much faster
don't really know how they compare since ~P4 era

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Bresenham circle needs a SQRT?
« Reply #128 on: October 03, 2013, 08:00:13 AM »
Bresenham circle needs a SQRT, right?

Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)
loop overhead is approx. 188/100 cycles

6678    cycles for 100 * Sqrt
11083   cycles for 100 * fsincos

6670    cycles for 100 * Sqrt
11072   cycles for 100 * fsincos

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #129 on: October 03, 2013, 08:38:34 AM »
the whole idea behind Bresenham is to use integers, as opposed to floating point math

here is some decent "pseudo-code"
of course, you wouldn't want to use SetPixel
better to calculate DIB section addresses

Code: [Select]
int x,y,d,r;
y=r;
putpixel(x,y,1);
d=(3-2*r);
while(x<=y)
{
    if(d<=0)
        d += (4*x+6);
    else
    {
        d = d+4*(x-y)+10;
        y--;
    }
    x++;
    putpixel(x,y,1);
    putpixel(-x,y,1);
    putpixel(x,-y,1);
    putpixel(-x,-y,1);
    putpixel(y,x,1);
    putpixel(-y,x,1);
    putpixel(y,-x,1);
    putpixel(-y,-x,1);
}

http://www.asksatyam.com/2011/01/bresenhams-circle-algorithm_22.html

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #130 on: October 03, 2013, 05:05:56 PM »
the whole idea behind Bresenham is to use integers, as opposed to floating point math

here is some decent "pseudo-code"

int x,y,d,r;
y=r;
  <<<<<<<<<<<< assigns garbage

Doesn't fly. But I found one that works great, see attachment (you may have to maximise the console).

For BASIC illiterates: The only MasmBasic instruction is Locate(). If you have a decent Locate macro yourself, you can do it with Masm32 only.

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #131 on: October 03, 2013, 05:46:45 PM »
i would assume "y" and "r" are initialized with the radius

not sure how you got bresenham.asm to assemble
Code: [Select]
end startstart is not defined - i am guessing at the Init call

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #132 on: October 03, 2013, 06:04:32 PM »
not sure how you got bresenham.asm to assemble
Don't be shy, it's just a library, like Masm32 ;-)

Quote
end start
start is not defined - i am guessing at the Init call
Good guess :t

dedndave

  • Member
  • *****
  • Posts: 8751
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #133 on: October 03, 2013, 06:20:59 PM »
the reason for it not assembling being "start" is undefinded   :P

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7752
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #134 on: October 08, 2013, 09:25:41 PM »
Update 8 October 2013 (download):

1. Some improvements of the DDE interface to Excel. Inter alia, there is a new xlsRC$() macro:
  xlsRC$(1, 2) returns "R1C2"

  See detailed example.

2. Win$() can now take as second argument the ID of a child window:

include \masm32\MasmBasic\MasmBasic.inc
  Init                       
  Launch "Notepad.exe \Masm32\include\bignumsdk.inc", SW_MINIMIZE
  Delay 200                ; give Notepad 200 ms to get ready
  .if WinByTitle("bignumsdk.inc - Note")
        xchg eax, ecx                ; ecx is the parent, 15 is the ID of the Notepad edit control
        wPrint "Content=", wTb$, wWin$(ecx, 15)        ; delete the w if you prefer ANSI
        ConsoleColor cYellow
        wInkey wCrLf$, "Title=", wWin$(ecx)
        invoke SendMessage, ecx, WM_CLOSE, 0, 0        ; close Notepad window
  .else
        Inkey "Notepad not ready - increase the delay?"
  .endif
  Exit
end start


3. GSL (GNU Scientific Library) example updated (see \Masm32\MasmBasic\GNUSCLIB\DLL\GslExample.asc)

4. New If_ ... Then ... macro (for details see this thread):
  If_ ebx==123 Then inc ebx : dec eax : call mytest