flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > Tutorials, Books, Sites

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 27 Jan 2013, 14:58
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 21:53; edited 3 times in total
Post 27 Jan 2013, 14:58
View user's profile Send private message Reply with quote
ASM-Man



Joined: 11 Jan 2013
Posts: 64
ASM-Man 27 Jan 2013, 20:01
AsmGuru62 wrote:
@ASM-Man: yes -- OO means Object Oriented.


Nice. And how will you implement it in assembly language? could you provide a code example? Razz

_________________
I'm not a native speaker of the english language. So, if you find any mistake what I have written, you are free to fix for me or tell me on. Smile
Post 27 Jan 2013, 20:01
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 27 Jan 2013, 22:24
Why change the subject?

Randall Hyde never claimed that HLA was "real assembler". In fact, the name is "High-Level ASM".

Quote:
I am using macros, because it is normal for "macro assembler"
We both create/use macros. Only difference is you that claim your macros are real ASM.

Quote:
For this reason you will never see me using HLL style "if then else" macros or "for", "while", etc
And you will never see me waste 10+ years of my life working on one program that's only for Windows Smile Listen, I'm not trying to change anyone who is satisfied with their style and I don't care how you personally write code. I merely offer syntaxes to programmers who are looking for alternatives and don't want to use HL compilers like C++/C#/Java. Also, remember that these so-called HL syntaxes are on the CPU/machine level; way below OS-specific code and controls.

My Z77 library was originally written in pure ASM then converted to macros and I have many reasons for this. One reason is portability. This is important in the modern world where there are multiple CPUs and OSs. ARM is the future and I want to support Menuet. Example:

Code:
; 100% portable to any CPU or OS...

try [p]=allocate 4*KB

; NOT portable. specific to CPU, OS
; and HL calling convention...
; (in addition to being much longer)

invoke HeapAlloc [heap], 0, 4096
mov [p], eax
test eax, eax
jz .!    


Now, I challenge you to give one logical reason for writing code this way. "Because Hutch said so" Smile It's faith-based programming; there is no reason, just believe.

Quote:
Another non assembly feature is to call subroutines by their names - it is clearly feature of the HLLs
Just the opposite is true. Real LL ASM is "call x" direct; whereas stdcall/invoke is a HL calling convention that specifies order of parameters. And this statement is by one who recommends using HL compilers instead of FASM: "If you want HL features, use a C++ compiler". I use strictly FASM and I think we should take advantage of its powerful macro features.

In case you didn't know, Steve Hutchesson ("Hutch") was the businessman for Microsoft/MASM who presented the original stdcall/invoke prefixes in the 90s when programmers discovered how to use ASM for Windows. With my macros, these pointless prefixes are no longer needed.

I think John has personal reasons for using call prefixes; ie, he doesn't want to go through his library and replace all appearances (Ctrl+H) of stdcall/invoke with NOTHING; therefore, everyone else should have to use them in their code. I predict that John will be using HL variable declarations someday. Who was the first to present HL variables/arrays/structures and countless other unique syntaxes? Me.

Z77 is the evolution of technology. His stale IDE macros are history!
Post 27 Jan 2013, 22:24
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 28 Jan 2013, 01:09
Oh, and look at the trash he calls ASM that he just posted.

First, John attacks Randall Hyde and says:
Quote:
Randall hyde sucks
Quote:
he caused more harm to the assembly language programming than any HLL
Quote:
assembly syntax in its classic, line based form is more readable than any "character stream" syntax - like C or Pascal
Quote:
I always try to keep the pure assembly syntax of my macros in the form


Then he posts this garbage (real/pure ASM?!):
Code:
stdcall Create, CButton 
execute [frmMain], TWindow.AddChild, ebx 
stdcall Set, ebx, TButton.width, 100 
stdcall Set, ebx, TButton.heihgt, 100 
stdcall Set, ebx, TButton.Caption, 'My button' 
stdcall Set, ebx, TButton.OnClick, ButtonClick 
stdcall Set, ebx, TButton.Visible, TRUE    


Finally, he takes shots at me. Now, prepare to be destroyed by the master of syntaxes... Twisted Evil

Code:
; rotate 'r'ight (90) or 'l'eft (270)

