Skip to content

emit code spilled outside a single-statement function #272

Open
@YashasSamaga

Description

@YashasSamaga

#emit spills the instructions before the function

func()
	#emit NOP
	#emit CONST.pri 321
	#emit NOP
	#emit CONST.pri 123
	return;
	
main () {
	func();
}

produces

CODE 0	; 0
;program exit point
	halt 0

	nop 
	const.pri 141
	nop 
	const.pri 7b
	proc	; func
	; line 6
	; line 6
	break	; 24
	zero.pri
	retn

	proc	; main
	; line 8
	; line 9
	break	; 34
	push.c 0
	call .func
	;$exp
	zero.pri
	retn


STKSIZE 1000

__emit (single instruction) spills it after (except for the first one) the function

func()
	__emit NOP;
	__emit CONST.pri 321;
	__emit NOP;
	__emit CONST.pri 123;
	
main () {
	func();
}

produces


CODE 0	; 0
;program exit point
	halt 0

	proc	; func
	; line 2
	; line 2
	break	; c
	nop
	;$exp
	zero.pri
	retn

	const.pri 141
	nop
	const.pri 7b
	proc	; main
	; line 7
	; line 8
	break	; 34
	push.c 0
	call .func
	;$exp
	zero.pri
	retn


STKSIZE 1000

__emit {} doesn't even compile

func()
 	__emit {
		nop
		CONST.pri 321
		NOP
		CONST.pri 123
	}

error 055: start of function body without function header

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions