News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

CodeEdit, the Christmas Edition

Started by hutch--, December 25, 2022, 09:23:21 AM

Previous topic - Next topic

hutch--

I have kept working on CodeEdit to try and get it up to a code editor standard. With this version which I hope is the final release, the auto-indent works, the tab replace which is compatible with the autoindent works fine. Double click word selection works correctly and F1 help uses that to call whatever help file you like. It is currently set with WIN32.HLP.

The DLL usage has been extended, the original "cplugin.dll" performs the same task that load on editor startup and a new capacity for transient load DLLs has been added. It uses the identical call format to simplify making the plugin DLLs, one for setting editor functionality like menus and so on, the other plugins are for transient or temporary loads on demand.

There is an additional script for making the barest plugin DLL (only has a MessageBox() to show it works) and the earlier one for more extensive work.

The one that load at startup (if you use it) must be named "cplugin.dll", any of the others that you may create must have a different name.

The complete package is an editor for programmers who can tweak it to suit their own programming style. In the development and testing, I have found it to be a pleasant enough editor to use, I hope it does the job for you.  :thumbsup:

HSE

Hi Hutch!

I don't understand so well cmd_tail, but look have some problem opening a file from explorer.

More easy, I adapted the reliable 32 bits GetCL:; #########################################################################

GetCL proc ArgNum:DWORD, ItemBuffer:QWORD

  ; -------------------------------------------------
  ; arguments returned in "ItemBuffer"
  ;
  ; arg 0 = program name
  ; arg 1 = 1st arg
  ; arg 2 = 2nd arg etc....
  ; -------------------------------------------------
  ; Return values in eax
  ;
  ; 1 = successful operation
  ; 2 = no argument exists at specified arg number
  ; 3 = non matching quotation marks
  ; 4 = empty quotation marks
  ; -------------------------------------------------

    LOCAL lpCmdLine      :QWORD
    LOCAL cmdBuffer[192] :BYTE
    LOCAL tmpBuffer[192] :BYTE

    USING rsi, rdi

    SaveRegs

    invoke GetCommandLine
    mov lpCmdLine, rax        ; address command line

  ; -------------------------------------------------
  ; count quotation marks to see if pairs are matched
  ; -------------------------------------------------
    xor ecx, ecx            ; zero ecx & use as counter
    mov rsi, lpCmdLine
   
    @@:
      lodsb
      cmp al, 0
      je @F
      cmp al, 34            ; [ " ] character
      jne @B
      inc ecx               ; increment counter
      jmp @B
    @@:

    push rcx                ; save count

    shr ecx, 1              ; integer divide ecx by 2
    shl ecx, 1              ; multiply ecx by 2 to get dividend

    pop rax                 ; put count in eax
    cmp eax, ecx            ; check if they are the same
    je @F
      RestoreRegs
      mov eax, 3            ; return 3 in eax = non matching quotation marks
      ret
    @@:

  ; ------------------------
  ; replace tabs with spaces
  ; ------------------------
    mov rsi, lpCmdLine
    lea rdi, cmdBuffer

    @@:
      lodsb
      cmp al, 0
      je rtOut
      cmp al, 9     ; tab
      jne rtIn
      mov al, 32
    rtIn:
      stosb
      jmp @B
    rtOut:
      stosb         ; write last byte

  ; -----------------------------------------------------------
  ; substitute spaces in quoted text with replacement character
  ; -----------------------------------------------------------
    lea rax, cmdBuffer
    mov rsi, rax
    mov rdi, rax

    subSt:
      lodsb
      cmp al, 0
      jne @F
      jmp subOut
    @@:
      cmp al, 34
      jne subNxt
      stosb
      jmp subSl     ; goto subloop
    subNxt:
      stosb
      jmp subSt

    subSl:
      lodsb
      cmp al, 32    ; space
      jne @F
        mov al, 254 ; substitute character
      @@:
      cmp al, 34
      jne @F
        stosb
        jmp subSt
      @@:
      stosb
      jmp subSl

    subOut:
      stosb         ; write last byte

  ; ----------------------------------------------------
  ; the following code determines the correct arg number
  ; and writes the arg into the destination buffer
  ; ----------------------------------------------------
    lea rax, cmdBuffer
    mov rsi, rax
    lea rdi, tmpBuffer

    mov ecx, 0          ; use ecx as counter

  ; ---------------------------
  ; strip leading spaces if any
  ; ---------------------------
    @@:
      lodsb
      cmp al, 32
      je @B

    l2St:
      cmp ecx, ArgNum     ; the number of the required cmdline arg
      je clSubLp2
      lodsb
      cmp al, 0
      je cl2Out
      cmp al, 32
      jne cl2Ovr           ; if not space

    @@:
      lodsb
      cmp al, 32          ; catch consecutive spaces
      je @B

      inc ecx             ; increment arg count
      cmp al, 0
      je cl2Out

    cl2Ovr:
      jmp l2St

    clSubLp2:
      stosb
    @@:
      lodsb
      cmp al, 32
      je cl2Out
      cmp al, 0
      je cl2Out
      stosb
      jmp @B

    cl2Out:
      mov al, 0
      stosb

  ; ------------------------------
  ; exit if arg number not reached
  ; ------------------------------
    .if ecx { ArgNum
      mov rdi, ItemBuffer
      mov al, 0
      stosb
      mov eax, 2  ; return value of 2 means arg did not exist
      RestoreRegs
      ret
    .endif

  ; -------------------------------------------------------------
  ; remove quotation marks and replace the substitution character
  ; -------------------------------------------------------------
    lea rax, tmpBuffer
    mov rsi, rax
    mov rdi, ItemBuffer

    rqStart:
      lodsb
      cmp al, 0
      je rqOut
      cmp al, 34    ; dont write [ " ] mark
      je rqStart
      cmp al, 254
      jne @F
      mov al, 32    ; substitute space
    @@:
      stosb
      jmp rqStart

  rqOut:
      stosb         ; write zero terminator

  ; ------------------
  ; handle empty quote
  ; ------------------
    mov rsi, ItemBuffer
    lodsb
    cmp al, 0
    jne @F
    RestoreRegs
    mov eax, 4  ; return value for empty quote
    ret
  @@:

    mov eax, 1  ; return value success

    RestoreRegs
   
    ret

GetCL endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


Then:
  ; --------------------------------------
  ; load file from command line if present
  ; --------------------------------------
    DBbegin
    DBclear

    invoke GetCommandLine
    invoke GetCL, 1, addr filebuffer
    DBreg rax
   
    .if rax == 1
   
        lea rax, filebuffer
        DBout rax
        cmp BYTE PTR [rax], 0           ; test if its empty
        je rfout                        ; bypass loading file if empty

        mov pFile, rax
        rcall exist,pFile               ; check if file exists
        test rax, rax
        jnz @F

        mov pbuf,ptr$(buffer)
        mcat pbuf,"Command line file '",pFile,"' cannot be found."
        invoke MsgboxI,hWnd,pbuf,"Whoops",MB_OK,10
        jmp rfout
    .endif
  @@:
    DBout pFile
    rcall file_read, hEdit, pFile

  rfout:
    DBend


But openning files from explorer I'm loosing CodeEditEx path  :biggrin: :biggrin: :biggrin:

That is for another day :thumbsup:
Equations in Assembly: SmplMath

zedd151

#2
Okay, dropping a file either onto the program icon or onto the editor window works; but was curious as to exactly what the issue is. So I tracked down what HSE is talking about.
Upon right clicking an .asm (probably other extensions as well) file in Explorer and clicking "Open With" then "Choose default program", when browsing to select CodeEditEx.exe as the program to open .asm files with, this is the result
Command line file
'"C:\Users\Administrator\downloads\CodeEditEx\findrepl.asm"' cannot be found.


Yikes. I should look at my own editors to see if this occurs there as well.
edited for clarity.

zedd151

#3

Also tested on another file, not in the program directory...
Command line file
'"C:\Users\Administrator\Desktop\POE\poe.asm"' cannot be found.

hutch--

Given that the editor was written in Win10 64 bit and was designed for that OS or higher, it works perfectly here with both Explorer and Winfile. I know Z is using Win7 but I don't know what Hector is using.

zedd151

#5
Whoops! Windows 10 64 bit...
Attemtping to open file via Explorer right click context menu "Open With"...
Same results as above...
I do have Windows 10, 64 bit capability when needed.   :tongue:


edit for typo.  :undecided:

hutch--

Give this test piece a blast. It works perfectly on Win10 64 Pro.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm64\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL clp :QWORD                                ; command line pointer

    call GetCommandLine
    mov clp, rax

    rcall MessageBox,0,clp," GetCommandLine",MB_OK

    mov clp, rvcall(cmd_tail)

    rcall MessageBox,0,clp," cmd_tail",MB_OK

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

zedd151

#7
Quote from: hutch-- on December 27, 2022, 04:28:05 AM
Give this test piece a blast. It works perfectly on Win10 64 Pro.
It works... via Explorer  right click context menu, "Open With..."
lemme go back to Windows 10 and give it a whirl there...
Works with windows 10-64 as well

HSE

Hi Hutch!

Win 10 64 bits here, show exactly zedd's pictures. 

Apparently cmd_tail process first argument, but don't process second argument.
Equations in Assembly: SmplMath

hutch--

Just try this, its a test of the "exist" algo.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm64\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL clp :QWORD                                    ; command line pointer
    LOCAL rvl :QWORD

    call GetCommandLine
    mov clp, rax

    rcall MessageBox,0,clp," GetCommandLine",MB_OK      ; show raw command line

    mov clp, rvcall(cmd_tail)

    rcall MessageBox,0,clp," cmd_tail",MB_OK            ; get the command tail

    rcall exist,clp                                     ; testing "exist" result
    mov rvl, rax
    rcall MessageBox,0,str$(rvl)," 1 = file exists",MB_OK

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

zedd151

#10
Quote from: hutch-- on December 27, 2022, 04:55:13 AM
Just try this, its a test of the "exist" algo.
assembled as console program
Used same method right click .asm file -> (Explorer -> Open With...) as with CodeEditEx.exe

No command tail, returns 0 in Windows 7 64 bit...


Now dropping a file onto the executable does work and returns 1

HSE

cmd_tail don't remove quotes in second argument.

You can see in my first post, I use exist without problem:
        mov pFile, rax
        rcall exist,pFile               ; check if file exists
        test rax, rax
        jnz @F
Equations in Assembly: SmplMath

hutch--

Try this variant. What I am testing is if exist is being handled differently.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm64\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL clp :QWORD                                    ; command line pointer
    LOCAL rvl :QWORD

    call GetCommandLine
    mov clp, rax

    rcall MessageBox,0,clp," GetCommandLine",MB_OK      ; show raw command line

    mov clp, rvcall(cmd_tail)

    rcall MessageBox,0,clp," cmd_tail",MB_OK            ; get the command tail

    .if len(clp) == 0
      rcall MessageBox,0,"Nope"," cmd_tail",MB_OK
    .else
      rcall MessageBox,0,"Yurp"," cmd_tail",MB_OK
    .endif

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

zedd151

Quote from: hutch-- on December 27, 2022, 05:12:44 AM
Try this variant. What I am testing is if exist is being handled differently.
Yurp! It wurked  :tongue:

HSE

Equations in Assembly: SmplMath