function rotate.image, image, way
locals x, y, w, h, p, s, col, row
let eax=[image], [s]=[?image.p+eax],\
 [w]=[?image.w+eax], [h]=[?image.h+eax]
try [p]=scratch [h], [w] ; w/h reversed
.if [way]='r' ; right, 90
  let eax=[h], eax--, [col]=eax
  .loop [y]=0 to [h]
    .loop [x]=0 to [w]
      let eax=[x], eax*[h], eax+[col], eax<<2,\
       eax+[p], edx=[y], edx*[w], edx+[x], edx<<2,\
      edx+[s], [eax]=[edx]
    .endl
    let [col]--
  .endl
.else.if [way]='l' ; left, 270
  let [col]=0
  .loop [y]=0 to [h]
    let eax=[w], eax--, [row]=eax
    .loop [x]=0 to [w]
      let eax=[row], eax*[h], eax+[col], eax<<2,\
       eax+[p], edx=[y], edx*[w], edx+[x], edx<<2,\
      edx+[s], [eax]=[edx], [row]--
    .endl
    let [col]++
  .endl
.end
end.scratch [image]
let eax=[image],\ ; adjust location
 edx=[?image.x+eax], ecx=[w], ecx>>1, edx+ecx,\
 ecx=[h], ecx>>1, edx-ecx, [?image.x+eax]=edx,\
 edx=[?image.y+eax], ecx=[h], ecx>>1, edx+ecx,\
 ecx=[w], ecx>>1, edx-ecx, [?image.y+eax]=edx
endf

; draw arbitrary line from x1/y1 to x2/y2

function draw.line.a, x1, y1, x2, y2, c
locals i, x, y, px, py, dx, dy
let eax=[x2], eax-[x1], [dx]=eax,\
 ecx=[y2], ecx-[y1], [dy]=ecx,\
 eax>>1, [x]=eax, ecx>>1, [y]=ecx,\
 [px]=[x1], [py]=[y1]
vga.xy [px], [py]
let [eax]=[c], ecx=[dy]
.if [dx]>ecx
  .loop [i]=0 to [dx]
    let eax=[y], eax+[dy], [y]=eax
    .if eax>=[dx]
      let eax=[dx], [y]-eax, [py]++
    .end
    let [px]++
    draw.pixel [px], [py], [c]
  .endl
.else
  .loop [i]=0 to [dy]
    let eax=[x], eax+[dx], [x]=eax
    .if eax>=[dy]
      let eax=[dy], [x]-eax, [px]++
    .end
    let [py]++
    draw.pixel [px], [py], [c]
  .endl
.end
endf

; size pixel array using "nearest neighbor"

function size.image, image, w, h
locals i, j, p, s, x1, y1, w1, h1, x2, y2
let eax=[image], [s]=[?image.p+eax],\
 [w1]=[?image.w+eax], [h1]=[?image.h+eax]
try [p]=scratch [w], [h]
; ratio=(size*64k)/size
let eax=[w1], eax<<16, eax/[w], [x1]=eax,\
 eax=[h1], eax<<16, eax/[h], [y1]=eax
.loop [i]=0 to [h]
  .loop [j]=0 to [w]
    ; offset=(n*ratio)/64k
    let eax=[j], eax*[x1], eax>>16, [x2]=eax,\
     eax=[i], eax*[y1], eax>>16, [y2]=eax
    ; destiny[(i*w2)+j]=source[(y2*w1)+x2]
    let eax=[i], eax*[w], eax+[j], eax<<2,\
     eax+[p], ecx=[y2], ecx*[w1], ecx+[x2],\
    ecx<<2, ecx+[s], [eax]=[ecx] ; *p=*s
  .endl
.endl
end.scratch [image]
endf

; size by percentage (integer)

function size.image.p, image, p
locals w, h, iw, ih
let eax=[image],\
 [iw]=[?image.w+eax], [ih]=[?image.h+eax],\
 eax=[iw], eax*[p], ecx=100, eax/ecx, [w]=eax,\
 eax=[ih], eax*[p], ecx=100, eax/ecx, [h]=eax
size.image [image], [w], [h]
endf

; mirror; flip 'h'orizontal, 'v'ertical
; or 'd'iagonal

function mirror.image.h, image
locals x, y, w, h, p, s
let eax=[image], [s]=[?image.p+eax],\
 [w]=[?image.w+eax], [h]=[?image.h+eax]
try [p]=scratch [w], [h]
.loop [y]=0 to [h]
  .loop [x]=0 to [w]
    ; p[x+(y*w)]=s[(w-x-1)+(y*w)]
    let edx=[w], edx-[x], edx--, ecx=[y],\
     ecx*[w], edx+ecx, edx<<2, edx+[s],\
     eax=[x], eax+ecx, eax<<2, eax+[p],\
    [eax]=[edx]
  .endl
.endl
end.scratch [image]
endf

function mirror.image.v, image
locals y, w, h, p, s
let eax=[image], [s]=[?image.p+eax],\
 [w]=[?image.w+eax], [h]=[?image.h+eax]
try [p]=scratch [w], [h]
.loop [y]=0 to [h]
  ; memory.copy &p[y*w], &s[(h-y-1)*w], w*4
  let edx=[h], edx-[y], edx--, edx*[w],\
   edx<<2, edx+[s], eax=[y], eax*[w],\
   eax<<2, eax+[p], ecx=[w], ecx<<2
  memory.copy eax, edx, ecx
.endl
end.scratch [image]
endf

; draw image from 2D graph of images - for
; sprites, projectiles, explosions, etc.
; cell is drawn at image.x/y. parameters
; x/y = cell offset inside image.
; w/h = cell size

function draw.image.cell, image, x, y, w, h
locals i, p, ix, iy, iw, ih, wb, b, key
let eax=[image],\
 [ix]=[?image.x+eax], [iy]=[?image.y+eax],\
 [iw]=[?image.w+eax], [ih]=[?image.h+eax],\
 [p]=[?image.p+eax], [key]=[?image.key+eax]
; image w in bytes
let eax=[iw], eax<<2, [wb]=eax
; p=&image[(iw*h*y*4)+(x*w*4)]
let eax=[iw], eax*[h], eax*[y], eax<<2,\
 ecx=[x], ecx*[w], ecx<<2, eax+ecx,\
 eax+[p], [p]=eax, ecx=[iy], ecx+[h], [b]=ecx
.loop [i]=[iy] to [b]
  draw.scanline [p], [ix], [i], [w], [key], 0
  let ecx=[p], ecx+[wb], [p]=ecx
.endl
endf

; extract rgb components from color
; parameters: c, &r, &g, &b. r/g/b are addresses

function get.rgb, c, r, g, b
let eax=[c],\
ecx=eax, ecx>>16, ecx&0FFh, edx=[r], [edx]=ecx,\
ecx=eax, ecx>>8, ecx&0FFh, edx=[g], [edx]=ecx,\
ecx=eax, ecx&0FFh, edx=[b], [edx]=ecx
endf

; mix a, b, n - alpha combination. n=0-255

function mix, a, b, n
locals sr, sg, sb, dr, dg, db
let eax=[a], edx=[b]

.if [n]=NO  ; if no alpha, return a
  return
.end
.if [n]>254 ; if maximum, return b
  let eax=edx
  return
.end

let \ ; extract r/g/b components
 ecx=eax, ecx>>16, ecx&0FFh, [sr]=ecx,\
 ecx=eax, ecx>>8, ecx&0FFh, [sg]=ecx,\
 ecx=eax, ecx&0FFh, [sb]=ecx,\
 ecx=edx, ecx>>16, ecx&0FFh, [dr]=ecx,\
 ecx=edx, ecx>>8, ecx&0FFh, [dg]=ecx,\
 ecx=edx, ecx&0FFh, [db]=ecx

let \ ; calculate deltas: (((s-d)*a)/256)+d
 eax=[sr], eax-[dr], eax*[n], eax>>8, eax+[dr],\
 ecx=[sg], ecx-[dg], ecx*[n], ecx>>8, ecx+[dg],\
 edx=[sb], edx-[db], edx*[n], edx>>8, edx+[db]

let \ ; construct RGB
 eax<<16, ecx<<8, eax|ecx, eax|edx
endf

; equal? return 0 if not

function text.equal, a, b
push esi edi
let eax=[a],\
 edx=[b]
.if [CASE]         ; sensitive
  @@:
   let \
   cl=[eax],\
   ch=[edx],\
   eax++, edx++
   cmp cl, ch      ; while *a++=*b++
   jne .r0
   or cl, ch       ; and both nonzero
  jnz @b
  or cl, ch        ; both must=0 at end
  jnz .r0
  jmp .e
