;---------------------------------------------------------------------
; mpush eax,ebx,ecx...
; mpop eax,ebx,ecx...

%macro push 1-*
%rep %0
	push %1
%rotate 1
%endrep
%endmacro

%macro pop 1-*
%rep %0
%rotate -1
	pop %1
%endrep
%endmacro

;---------------------------------------------------------------------
; repeat ... until <cc>

%macro repeat 0
%push repeat
%$repeat:
%endmacro

%macro until 1
	j%-1 %$repeat
%pop
%endmacro

;---------------------------------------------------------------------
; begin <test> while <cc> ... wend

%macro begin 0
%push begin
%$begin:
%endmacro

%macro while 1
	j%-1 near %$wend
%endmacro

%macro wend 0
	jmp near %$begin
%$wend:
%pop
%endmacro

;---------------------------------------------------------------------
; if <cc> ... else ... endif

%macro if 1
	%push if
	j%-1 %$ifnot
%endmacro

%macro else 0
	%ifctx if
		%repl else
		jmp short %$ifend
		%$ifnot:
	%else
		%error "'else' without 'if'"
	%endif
%endmacro

%macro endif 0
	%ifctx if
		%$ifnot:
		%pop
	%elifctx else
		%$ifend:
		%pop
	%else
		%error "'endif' without 'if' or 'else'"
	%endif
%endmacro
