flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Please help: JE ret |
Author |
|
okasvi 04 Sep 2006, 16:52
Quote: Going off on a tangent, must I use commas between the parameters of a macro e.g. push ax,bx,cx,dx instead of push ax bx cx dx? No, push 0h esi 0h edi seems to be working |
|||
04 Sep 2006, 16:52 |
|
vid 04 Sep 2006, 19:26
1. there is no "ret" isntruction, i believe you mean "retn". "ret" is pseudo-opcode (macro in FASM) to return from current context (eg. procedure)
to your problem: you may find way to solution here |
|||
04 Sep 2006, 19:26 |
|
UCM 04 Sep 2006, 23:54
Yes, there is the "ret" instruction. In fact, it is not an instruction, but not implemented as a macro.
|
|||
04 Sep 2006, 23:54 |
|
LocoDelAssembly 05 Sep 2006, 01:36
But it's true that "ret" is implemented as a macro in PROC context.
|
|||
05 Sep 2006, 01:36 |
|
wht36 05 Sep 2006, 05:47
Hmm, so ret is not an instruction... does that mean if I try to implement my ret macro something nasty would happen and I should just use something like jmp @f instead of jmp .ret?
Sigh... what a pity, I thought something like JMP RET would be much clearer than JMP @F |
|||
05 Sep 2006, 05:47 |
|
vid 05 Sep 2006, 07:33
i think tomasz explained it somewhere, that ret should be return from current context, it's not defined in manuals (not sure about this), and implemented "ret"="retn" for compatibility with other assemblers, and because people ought to use it.
those @@@/@@f/@@b macros showed you way how you can solve your problem with macros. analogy, overload "ret" with something like "@@@", and overload "jmp ret" with something that compares distance to neares preceding ret (@@b) and nearest following ret (@@f). Of course you need more checks (no preceding/following ret) etc. |
|||
05 Sep 2006, 07:33 |
|
wht36 07 Dec 2010, 15:31
Not fully tested, but I think one can simulate JE ret, jb ret4 etc with the macros below
Code: irp cond, mp, a, b, be, c, e, l, le, o, s, z, na, nb, nbe, nc, ne, nl, nle, no, ns, nz { macro j#cond addr { j equ addr match =ret,addr { j equ ..ret \\} match =ret4,addr { j equ ..ret4 \\} match =ret8,addr { j equ ..ret8 \\} match =ret12,addr { j equ ..ret12 \\} j#cond j \} } macro ret n { ; macro to create a label for each ret instruction so one can use e.g. jmp .ret4 & je .ret match =..ret#n,..ret#n {..ret#n:\} ; create the label .ret if .ret was not defined previously so that forward jumps to .ret will work local ..z ; create anonymous label ..z for each ret ..z: ret n ; make the anonymous label specific to n match ,n { ..ret equ ..z \} ; assign the label to .ret if there is no n specified match x,n { ..ret\#x equ ..z \} ; else assign .retn to the label } |
|||
07 Dec 2010, 15:31 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.