.else              ; insensitive
  @@:
   let \
    esi=>[eax],\
    edi=>[edx],\
    cl=[IT+esi],\
    ch=[IT+edi],\
    eax++, edx++
   cmp cl, ch      ; while it[*a++]=it[*b++]
   jne .r0
   or esi, edi     ; and both nonzero
  jnz @b
  or esi, edi      ; both must=0 at end
  jz .e
.end
.r0: let eax=0
.e: pop edi esi
endf

; search for text. if a contains b. return
; address of first/next appearance or 0
; if none

function text.search, a, b
locals s
push ebx esi edi
let eax=[a], edx=[b]
.if [CASE]            ; sensitive...
  let esi=edx
  .sl:
   let ch=[edx]
   @@:
    let cl=[eax],\
     eax++
    test cl, cl       ; if *a=0
    jz .r0
    cmp cl, ch        ; while *a++!=*b
   jne @b
   let eax--,\        ; save start address
    [s]=eax
   @@:
    let cl=[eax],\
     ch=[edx],\
     eax++, edx++
    test ch, ch       ; if *b=0
    jz .r1
    cmp cl, ch        ; while *a++=*b++
   je @b
   @@:
    let eax--,\
    edx=esi
  jmp .sl
.else                 ; insensitive...
  let ebx=edx,\
   esi=eax, edi=edx
  .il:
   let edi=>[edx],\
    ch=[IT+edi]
   @@:
    let esi=>[eax],\
     cl=[IT+esi],\
     eax++
    or esi, esi       ; if *a=0
    jz .r0
    cmp cl, ch        ; while it[*a++]!=it[*b]
   jne @b
   let eax--, [s]=eax ; save start address
   @@:
    let esi=>[eax],\
     edi=>[edx],\
      cl=[IT+esi],\
      ch=[IT+edi],\
     eax++, edx++
    test edi, edi     ; if *b=0
    jz .r1
    cmp cl, ch        ; while it[*a++]=it[*b++]
   je @b
   let eax--, edx=ebx
  jmp .il
.end
.r0: let eax=NO
 jmp @f
.r1: let eax=[s]
@@:
 pop edi esi ebx
endf

macro zero.bit v, i { ; v&=~(1<<i)
let eax=1, ecx=i, eax<<cl, not eax, v&eax
}

macro set.nibble v, i, n { ; v|=(n<<(i*4))
let eax=v, ecx=i, edx=n, ecx<<2, edx<<cl,\
eax|edx, v=eax
} 

; create AA.BB.CC.DDb BIT structure

function quadruplet, a, b, c, d
let eax=[a], eax<<6, ecx=[b], ecx<<4,\
edx=[c], edx<<2, eax|ecx, eax|edx, eax|[d]
endf

; versatile align n/umber by power of 2

; return n aligned to p in eax. in ecx,
; return the quantity to add to make n
; divisible by p. algorithm:

; n+(((p-1)-(n+p-1))&(p-1))

function align.n, n, p
let ecx=[p], ecx-1, edx=[n], edx+ecx, eax=ecx,\
eax-edx, eax&ecx, ecx=eax, edx=[n], eax+edx
endf    


Last edited by uart777 on 02 Feb 2013, 15:23; edited 2 times in total
Post 28 Jan 2013, 01:09
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 28 Jan 2013, 05:10
It is a matter of taste.
Some ASM coders use macros heavily, and some can't stand them.
It is like a war within C coders where to put { and }.
In other words, useless waste of time.
Post 28 Jan 2013, 05:10
View user's profile Send private message Send e-mail Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 28 Jan 2013, 07:21
So, uart777, in order to have your own opinion, you have to disprove my, are you?
Post 28 Jan 2013, 07:21
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 28 Jan 2013, 13:00
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 21:50; edited 1 time in total
Post 28 Jan 2013, 13:00
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 28 Jan 2013, 15:14
hallo people,
AsmGuru62 wrote:
It is a matter of taste.
Some ASM coders use macros heavily, and some can't stand them.

