在 NASM 中断言两个标签相隔小于 N 字节

Assert that two labels are less than N bytes apart in NASM

在NASM中,我可以在编译时断言两个标签之间的距离小于 N 字节吗?

即,类似于:

label1:
; some code
; goes here
label2:

; here I want to check that the distance between label1 and label2 is less than 50 bytes...

应该在编译时发现问题,最好是带有可理解的错误消息。

假设标签出现在检查之前,这应该有效:

label1:
resb 50  ; For testing purposes
label2:

%if (label2 - label1) >= 50
%error "Blah blah blah"
%endif