VOOZH about

URL: https://qiita.com/Stosstruppe/items/a3471675d9770864c94c

⇱ z88dk zcc バグと回避 #Z80 - Qiita


👁 Image
3

Go to list of users who liked

1

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@Stosstruppe

z88dk zcc バグと回避

3
Last updated at Posted at 2018-07-18

zcc - Frontend for the z88dk Cross-C Compiler - v12228-3adc863-20180704

  • 症状

for文でbreakを使うと挙動がおかしくなる。

test.c
/*
z88dk / WebMSX
zcc +msx -lndos -create-app -bntest test.c
*/

# include <stdio.h>

void main()
{
	for (int i = 0; i < 10; i++) {
		if (i >= 5) break;
		printf("%d\n", i);
	}
}
  • 回避策

変数宣言をfor文の外に出す。

test.c
/*
z88dk / WebMSX
zcc +msx -lndos -create-app -bntest test.c
*/

# include <stdio.h>

void main()
{
	int i;
	for (i = 0; i < 10; i++) {
		if (i >= 5) break;
		printf("%d\n", i);
	}
}
  • 症状

floatの比較がおかしい。

  • 回避策

条件をいろいろ変えてみる。

test.c
/*
z88dk / WebMSX
zcc +msx -lndos -lm -create-app -bntest test.c

PC6001V / cload, run
zcc +pc6001 -lm -create-app -subtype=32k -bntest test.c
*/

# include <stdio.h>

void main()
{
	float f = 0;

	if (4 < f) {
		printf("true\n");
	} else {
		printf("false\n");
	}

	if (f > 4) {
		printf("true\n");
	} else {
		printf("false\n");
	}
}

👁 WMSX Screen (2).png

👁 新しいビットマップ イメージ.png

3

Go to list of users who liked

1
6

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3

Go to list of users who liked

1