of course,yes. you understate it a bit though. it's about
an entirely new language. a macro language, as stated from uart
Quote:
I merely offer syntaxes to programmers who are looking for alternatives and don't want to use HL compilers like C++/C#/Java
you may not like that syntax as in uart's code. on the contrary, if it
would fit eventually your taste, would you avoid it because macro-ed ?
wouldnt you like writing something like FORTH or COBOL but compiled with fasm ? FORTH and COBOL have a huge audience yet:
consider now their syntax relying purely on fasm instead of those HLL above! you can figure it out.

please, dont forget that opponents to a macro-language as favourable people assume fasm will not break that macro-syntax in future version of it.

afaik, on board, this from uart is a concrete try at an exaustive macro language, from now up
F(asm) M(acro) L(anguage) read it: "female" Very Happy
i will open a new thread about it in the next days, but the subject is plain:
female

Cheers,
Very Happy

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 28 Jan 2013, 15:14
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 28 Jan 2013, 16:47
I would use macros gladly -- if only I could read his (uart777) code!
I can't -- my brain is trained by decades of coding in a "usual" way.
I use macros in my coding quite a lot, but only small macros, which
do not try to "re-design" the language. Like these nice macros for taking
the size(s) of a rectangle:
Code:
macro WRect r32,pRect
{
    mov       r32, [pRect + RECT.right]
    sub       r32, [pRect + RECT.left]
}
macro HRect r32,pRect
{
    mov       r32, [pRect + RECT.bottom]
    sub       r32, [pRect + RECT.top]
}
    

Or some macros to make/release stack room:
Code:
macro StkAlloc r32,bytes
{
    sub       esp, bytes
    mov       r32, esp
}
macro StkFree bytes
{
    add       esp, bytes
}
    

Or for CALLBACK entry/exit:
Code:
macro Prolog
{
    push      ebp
    mov       ebp, esp
    push      ebx esi edi
}
macro Epilog
{
    pop       edi esi ebx ebp
}
    

And my IDE auto-completes macros with 3 or even 2 characters typed.
So, code writes itself pretty quick.

Now, for exercise, lets look at the code for extracting RGB values from a register (posted above in "function get.rgb"):

- It loads into EAX the full COLORREF value.
- It applies AND to mask out some bits
- It applies SHIFT to put those bits to the right place.

And it goes three times like that to extract all color intensities.
However, there is an instruction, which allows to do it in fewer steps:
Code:
movzx   eax, cl
mov     [RED], eax

shr     ecx, 8
movzx   eax, cl
mov     [GREEN], eax

shr     ecx, 8
movzx   eax, cl
mov     [BLUE], eax
    

It is not an attempt to discredit uart's code - I am just saying that macros
will limit the amount of things a coder can do. But they allow to write code fast and that is very important.

If only uart had a macro for MOVZX!
Smile
Post 28 Jan 2013, 16:47
View user's profile Send private message Send e-mail Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 28 Jan 2013, 16:56
Quote:
Guru: In other words, useless waste of time
Yeah, but it makes some people think, examine their style and helps them improve in certain ways. Maybe you think things are just fine the way they are, but to me, the evolution of programming styles is of utmost importance.

We ASM programmers don't stand a chance to compete with the production of modern HL C#/Java programmers who make real-life applications and games. As time goes by, more ASM programmers give into the temptation of C#/Java and I fear that the community is slowly becoming extinct. However, with improved HL syntaxes and true portability (Universal ASM), we can increase production speed dramatically, start making real programs and games and this will bring in modern programmers.

For example, here's a program I've been working on for the last week, an ASM version of the SpaceBrush art program I originally made in C: Image

I think examples like this have potential to build the FASM community to 10+ times its current size.

hopcode: I'd love to see your ideas for HL features ("Macros" forum).
Post 28 Jan 2013, 16:56
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 28 Jan 2013, 17:09
Quote:
I would use macros gladly -- if only I could read his (uart777) code!
LOL Smile It definitely takes practice. My HL features are not quite perfected yet; in fact, I have a long 2-DO list of features that are not currently supported. Not suggesting that everyone use my code except for reference to general ideas and algorithms. We should invent new syntaxes and not be scared of ideas, change and evolution. But I think most people will want to use HL variable declarations: integer a,b,c,d,e,f,g
Post 28 Jan 2013, 17:09
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12742
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 28 Jan 2013, 17:36
i believe, the goal is, easiest, simplest way to read code, to comprehend, to understand, and to expand.

