; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; ::: HLA include file for fasmg
;
; By: Jessé Gonçalves
; Start Date: 2025 05 03
;
; (The ugly variable and label names here are intentionaly chosen
; so you can use the remaining beautiful ones in your code ;))
;
; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; ::: @@@ anonymous label macro
;
;  Update: I adopted my nasm approach after solving the BUG
;
;  Usage:
;
;  @@@          mov     rax, [mtvar]    ; @@@ is the anon label
;               test    al, -1
;               jp      @@b             ; @@b jumps to previous
;               js      @@f             ; @@f jumps to next
;               nop
;               lock add [mtvar], r12
;               ; ...
;  @@@          cmovc   esi, r15d
;               ; ...
;               ; ...
__lbl_count2_ = 1
define @@f? ..@@@_UL_2
macro @@@ line&
  __local_count_ = __lbl_count2_
  repeat 1, i:__local_count_
    define @@b? ..@@@_UL_#i
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @@f? ..@@@_UL_#i
  end repeat
  repeat 1, i:__lbl_count2_
    ..@@@_UL_#i: line
  end repeat
  __lbl_count2_ = __lbl_count2_ + 1
end macro
;
; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; ::: @@ anonymous label macro
;     Work similar to @@@, but it has 16 previous and 16 next labels
;  to jump (above and below), identified by the number (x)
;  at @bx and @fx
;  This is equal to my @@ macro at nasm assembler. Works identical,
;  including the know BUG:
;
;     @@    jmp    @f ; jump to the same line, instead of next
;     @@    nop
;           nop
;     @@    jmp    @b ; jump to '@@ nop' above, instead of same line
;           nop
;
;     The BUG is solved by using 2 counters (1 local 1 global),
;     and moving the "plot line" to the end, before increment
;     global counter!
;
;     ### DONE!: create 16 @fx and 16 @bx levels
;
;     Tip: @b = @b1 and @f = @f1 - For aesthetic purposes
;
__lbl_count_ = 16
define @f? ..@@_UL_16
define @f1? ..@@_UL_16
define @f2? ..@@_UL_17
define @f3? ..@@_UL_18
define @f4? ..@@_UL_19
define @f5? ..@@_UL_20
define @f6? ..@@_UL_21
define @f7? ..@@_UL_22
define @f8? ..@@_UL_23
define @f9? ..@@_UL_24
define @f10? ..@@_UL_25
define @f11? ..@@_UL_26
define @f12? ..@@_UL_27
define @f13? ..@@_UL_28
define @f14? ..@@_UL_29
define @f15? ..@@_UL_30
define @f16? ..@@_UL_31
macro @@ line&
  __local_count_ = __lbl_count_ - 15
  repeat 1, i:__local_count_
    define @b16? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b15? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b14? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b13? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b12? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b11? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b10? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b9? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b8? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b7? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b6? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b5? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b4? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b3? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b2? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @b1? ..@@_UL_#i
    define @b? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f1? ..@@_UL_#i
    define @f? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f2? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f3? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f4? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f5? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f6? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f7? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f8? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f9? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f10? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f11? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f12? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f13? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f14? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f15? ..@@_UL_#i
    ; display `i, 32
  end repeat
  __local_count_ = __local_count_ + 1
  repeat 1, i:__local_count_
    define @f16? ..@@_UL_#i
    ; display `i, 32
  end repeat
  repeat 1, i:__lbl_count_
    ..@@_UL_#i#: line
  end repeat
  __lbl_count_ = __lbl_count_ + 1
  ; display 32,32,10
  purge __local_count_
end macro
;
; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; :::    _code and _data and entry macros are to make code more
;     straight to the point and also compact
;
;
; macro entry label, line&   ; ### TODO ###
;   
; end macro
macro _rdata line&  ; Read only data segment
  segment readable
  line
end macro

macro _data line&   ; Read/write data segment
  segment readable writeable
  line
end macro

macro _code line&   ; Code segment
  segment readable executable
  line
end macro
;
; :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
