Author Topic: (ignore: response to ShowCase rant)  (Read 439 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11552
  • Assembler is fun ;-)
    • MasmBasic
(ignore: response to ShowCase rant)
« on: March 10, 2021, 01:26:13 PM »
I set up this Showcase sub forum for assembler code, should we be supporting C and basic compilers as well ?

Assembler code is code that gets assembled by an assembler. So MasmBasic is assembler code. Once upon a time you were proud to produce high level stuff. Your Masm32 SDK is full of basic-like macros, see below.

But you are the boss here, so I moved my showcase example to the MasmBasic section :cool:

Code: [Select]
acfm$ MACRO txt:VARARG/LOCAL ch1,char,nu$,tmp,flag,lbuf,rbuf,cpos,sln
add$ MACRO lpSource,lpAppend/IFNDEF __UNICODE__
alloc MACRO bytecount/invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,bytecount
alloc$ MACRO ln/invoke SysAllocStringByteLen,0,ln
Append MACRO buffer,text/LOCAL szTxt
append$ MACRO string,buffer,location/IFNDEF __UNICODE__
AppModel MACRO Processor/Processor ;; Processor type
AppStart MACRO/.code
argcount MACRO args:VARARG/LOCAL cnt
arr2file$ MACRO arr,ptxt ;; write array to text file with CRLF line terminatio
arr2mem$ MACRO arr,pmem ;; binary write array to memory with/EXITM <rv(arr2m
arr2text$ MACRO arr,pmem ;; write array to text buffer/EXITM <rv(arr2text,arr
arralloc$ MACRO member_count ;; create a new empty array/EXITM <rv(arralloc,membe
arrbin$ MACRO arr,indx,psrc,lsrc ;; write binary data to an array member/EXITM <rv(ar
arrcnt$ MACRO arr ;; get the stored member count/EXITM <rv(arrcnt,arr)
arrealloc$ MACRO arr,cnt ;; change the size of an existing array/EXITM <rv(ar
arrextnd$ MACRO arr,indx ;; extend an existing array/EXITM <rv(arrextnd,arr,i
arrfile$ MACRO file_name ;; load multiline text file into array/EXITM <rv(arr
arrfree$ MACRO arr ;; destroy an array freeing all of the memory it use
arrget$ MACRO arr,indx ;; get the address of an array member/EXITM <rv(arrg
arrlen$ MACRO arr,indx ;; get the stored length of a single member/EXITM <r
arrset$ MACRO arr,indx,ptxt ;; write text data to an array member/EXITM <rv(arrs
arrtotal$ MACRO arr,crlf ;; calculate entire array storage/EXITM <rv(arrtotal
arrtrunc$ MACRO arr,indx ;; truncate an existing array/EXITM <rv(arrtrunc,arr
arrtxt$ MACRO ptxt ;; load multiline text buffer into array/EXITM <rv(a
ascii MACRO quoted_text:VARARG/LOCAL txtname
ASM MACRO parameter1,source/LOCAL mnemonic
BeginMessageLoop MACRO mStruct/MessageLoopStart:
CADD MACRO quoted_text:VARARG/LOCAL vname,lbl
case$ MACRO quoted_text:REQ/;; The case statements will be any statements between the
casei$ MACRO quoted_text:REQ/;; The case statements will be any statements between th
cat$ MACRO arguments:VARARG/LOCAL txt
catargs MACRO mname,mem,args:VARARG/LOCAL lcnt,var ;; LOCAL loop
ccout MACRO text:VARARG/print cfm$(text)
cfm$ MACRO txt:VARARG/IFDEF __UNICODE__
chdir MACRO pathname/invoke SetCurrentDirectory,reparg(pathname)
chr$ MACRO any_text:VARARG/LOCAL txtname
chtype$ MACRO character/IFNDEF chtyptbl
cls MACRO ;; clear screen/invoke ClearScreen
cmd$ MACRO argnum/LOCAL argbuffer
cmp$ MACRO arg1,arg2/invoke lstrcmp,reparg(arg1),reparg(arg2)
cmpi$ MACRO arg1,arg2/invoke lstrcmpi,reparg(arg1),reparg(arg2)
cprint MACRO args:VARARG/push esi
CPROTO MACRO func_addr:REQ,arglist:VARARG ;; C calling version/LOCAL lp,var
cst MACRO arg1,arg2/IFNDEF __UNICODE__
CTXT MACRO quoted_text:VARARG/EXITM <offset literal(quoted_text)>
CurDir$ MACRO/IFNDEF cdir__equate__flag
date$ MACRO/IFNDEF @_@_current_local_date_@_@
DDPROTO MACRO lpFunction,pcount/LOCAL txt1,txt2
DropFileName MACRO wordparam/IFNDEF df@@name
dsText MACRO Name, Text:VARARG/.data
echo ERROR IN "stackframe" MACRO/echo Incorrect Argument Supplied
else$ MACRO/IFIDN $sw_state$, <if> ;; If following a case$, emit a jump t
elsei$ MACRO/IFIDN $sw_statei$, <if> ;; If following a case$, emit a jum
EndMessageLoop MACRO mStruct/invoke TranslateMessage, ADDR mStruct
endsw$ MACRO/IFIDN $sw_state$, <if> ;; If following a case$, terminate th
endswi$ MACRO/IFIDN $sw_statei$, <if> ;; If following a case$, terminate
env$ MACRO item/invoke crt_getenv,reparg(item)
envget$ MACRO str1/IFNDEF get@@env@@buffer
envset$ MACRO evar,evalue/IFIDN <evalue>,<0>
exit MACRO optional_return_value/IFNDEF optional_return_value
expand_prefix MACRO txtitm/LOCAL prefix1,wrd,nu,varname
fclose MACRO arg:REQ/invoke CloseHandle,arg
fcreate MACRO filename/invoke CreateFileA,reparg(filename),GENERIC_READ or GENERIC_WRITE
fcreateW MACRO filename/invoke CreateFileW,reparg(filename),GENERIC_READ or GENERIC_WRIT
fdelete MACRO filename/invoke DeleteFileA,reparg(filename)
fdeleteW MACRO filename/invoke DeleteFileW,reparg(filename)
fexist MACRO name_of_file/IFNDEF __UNICODE__
fflush MACRO hfile/invoke FlushFileBuffers,hfile
find$ MACRO spos,lpMainString,lpSubString/IFNDEF __UNICODE__
fld10 MACRO fpvalue/LOCAL name
fld4 MACRO fpvalue/LOCAL name
fld8 MACRO fpvalue/LOCAL name
FLOAT10 MACRO name,value/.data
FLOAT4 MACRO name,value/.data
FLOAT8 MACRO name,value/.data
fn MACRO FuncName:REQ,args:VARARG/p@arg equ <invoke FuncName> ;; construct inv
fnc MACRO FuncName:REQ,args:VARARG/the@arg equ <invoke FuncName> ;; construct in
fncx MACRO FncName:req,args:VARARG/;/* check if a optional destination is specified */
fnx MACRO FncName:req,args:VARARG/;/* check if a optional destination is specified */
fopen MACRO filename/invoke CreateFileA,reparg(filename),GENERIC_READ or GENERIC_WRITE,
fopenW MACRO filename/invoke CreateFileW,reparg(filename),GENERIC_READ or GENERIC_WRITE,
FP10 MACRO value/LOCAL vname
FP4 MACRO value/LOCAL vname
FP8 MACRO value/LOCAL vname
fprint MACRO hFile:REQ,text:VARARG ;; zero terminated text/LOCAL var
fprintc MACRO hFile:REQ,text:VARARG ;; zero terminated text/LOCAL var
fread MACRO hFile,buffer,bcnt/LOCAL var
free MACRO hmemory/invoke GlobalFree,hmemory
free$ MACRO strhandle/invoke SysFreeString,strhandle
fseek MACRO hFile,distance,location/IFIDN <location>,<BEGIN>
fseteof MACRO hFile/invoke SetEndOfFile,hFile
fsize MACRO hFile/invoke GetFileSize,hFile,NULL
ftext MACRO hFile:REQ,args:VARARG/push esi ;; preserve ESI
FUNC MACRO parameters:VARARG/invoke parameters
fwrite MACRO hFile,buffer,bcnt/LOCAL var
getarg MACRO num:REQ,args:VARARG/LOCAL cnt, txt
GetConsoleCaption$ MACRO/IFNDEF @@_console_caption_buffer_@@
GetDllProc MACRO libname_text1,procname_text2/LOCAL library_name
GetFontHandle MACRO fnam:REQ,fsiz:REQ,fwgt:REQ/invoke RetFontHandle,reparg(fnam),fsiz,
getkey MACRO/call ret_key
GLOBAL MACRO variable:VARARG/.data
GLOBALS MACRO var1,var2,var3,var4,var5,var6,var7,var8,var9,var0,/varA,varB
h2ub MACRO pStr:req/LOCAL ub
h2ud MACRO pStr:req/LOCAL ud
h2uq MACRO pStr:req/LOCAL uq
h2uw MACRO pStr:req/LOCAL uw
halloc MACRO bytecount/EXITM <rv(HeapAlloc,rv(GetProcessHeap),0,bytecount)>
hDlgItem MACRO pHwnd,ctlID/LOCAL retval
hex$ MACRO DDvalue/LOCAL rvstring
hfree MACRO memory/invoke HeapFree,rv(GetProcessHeap),0,memory
hsize MACRO hmem/invoke HeapSize,rv(GetProcessHeap),0,hmem
hval MACRO lpstring ; hex string to unsigned 32 bit integer/invoke htodw, reparg
inkey MACRO user_text:VARARG/IFDIF <user_text>,<NULL> ;; if user text n
input MACRO prompt:VARARG/LOCAL txt
InputFile MACRO lpFile/IFNDEF __UNICODE__
InputFileA MACRO lpFile/;; ----------------------------------------------------------
InputFileW MACRO lpFile/;; ----------------------------------------------------------
isregister MACRO var:req/IF regsize(var)
issize MACRO var:req, bytes:req/LOCAL rval
jmp_table MACRO name,args:VARARG/.data
LastError$ MACRO/IFNDEF @@_e_r_r_o_r_@@
lcase$ MACRO lpString/IFNDEF __UNICODE__
left$ MACRO lpString,slen/IFNDEF __UNICODE__
len MACRO lpString/IFNDEF __UNICODE__
LimitWindowHeight MACRO whgt/LOCAL label
LimitWindowWidth MACRO wdth/LOCAL label
linein$ MACRO source,buffer,spos/invoke readline,source,buffer,spos
lineout$ MACRO source,buffer,spos,op_crlf/invoke writeline,reparg(source),buffer,spos,op
literal MACRO quoted_text:VARARG/LOCAL local_text
LoadProcAddress MACRO libname_text1,procname_text2/LOCAL library_name
lob MACRO/mov al, [esi]
loc MACRO xc,yc ;; set cursor position/invoke locate,xc,yc
LOWORD MACRO bigword mov eax,bigword/and eax,0FFFFh ;; Set to low wor
lstrcat$ MACRO arg1,arg2/invoke lstrcat,tstarg(arg1),reparg(arg2)
lstrcmp$ MACRO arg1,arg2/invoke lstrcmp,reparg(arg1),reparg(arg2)
lstrcmpi$ MACRO arg1,arg2/invoke lstrcmpi,reparg(arg1),reparg(arg2)
lstrcpy$ MACRO arg1,arg2/invoke lstrcpy,tstarg(arg1),reparg(arg2)
lstrcpyn$ MACRO arg1,arg2,ccnt/invoke lstrcpyn,tstarg(arg1),reparg(arg2),ccnt
ltrim$ MACRO lpString/IFNDEF __UNICODE__
m2m MACRO M1, M2/push M2
MAKEDWORD MACRO LoWord,HiWord/mov ax, HiWord
MakeIP MACRO arg1,arg2,arg3,arg4/mov ah, arg1
Mcopy MACRO lpSource,lpDest,len/mov esi, lpSource
memalign MACRO reg, number/add reg, number - 1
mkdir MACRO dirname/invoke CreateDirectory,reparg(dirname),NULL
mrm MACRO m1, m2/mov eax, m2
MsgBox MACRO hndl,txtmsg,titlemsg,styl/invoke MessageBox,hndl,reparg(txtmsg),reparg(titl
nops MACRO cnt:REQ/REPEAT cnt
num2str MACRO arg/EXITM % arg
op_type MACRO arg:REQ/LOCAL result
OpenFileDlg MACRO hWin,hInstance,lpTitle,lpPattern/invoke OpenFileDialog,hWin,hInstanc
OutputFile MACRO lpFile,lpMem,lof/IFNDEF __UNICODE__
OutputFileA MACRO lpFile,lpMem,lof/invoke write_disk_file,reparg(lpFile),lpMem,lof
OutputFileW MACRO lpFile,lpMem,lof/invoke write_disk_fileW,reparg(lpFile),lpMem,lof
Pcall MACRO name:REQ,items:VARARG/LOCAL arg
popr MACRO/LOCAL lbl
poptext MACRO name:req/LOCAL pos
poptexti MACRO name:req/LOCAL pos
poptxt MACRO extra:VARARG ;; "extra" arg if used must be "lbl" (without
poptxt$ MACRO/LOCAL txt,num,sln
print MACRO arg1:REQ,varname:VARARG ;; display zero terminated string/IFNDEF __UN
printc MACRO text:VARARG/print cfm$(text)
printf MACRO format:REQ, args:VARARG/IFNDEF __UNICODE__
pth$ MACRO ;; application path OFFSET returned/IFNDEF pth__equate__flag
ptr$ MACRO buffer/lea eax, buffer
pushr MACRO regs:VARARG/LOCAL cnt,lpc,lbl
pushtext MACRO name:req/$text_stack$ CATSTR <name>, <#>, $text_stack$
pushtexti MACRO name:req/$text_stacki$ CATSTR <name>, <#>, $text_stacki$
pushtxt MACRO arg/IFNDEF @_txt_stack_@
real10$ MACRO r10value:req/LOCAL buffer, r8value
real4$ MACRO r4value:req/LOCAL buffer, r8value, r4tmp
real8$ MACRO r8value:req/LOCAL buffer
regsize MACRO item/LOCAL rval,ln
remove$ MACRO src,substr/IFDEF __UNICODE__
reparg MACRO arg/LOCAL nustr
repargof MACRO arg/LOCAL nustr
repargs MACRO cstr:=<0>,args:VARARG/;/* initialize global counter which */
repargv MACRO arg/LOCAL nustr
return MACRO arg/mov eax, arg
retval MACRO var/IF var EQ 0
rev$ MACRO lpString/IFNDEF __UNICODE__
RGB MACRO red, green, blue/xor eax, eax
right$ MACRO lpString,slen/IFNDEF __UNICODE__
rmdir MACRO dirname/invoke RemoveDirectory,reparg(dirname)
rndir MACRO oldname,newname/invoke MoveFile,reparg(oldname),reparg(newname)
rtrim$ MACRO lpString/IFNDEF __UNICODE__
rv MACRO FuncName:REQ,args:VARARG/the@arg equ <invoke FuncName> ;; construct inv
rvc MACRO FuncName:REQ,args:VARARG/the@arg equ <invoke FuncName> ;; construct in
rvcx MACRO FncName:req,args:VARARG/;/* check if a optional destination is specified */
rvx MACRO FncName:req,args:VARARG/;/* check if a optional destination is specified */
SADD MACRO quoted_text:VARARG/EXITM <ADDR literal(quoted_text)>
sas MACRO var,quoted_text:VARARG/LOCAL txtname
SaveFileDlg MACRO hWin,hInstance,lpTitle,lpPattern/invoke SaveFileDialog,hWin,hInstanc
sbyte$ MACRO sbytevalue:req/;; signed byte
Scall MACRO name:REQ,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12, \/p13,p14,p1
sdb$ MACRO sbytevalue:req/;; signed byte
sdd$ MACRO sdwordvalue:req/;; signed dword
sdq$ MACRO sqwordvalue:req/;; signed qword
sdw$ MACRO swordvalue:req/;; signed word
sdword$ MACRO sdwordvalue:req/;; signed dword
SetConsoleCaption MACRO title_text:VARARG/invoke SetConsoleTitle,reparg(title_text)
setenv MACRO value/invoke crt__putenv,reparg(value)
ShellAboutBox MACRO handle,IconHandle,quoted_Text_1,quoted_Text_2:VARARG/LOCAL AboutTi
SingleInstanceOnly MACRO lpClassName/invoke FindWindow,lpClassName,NULL
SPROTO MACRO func_addr:REQ,arglist:VARARG ;; STDCALL version/LOCAL lp,var
sqword$ MACRO sqwordvalue:req/;; signed qword
sstr$ MACRO number/LOCAL buffer
stackframe MACRO arg/IFIDN <on>,<arg>
stb MACRO/mov [edi], al
str$ MACRO DDvalue/LOCAL rvstring
STRADD MACRO data_label,args:VARARG/LOCAL dataname
stralloc MACRO ln/invoke SysAllocStringByteLen,0,ln
strcat MACRO arguments:VARARG/LOCAL txt
strfree MACRO strhandle/invoke SysFreeString,strhandle
STRING MACRO data_label,quoted_text:VARARG/IFNDEF __UNICODE__
sval MACRO lpstring/IFNDEF __UNICODE__
switch$ MACRO lpstring:REQ/pushtext $test_val$ ;; Preserve globals fo
switchi$ MACRO lpstring:REQ/pushtexti $test_vali$ ;; Preserve globals
sword$ MACRO swordvalue:req/;; signed word
SysDir$ MACRO/IFNDEF sys__equate__flag
szText MACRO Name, Text:VARARG/LOCAL lbl
TB_BEGIN MACRO pHandle/LOCALVAR TBhWnd :DWORD
TB_BEGIND MACRO pHandle/LOCALVAR TBhWnd :DWORD
TB_END MACRO/mov eax, TBhWnd
time$ MACRO/IFNDEF @_@_current_local_time_@_@
trim$ MACRO lpString/IFNDEF __UNICODE__
tstarg MACRO arg/quot SUBSTR <arg>,1,1
tstline$ MACRO lpstr/invoke tstline,reparg(lpstr)
TxtItem MACRO tID, cID, strng/mov tbb.iBitmap, I_IMAGENONE
TxtSeperator MACRO/mov tbb.iBitmap, I_IMAGENONE
uadd$ MACRO wstr1,wstr2/invoke ucCatStr,wstr1,wstr2
ubyte$ MACRO ubytevalue:req/;; unsigned byte
uc$ MACRO args:VARARG/.data
ucase$ MACRO lpString/IFNDEF __UNICODE__
ucc$ MACRO args:VARARG/.data
ucCmd$ MACRO argnum/IFNDEF ucl_@_buffer
UCCSTR MACRO lbl,args:VARARG/IFNDEF uccstr_lbl_cntr
ucfm$ MACRO txt:VARARG/LOCAL ch1,char,nu$,tmp,flag,lbuf,rbuf,cpos,sln
ucmp$ MACRO wstr1,wstr2/invoke ucCmp,wstr1,wstr2
ucopy$ MACRO wstr1,wstr2/invoke ucCopy,wstr1,wstr2
UCSTR MACRO lbl,args:VARARG/;/* initialize counter used for label creation */
udb$ MACRO ubytevalue:req/;; unsigned byte
udd$ MACRO udwordvalue:req/;; unsigned dword
udq$ MACRO uqwordvalue:req/;; unsigned qword
udw$ MACRO uwordvalue:req/;; unsigned word
udword$ MACRO udwordvalue:req/;; unsigned dword
uhex$ MACRO DDvalue ;; unsigned DWORD to hex string/LOCAL rvstring
ulcase$ MACRO lpwstr/invoke CharLowerBuffW,lpwstr,ulen$(lpwstr)
uleft$ MACRO lpwstr,ccount/invoke ucLeft,lpwstr,lpwstr,ccount
ulen$ MACRO lpwstr/invoke ucLen,lpwstr
ultrim$ MACRO lpwstr/invoke ucLtrim,lpwstr,lpwstr
umid$ MACRO lpwstr,spos,ln/invoke ucMid,lpwstr,lpwstr,spos,ln
uni$ MACRO arglist:VARARG/LOCAL DATA@NAME
uptr$ MACRO lpbuffer/lea eax, lpbuffer
uqword$ MACRO uqwordvalue:req/;; unsigned qword
urev$ MACRO lpwstr/invoke ucRev,lpwstr,lpwstr
uright$ MACRO lpwstr,ccount/invoke ucRight,lpwstr,lpwstr,ccount
urtrim$ MACRO lpwstr/invoke ucRtrim,lpwstr,lpwstr
uselib MACRO args:VARARG/LOCAL acnt,buffer,var,lbl,libb,incc,buf1,buf2
ustr$ MACRO number/LOCAL buffer
uucase$ MACRO lpwstr/invoke CharUpperBuffW,lpwstr,ulen$(lpwstr)
uval MACRO lpstring/IFNDEF __UNICODE__
uword$ MACRO uwordvalue:req/;; unsigned word
WinDir$ MACRO/IFNDEF wdir__equate__flag
write MACRO quoted_text:VARARG ;; display quoted text/LOCAL txt
WSTR MACRO lblname,arglist:VARARG/LOCAL qflg ;; quote flag
xbyte$ MACRO xbytevalue:req/;; unsigned hex byte
xdb$ MACRO xbytevalue:req/;; unsigned hex byte
xdd$ MACRO xdwordvalue:req/;; unsigned hex dword
xdq$ MACRO xqwordvalue:req/;; unsigned hex qword
xdw$ MACRO xwordvalue:req/;; unsigned hex word
xdword$ MACRO xdwordvalue:req/;; unsigned hex dword
xqword$ MACRO xqwordvalue:req/;; unsigned hex qword
xword$ MACRO xwordvalue:req/;; unsigned hex word
zero1 MACRO membuf/mov membuf[0], 0
« Last Edit: March 10, 2021, 09:14:46 PM by jj2007 »