less rules is best practice,
more rules = more complex

things should just get expanded from base concept, consistent,

ah, my grand theory of programming language.
Post 28 Jan 2013, 17:36
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 28 Jan 2013, 19:32
AsmGuru62 wrote:
It is not an attempt to discredit uart's code - I am just saying that macros will limit the amount of things a coder can do. But they allow to write code fast and that is very important.
If only uart had a macro for MOVZX!
eh, dont worry, your posts are ok and plain. i have perhaps mis-term-ed something
in my posts. i mean ML in a wider and external point of view:

take this: there is a subtle difference among asm-programmers
an HLL programmers, those people overbloating everyday on comp.lang.c, for example.

they have almost the same problems/questions of asm-programmers. those issues cannot be resolved elegantly with their C/C++ toolchains
but you dont find such overbloating on Forth or Cobol forums, whenever (or just because) they are aware their syntax is not so "powerful" as in other
languages. the reason is: the syntax!

asm-programmers share the same problems of those C-people, but with an advantage:
they may, for their nature of programming bits and bytes, create more and more easy ways, new languages using powerful tools, example: fasm.

in fact, about the MOVZX macro, one may think at a
"z.let" syntax, where z overloads and redefines the let macro for zero extension.
this is a banal example. write it the way you likke but
every choice in the syntax must be weighed with hi accuracy.

i think uart's position has a double aspect, and lot of good reasons:
1) the syntax matter (whoose efficacy one may doubt upon)
2) the quest of a new syntax (using a powerful tool)
a good reason is when he tells about asm-programmers.

he is addressing the concept i explained above. that subtle difference, again:
C and some other HLL cannot evolve in something better,
think them as the perfect fly from the dinosaurs's age.
and all new syntaxes come coded from that C-doggystyle-of-coding.
weirdness in new syntax,like JAVA,LUA,JAVASCRIPT,REBOL?,RUBY?,D?,GO?,.NET, created with C tools, i find them yet more stupid if compared with uart's syntax.
this is taste too, indeed!

that is what i mean about understimating uart's quest. it's plain now.

take it positive! if you code a programming language in assembly using fasm, whenever bad, it show 100% granted always something of the geniality of fasm in it, whenever bad: one of the transmission-capabilities of open-source ? N.Wirth was right ?

but an ML with fasm it's not that easy: on the contrary of what one may think, restrictions are inherithed directly from fasm.

ASM can evolve, yes, thanks fasm. i didnt say NASM or MASM. i say fasm.
think at the same macros you posted above: you may improve it a lot easily, extend them eventually for 16/32/64bit, with fasm.

again, one may not accept uart's syntax, but his position is clear,
and i agree with him 100%, because he rebels himself to stupid standards,
because me and lot of other people will never use C & C. tools, etc.

sorry people,
time is over for me with this post in english, pfeee..,

Cheers,
Very Happy

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 28 Jan 2013, 19:32
View user's profile Send private message Visit poster's website Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 28 Jan 2013, 21:17
Guru: Your code assumes r/g/b are global variables.

let supports movsx (a=>b) and can easily be edited to support movzx (a=>>b ; ?) and even generate code for other CPUs (let ?r0=[x], ?r1=[y], ?r0+?r1, [z]=?r0)...
Code:
;;;;;;;;;;;;;;;;;;;;; LET ;;;;;;;;;;;;;;;;;;;;;;;;

; perform HL assignment/s/operation/s

macro let [p] {
forward
define ?s 0

; a=&[b], lea r, [b]

match =0 a==&b, ?s p \{
 lea a, b
 define ?s 1
\}

; a=>[b], movsx r, byte [b]

match =0 a==>b, ?s p \{
 movsx a, byte b
 define ?s 1
\}

; a=b, mov or push/pop or xor

match =0 a==b, ?s p \{
 if a eqtype [] & b eqtype [] ; m=m
  push dword b
  pop dword a
 else
  if b eq 0 & \
   a in <eax,ecx,edx,ebx,esi,edi>
    xor a, a
  else
   mov a, b
  end if
 end if
 define ?s 1
\}

; increment/decrement

match =0 a--, ?s p \{
 dec a
 define ?s 1
\}

match =0 a++, ?s p \{
 inc a
 define ?s 1
\}

; add/subtract

match =0 a-b, ?s p \{
 if b eq 1
  dec a
 else
  sub a, b
 end if
 define ?s 1
\}

match =0 a+b, ?s p \{
 if b eq 1
  inc a
 else
  add a, b
 end if
 define ?s 1
\}

; multiply/divide. 2/4 will be optimized
; and replaced with signed shift 1/2

match =0 a*b, ?s p \{
if b eq 2
 sal a, 1
else if b eq 4
 sal a, 2
else
 imul a, b
end if
define ?s 1
\}

; for idiv, only eax/n is allowed.
; n must be m, ecx or 2/4 (shr). example:
; eax=n/123 may be written as - let \
; eax=n, ecx=123, eax/ecx - instead of
; 4 separate lines

match =0 =eax/n, ?s p \{
if n eq 2
 sar eax, 1
else if n eq 4
 sar eax, 2
else
 cdq
 idiv n
end if
 define ?s 1
\}

; shifts

match =0 a>>>b, ?s p \{ shr a, b
define ?s 1 \}
match =0 a<<b, ?s p \{ sal a, b
define ?s 1 \}
match =0 a>>b, ?s p \{ sar a, b
define ?s 1 \}

; binary and/or

match =0 a&b, ?s p \{ and a, b
define ?s 1 \}
match =0 a|b, ?s p \{ or a, b
define ?s 1 \}

; neg/not unary prefixes

match =0 =neg a, ?s p \{
 neg a
 define ?s 1
\}

match =0 =not a, ?s p \{
 not a
 define ?s 1
\}

verify.syntax .let
}    


hopcode: Most programmers here are not experienced with the macros like we are so they don't know that it's possible to create a HL compiler within FASM. Those who say "I don't use macros" simply don't know how or don't understand them well enough.

hopcode wrote:
Quote:
again, one may not accept uart's syntax, but his position is clear, and i agree with him 100%, because he rebels himself to stupid standards, because me and lot of other people will never use C & C. tools, etc.


http://www.youtube.com/watch?v=8rwsuXHA7RA


Last edited by uart777 on 28 Jan 2013, 23:30; edited 4 times in total
Post 28 Jan 2013, 21:17
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 28 Jan 2013, 22:58
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 21:49; edited 1 time in total
Post 28 Jan 2013, 22:58
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 28 Jan 2013, 23:05
Quote:
HaHa: I know absolutely nothing about macros.
vid's FASM macro tutorials: http://bos.asmhackers.net/docs/FASM%20tutorial/preproc.html

push/pop can accept multiple operands in FASM: pop a b c
Post 28 Jan 2013, 23:05
View user's profile Send private message Reply with quote
Georgian



Joined: 10 Apr 2015
Posts: 9
Location: Georgia, Batumi
Georgian 26 Apr 2015, 13:50
Hello everyone Smile. I am a totally new in assembler. not in fasm or masm or something like thet. I am totally new to assembler of all sorts, types and so on. Smile. so which book will you recommend me to start? I mean from which book is it easy to transfer your self and knowledge to FASM. where I should start. and yes I know here is programmers manual. this wouldn't help you If you don't have past assembler experience. So HELP ME TO BECOME FASSEMBLER PROGRAMMER. SmileSmile
Post 26 Apr 2015, 13:50
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 26 Apr 2015, 16:11
@Georgian - Try with Intel® 64 and IA-32 Architectures Software Developer Manuals - It is a hard read, because of the big volume, but the books are useful.

Also, try to learn-to-program-by-programming - FASM package contains examples, that you can compile, run in the debugger and modify.
Post 26 Apr 2015, 16:11
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Georgian



Joined: 10 Apr 2015
Posts: 9
Location: Georgia, Batumi
Georgian 26 Apr 2015, 17:34
JohnFound wrote:
@Georgian - Try with Intel® 64 and IA-32 Architectures Software Developer Manuals - It is a hard read, because of the big volume, but the books are useful.

Also, try to learn-to-program-by-programming - FASM package contains examples, that you can compile, run in the debugger and modify.


I understood, BUT, for example I need a manual from scratch and I can't find it for FASM. so can I start learning TASM or NASM and then switch for FASM. All what I need is a beginners manual. manual for DUMMIES

Hope you understand what I mean Smile

_________________
გაუმარჯოს
Post 26 Apr 2015, 17:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.