Hello everyone:

I am in search of a macro written in NASM that will perform the functions of the SWITCH/CASE C/C++ statements. Mammon wrote a macro some time ago that makes the rounds on the internet, and I have coded his macro, but it doesn't work. I can't understand why. If someone could share similar macro that does work, I would be grateful. Or, failing that, suggest any "bugs" to the Mammon code that have been identified.

Thanks,
Mark Allyn

How about a function table! No macro!

funcA:	mov	eax,1
	ret

funcB:	mov	eax,2
	ret

funcC:	mov	eax,3
	ret

funcTbl:	dd	funcA, funcB, funcC


;;; and in your code

	mov	eax,1

	cmp	eax,3
	jae	bypass

	call	cs:funcTbl[eax*4]

bypass:	ret
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.