Beat it down, sooner or later it'll be done

Posted by s on Nov. 18, 2008, 11:05 p.m.

macro power op1,op2{

push ecx

mov eax,op1

mov ecx,op2

call POWER

pop ecx

}

POWER:

jcxz GTFOofpowerafterreturningone

push ebx

dec ecx

mov ebx,eax

@@:

mul ebx

loop @b

pop ebx

ret

GTFOofpowerafterreturningone:

mov eax,1

ret

So I decided stdcall can screw itself and I'd implement POWER to use a macro power to cover the calling convention. This allows me to ignore the stack all together. Maybe I'll expand op2 to allow for power towers

Well, here's a power tower climber macro

macro powertowerclimber op1,[ops]{

common

mov eax,op1

push ecx

forward

mov ecx,ops

call POWER

common

pop ecx

}

And I suppose if it really matters, the person can reverse the argument list themselves

And so I'll include the new factorial

macro factorial arg{

push ecx

mov ecx,arg

call FACTORIAL

}

factorial:

mov eax,1

@@:

mul ecx

loop @b

pop ecx

ret

Issue that has to be watched is making sure to not have on the caller side what the callee can do. In order to not have to pass information with the stack, I have to push the registers caller side but I can still pop them callee side. Perhaps I should include a solely 2 argument power function to save on that pop ecx?

So I'm thinking FASM would make a nice backend. I'm thinking of a language that defines itself in terms of ASM so that abstraction can range from ASM to whatever. Of course such a core would be done with Sexps, but perhaps then the Sexps system can be made into the backend of another layer of syntactic sugar

Comments

ESA 15 years, 5 months ago

Your blogs are becoming lonely with no comments. Where are plethi's completely irrelevant ones? Or Mu's?

Hello anyway. I like reading your code-related rambles if I can call them that

Mush 15 years, 5 months ago

Looks flat.

Mu6502 15 years, 5 months ago

Sexplaystation system?(I went a whole week with out the web,that's proof that I'm not a web addict)Right?

s 15 years, 5 months ago

Sexps=S-Expressions (->Lisp)

Mush, ASM is very one thing at a time

Hello