Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pawndisasm: Fix 'switch' argument #236

Merged
merged 1 commit into from
Jan 7, 2018

Conversation

Daniel-Cortez
Copy link
Contributor

Fixes #179.
Test code:

native random(max);
main()
{
	static x;
	switch (random(1))
	{
		case 1: x = 1;
		default:x = 0;
	}
	#pragma unused x
}

pawndisasm output before this patch:

00000000  halt 00000000

00000008  proc 
0000000c  break 
00000010  break 
00000014  push.c 00000001
0000001c  push.c 00000004
00000024  sysreq.c 00000000	; random
0000002c  stack 00000008
00000034  switch 000000a0
0000003c  break 
00000040  const.pri 00000001
00000048  stor.pri 00000000
00000050  jump 00000080
00000058  break 
0000005c  zero 00000000
00000064  jump 00000080
0000006c  casetbl 00000001 00000058
                  00000001 0000003c
00000080  zero.pri 
00000084  retn 

Note the address after the switch instruction is incorrect, the case table (casetbl) is at 0000006c, not 000000a0.

Output after the patch:

00000000  halt 00000000

00000008  proc 
0000000c  break 
00000010  break 
00000014  push.c 00000001
0000001c  push.c 00000004
00000024  sysreq.c 00000000	; random
0000002c  stack 00000008
00000034  switch 0000006c
0000003c  break 
00000040  const.pri 00000001
00000048  stor.pri 00000000
00000050  jump 00000080
00000058  break 
0000005c  zero 00000000
00000064  jump 00000080
0000006c  casetbl 00000001 00000058
                  00000001 0000003c
00000080  zero.pri 
00000084  retn 

@Zeex Zeex merged commit 3ee2180 into pawn-lang:master Jan 7, 2018
@Zeex
Copy link
Contributor

Zeex commented Jan 7, 2018

Thanks.

@Daniel-Cortez Daniel-Cortez deleted the pawndisasm-patch branch January 7, 2018 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants