Skip to content

Instantly share code, notes, and snippets.

@andurilan
Created February 18, 2019 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andurilan/6a08557b321fc3cd0acacbee51eaee0b to your computer and use it in GitHub Desktop.
Save andurilan/6a08557b321fc3cd0acacbee51eaee0b to your computer and use it in GitHub Desktop.
Continuum Macro
;==================================================================================================================
; PlainOS | Copyright (C) 2008-2019 Lexeme
; ==================================================================================================================
;
; PlainOS Installation -----------------------------------------------------------------------------------------------------------------------------------------------
; ==================================================================================================================
;
; Dependency Injection Macros ------------------------------------------------------------------------------------------------------------------------------------
%include "macros/di.asm"
;
; Terminal Macro ----------------------------------------------------------------------------------------------------------------------------------------------------
%macro . 0-*
%%hmm: db "[.:", %0, "]", 0
%endmacro
;
; Continuum Macro ----------------------------------------------------------------------------------------------------------------------------------------------------
%macro ... 0-*
%if %0 = 16
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16
%elif %0 = 15
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15
%elif %0 = 14
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14
%elif %0 = 13
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13
%elif %0 = 12
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12
%elif %0 = 11
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11
%elif %0 = 10
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10
%elif %0 = 9
and... %1, %2, %3, %4, %5, %6, %7, %8, %9
%elif %0 = 8
and... %1, %2, %3, %4, %5, %6, %7, %8
%elif %0 = 7
and... %1, %2, %3, %4, %5, %6, %7
%elif %0 = 6
and... %1, %2, %3, %4, %5, %6
%elif %0 = 5
and... %1, %2, %3, %4, %5
%elif %0 = 4
and... %1, %2, %3, %4
%elif %0 = 3
and... %1, %2, %3
%elif %0 = 2
and... %1, %2
%elif %0 = 1
and... %1
%endif
%endmacro
;
; Continuum Macro ----------------------------------------------------------------------------------------------------------------------------------------------------
%macro and... 0-*
%if %0 > 0
%define macro .
%assign arity 0
%assign remaining %0
%ifid %1 && %ifmacro %1
%assign remaining remaining-1
%define macro %1
%ifnum %2
%assign arity %2
%assign remaining remaining-1
%assign parity remaining-arity
%if arity = 15
macro %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16
%elif arity = 14
macro %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15
%elif arity = 13
macro %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14
%elif arity = 12
macro %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13
%elif arity = 11
macro %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12
%elif arity = 10
macro %2, %3, %4, %5, %6, %7, %8, %9, %10, %11
%elif arity = 9
macro %2, %3, %4, %5, %6, %7, %8, %9, %10
%elif arity = 8
macro %2, %3, %4, %5, %6, %7, %8, %9
%elif arity = 7
macro %2, %3, %4, %5, %6, %7, %8
%elif arity = 6
macro %2, %3, %4, %5, %6, %7
%elif arity = 5
macro %2, %3, %4, %5, %6
%elif arity = 4
macro %2, %3, %4, %5
%elif arity = 3
macro %2, %3, %4
%elif arity = 2
macro %2, %3
%elif arity = 1
macro %2
%else
macro
%endif
%rotate parity
%ifid %1 && %ifmacro %1
%if parity = 16
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16
%elif parity = 15
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15
%elif parity = 14
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14
%elif parity = 13
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13
%elif parity = 12
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12
%elif parity = 11
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11
%elif parity = 10
and... %1, %2, %3, %4, %5, %6, %7, %8, %9, %10
%elif parity = 9
and... %1, %2, %3, %4, %5, %6, %7, %8, %9
%elif parity = 8
and... %1, %2, %3, %4, %5, %6, %7, %8
%elif parity = 7
and... %1, %2, %3, %4, %5, %6, %7
%elif parity = 6
and... %1, %2, %3, %4, %5, %6
%elif parity = 5
and... %1, %2, %3, %4, %5
%elif parity = 4
and... %1, %2, %3, %4
%elif parity = 3
and... %1, %2, %3
%elif parity = 2
and... %1, %2
%elif parity = 1
and... %1
%endif
%endif
%endif
%else
%rep %0
db %1
%rotate 1
%endrep
%endif
%endif
%endmacro
; ==================================================================================================================
; EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment