Skip to content

Commit 3810acb

Browse files
authored
Merge pull request #4 from kg68k/castlblmode
refactor: suppress msvc warnings
2 parents c968cb8 + 2d0c192 commit 3810acb

11 files changed

Lines changed: 74 additions & 75 deletions

File tree

src/analyze.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// 自動解析モジュール
33
// Copyright (C) 1989,1990 K.Abe, 1994 R.ShimiZu
44
// All rights reserved.
5-
// Copyright (C) 1997-2023 TcbnErik
5+
// Copyright (C) 2025 TcbnErik
66

77
#include <stdio.h>
88
#include <string.h>
@@ -152,7 +152,7 @@ static void printUndefinedInstruction(address pc) {
152152
// プログラム領域の終端をラベル登録する
153153
static void foundProgramEnd(address adrs) {
154154
if (search_label(adrs) == NULL) {
155-
regist_label(adrs, DATLABEL | UNKNOWN);
155+
regist_label(adrs, DATLABEL | (lblmode)UNKNOWN);
156156
}
157157
}
158158

@@ -347,7 +347,7 @@ static boolean analyzeInner(address start, analyze_mode mode) {
347347
disasm* code = &disp.code;
348348
CodeFlow flow;
349349
int orib = 0; // ori.b #??,d0 = $0000????
350-
void (*regoplbl)(disasm * code) = Dis.actions->registerOperandLabel;
350+
void (*regoplbl)(disasm* code) = Dis.actions->registerOperandLabel;
351351

352352
if (Dis.availableTextEnd <= start) {
353353
printReason("PCが有効なセクションを外れた。", start);
@@ -515,7 +515,7 @@ boolean analyze(address start, analyze_mode mode) {
515515

516516
if (!success) {
517517
charout('?');
518-
ch_lblmod(start, DATLABEL | UNKNOWN | FORCE);
518+
ch_lblmod(start, DATLABEL | FORCE | (lblmode)UNKNOWN);
519519
return FALSE;
520520
}
521521
charout('<');
@@ -533,12 +533,12 @@ static boolean branchToOdd(DisParam* disp, address start, address limit) {
533533

534534
if (Dis.acceptAddressError) {
535535
// -j: 奇数アドレスへの分岐を未定義命令と「しない」
536-
regist_label(code->jmp, DATLABEL | UNKNOWN);
536+
regist_label(code->jmp, DATLABEL | (lblmode)UNKNOWN);
537537
return TRUE;
538538
}
539539

540540
// 奇数アドレスへの分岐があればプログラム領域ではない
541-
ch_lblmod(start, DATLABEL | UNKNOWN | FORCE);
541+
ch_lblmod(start, DATLABEL | FORCE | (lblmode)UNKNOWN);
542542
not_program(start, MIN(code->pc, limit));
543543
return FALSE;
544544
}
@@ -561,7 +561,7 @@ static boolean branch_job(DisParam* disp, address start, analyze_mode mode,
561561
// 分岐先の領域を解析する
562562
if (!analyze(opval, mode) && mode != ANALYZE_IGNOREFAULT && !Dis.i) {
563563
// 分岐先がプログラム領域でなければ、呼び出し元も同じ
564-
ch_lblmod(start, DATLABEL | UNKNOWN | FORCE);
564+
ch_lblmod(start, DATLABEL | FORCE | (lblmode)UNKNOWN);
565565
not_program(start, MIN(disp->pc, limit));
566566
return FALSE;
567567
}
@@ -628,7 +628,7 @@ static boolean analyzeJump(DisParam* disp, CodeFlow* flow, address start,
628628
// 実際の分岐先は実行時のインデックスレジスタの値次第で、ラベルの場所が
629629
// プログラムではない可能性もあるので、解析はせずラベル登録だけに留める。
630630
// (README.txtの「参照されないラベル」と同様のケース)
631-
regist_label(code->jmp, DATLABEL | UNKNOWN);
631+
regist_label(code->jmp, DATLABEL | (lblmode)UNKNOWN);
632632
break;
633633
}
634634

@@ -703,17 +703,17 @@ static int analyzeRelativeTable(address table, opesize size,
703703
// (別のデータ形式かもしれないし、プログラム領域かもしれない)
704704
// ただしアドレス値だけで判定しているので確実とは言えない
705705
if (table == ptr)
706-
regist_label(ptr, DATLABEL | UNKNOWN | FORCE);
706+
regist_label(ptr, DATLABEL | (lblmode)UNKNOWN | FORCE);
707707
else
708-
regist_label(ptr, DATLABEL | UNKNOWN);
708+
regist_label(ptr, DATLABEL | (lblmode)UNKNOWN);
709709
break;
710710
}
711711

712712
#ifdef DEBUG_RELTBL_ADDRESS
713713
printReltblAddress(table, ptr, offs, label);
714714
#endif
715715
if (table != label) {
716-
regist_label(label, DATLABEL | UNKNOWN);
716+
regist_label(label, DATLABEL | (lblmode)UNKNOWN);
717717
}
718718
ptr += bytes;
719719

@@ -800,7 +800,7 @@ static int hasReltblData(address table) {
800800
// テーブルの解析は他の解析が終わって判明した限りのラベルが登録されてからとなる。
801801
void registerReltblOrder(ArrayBuffer* rtbuf, address table, opesize size,
802802
boolean isProgram, lblmode mode) {
803-
if (mode) regist_label(table, mode | size);
803+
if (mode) regist_label(table, mode | (lblmode)size);
804804

805805
if (hasReltblData(table)) {
806806
ReltblOrder* p = getArrayBufferNewPlace(rtbuf);
@@ -820,7 +820,7 @@ extern void z_table(address table) {
820820
while (ptr + 4 <= tableend) {
821821
address label = (address)peekl(ptr + Dis.Ofst);
822822

823-
regist_label(label, DATLABEL | UNKNOWN);
823+
regist_label(label, DATLABEL | (lblmode)UNKNOWN);
824824
ptr += 4;
825825
tableend = next(ptr)->label;
826826
}
@@ -835,7 +835,7 @@ extern void not_program(address from, address to) {
835835
DisParam disp;
836836
disasm* code = &disp.code;
837837

838-
ch_lblmod(from, DATLABEL | UNKNOWN | FORCE);
838+
ch_lblmod(from, DATLABEL | FORCE | (lblmode)UNKNOWN);
839839

840840
setDisParamPcPtr(&disp, from, Dis.Ofst);
841841
disp.pcEnd = to;
@@ -862,45 +862,45 @@ static void regist_data(disasm* code, operand* op) {
862862

863863
case IMMED:
864864
if (code->size2 == LONGSIZE && INPROG(op->opval, op->eaadrs))
865-
regist_label(op->opval, DATLABEL | UNKNOWN);
865+
regist_label(op->opval, DATLABEL | (lblmode)UNKNOWN);
866866
break;
867867

868868
case AbLong:
869869
if (INPROG(op->opval, op->eaadrs))
870-
regist_label(op->opval, DATLABEL | code->size2);
870+
regist_label(op->opval, DATLABEL | (lblmode)code->size2);
871871
break;
872872

873873
case PCDISP:
874874
case PCIDX:
875-
regist_label(op->opval, DATLABEL | code->size2);
875+
regist_label(op->opval, DATLABEL | (lblmode)code->size2);
876876
break;
877877

878878
case AregIDXB:
879879
if (op->exbd == 4 && INPROG(op->opval, op->eaadrs))
880-
regist_label(op->opval, DATLABEL | code->size2);
880+
regist_label(op->opval, DATLABEL | (lblmode)code->size2);
881881
break;
882882

883883
case AregPOSTIDX:
884884
case AregPREIDX:
885885
if (op->exbd == 4 && INPROG(op->opval, op->eaadrs))
886-
regist_label(op->opval, DATLABEL | LONGSIZE);
886+
regist_label(op->opval, DATLABEL | (lblmode)LONGSIZE);
887887
if (op->exod == 4 && INPROG(op->opval2, op->eaadrs2))
888-
regist_label(op->opval2, DATLABEL | code->size2);
888+
regist_label(op->opval2, DATLABEL | (lblmode)code->size2);
889889
break;
890890

891891
case PCIDXB:
892892
if ((op->flags & OPFLAG_PC_RELATIVE) ||
893893
(op->exbd == 4 && INPROG(op->opval, op->eaadrs)))
894-
regist_label(op->opval, DATLABEL | code->size2);
894+
regist_label(op->opval, DATLABEL | (lblmode)code->size2);
895895
break;
896896

897897
case PCPOSTIDX:
898898
case PCPREIDX:
899899
if ((op->flags & OPFLAG_PC_RELATIVE) ||
900900
(op->exbd == 4 && INPROG(op->opval, op->eaadrs)))
901-
regist_label(op->opval, DATLABEL | LONGSIZE);
901+
regist_label(op->opval, DATLABEL | (lblmode)LONGSIZE);
902902
if (op->exod == 4 && INPROG(op->opval2, op->eaadrs2))
903-
regist_label(op->opval2, DATLABEL | code->size2);
903+
regist_label(op->opval2, DATLABEL | (lblmode)code->size2);
904904
break;
905905
}
906906
}

src/analyze2.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// 自動解析モジュール2
33
// Copyright (C) 1989,1990 K.Abe
44
// All rights reserved.
5-
// Copyright (C) 1997-2023 TcbnErik
5+
// Copyright (C) 2025 TcbnErik
66

77
#include <stdio.h>
88

@@ -137,7 +137,8 @@ extern void analyze_data(void) {
137137
/* アドレス依存のデータがあれば、そのアドレスを登録する */
138138
for (adrs = data_from; (adrs = nearadrs(adrs)) < data_to && adrs < data_to;
139139
adrs += 4) {
140-
regist_label((address)peekl(adrs + Dis.Ofst), DATLABEL | UNKNOWN);
140+
regist_label((address)peekl(adrs + Dis.Ofst),
141+
DATLABEL | (lblmode)UNKNOWN);
141142
}
142143

143144
if (Dis.h && data_from < Dis.availableTextEnd) {
@@ -146,13 +147,13 @@ extern void analyze_data(void) {
146147

147148
if (word1 == 0x4e75) {
148149
// rts の次のアドレスを登録する
149-
regist_label(adrs + 2, DATLABEL | UNKNOWN);
150+
regist_label(adrs + 2, DATLABEL | (lblmode)UNKNOWN);
150151
}
151152

152153
if (Dis.findLinkW) {
153154
// link 命令に注目
154155
if ((word1 & 0xfff8) == 0x4e50)
155-
regist_label(adrs, DATLABEL | UNKNOWN);
156+
regist_label(adrs, DATLABEL | (lblmode)UNKNOWN);
156157
}
157158
}
158159
}

src/eval.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// テーブル行構文解析・評価
33
// Copyright (C) 1989,1990 K.Abe
44
// All rights reserved.
5-
// Copyright (C) 1997-2023 TcbnErik
5+
// Copyright (C) 2025 TcbnErik
66

77
// This file is part of dis (source code generator).
88
//
@@ -258,7 +258,7 @@ static ParseResult parseStrOrExp(Parser* parser, Expr* result) {
258258
if (parser->writePtr == NULL) {
259259
// 解析中ならラベル登録
260260
// テーブルでないと判定された場合に取り消す処理を追加したほうがよいかも
261-
regist_label((address)expr.value.ul, DATLABEL | UNKNOWN);
261+
regist_label((address)expr.value.ul, DATLABEL | (lblmode)UNKNOWN);
262262
}
263263
*result = createExprLabel(expr.value.ul);
264264
}
@@ -832,8 +832,7 @@ static StrSpan getKeywordSpan(char first, char* s) {
832832
char c;
833833

834834
if (isalpha(first) || first == '.') {
835-
while (isalnum(c = *p++) || c == '.')
836-
;
835+
while (isalnum(c = *p++) || c == '.');
837836
}
838837
return (StrSpan){s - 1, p - s};
839838
}
@@ -898,8 +897,7 @@ static Token fetchToken(Tokenizer* tokenizer) {
898897
char c, c2;
899898
tokenizer->_error = NULL;
900899

901-
while ((c = *tokenizer->_p++) == ' ' || c == '\t' || c == '\n')
902-
;
900+
while ((c = *tokenizer->_p++) == ' ' || c == '\t' || c == '\n');
903901
if (c == '\0') {
904902
tokenizer->_p -= 1;
905903
return (Token){TOKEN_NUL, 0};

src/human.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ソースコードジェネレータ
22
// Human68k
3-
// Copyright (C) 2024 TcbnErik
3+
// Copyright (C) 2025 TcbnErik
44

55
// This file is part of dis (source code generator).
66
//
@@ -254,17 +254,18 @@ static void analyzeDeviceDriver(void) {
254254
break;
255255
}
256256

257-
regist_label(dev + DH_NEXT, DATLABEL | LONGSIZE | FORCE | DEVLABEL);
258-
regist_label(dev + DH_TYPE, DATLABEL | WORDSIZE | FORCE | HIDDEN);
257+
regist_label(dev + DH_NEXT,
258+
DATLABEL | (lblmode)LONGSIZE | FORCE | DEVLABEL);
259+
regist_label(dev + DH_TYPE, DATLABEL | (lblmode)WORDSIZE | FORCE | HIDDEN);
259260

260261
// ストラテジルーチンと割り込みルーチンはリロケート情報があるので登録不要
261262
// ```
262263
// regist_label(dev + DH_STRATEGY, DATLABEL | LONGSIZE | FORCE);
263264
// regist_label(dev + DH_INTERRUPT, DATLABEL | LONGSIZE | FORCE);
264265
// ```
265266

266-
regist_label(dev + DH_NAME, DATLABEL | STRING | FORCE | HIDDEN);
267-
regist_label(dev + DH_SIZE, DATLABEL | UNKNOWN);
267+
regist_label(dev + DH_NAME, DATLABEL | (lblmode)STRING | FORCE | HIDDEN);
268+
regist_label(dev + DH_SIZE, DATLABEL | (lblmode)UNKNOWN);
268269

269270
analyze((address)peekl(ptr + DH_STRATEGY), ANALYZE_IGNOREFAULT);
270271
analyze((address)peekl(ptr + DH_INTERRUPT), ANALYZE_IGNOREFAULT);

src/label.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ラベル管理モジュール
33
// Copyright (C) 1989,1990 K.Abe
44
// All rights reserved.
5-
// Copyright (C) 2024 TcbnErik
5+
// Copyright (C) 2025 TcbnErik
66

77
#include "label.h"
88

@@ -25,7 +25,7 @@
2525
#include "./avl/avl.c"
2626

2727
static avl_root_node* LabelRoot;
28-
static lblbuf Nomore = {(address)-1, NULL, DATLABEL | UNKNOWN, 0, 1};
28+
static lblbuf Nomore = {(address)-1, NULL, DATLABEL | (lblmode)UNKNOWN, 0, 1};
2929

3030
static int compare(lblbuf* label1, lblbuf* label2) {
3131
return (ULONG)label1->label - (ULONG)label2->label;
@@ -96,7 +96,7 @@ boolean registerLabel(address adrs, lblmode mode) {
9696
if (isPROLABEL(mode)) {
9797
if (isOdd(adrs)) return FALSE;
9898
if (adrs > Dis.availableTextEnd) {
99-
regist_label(adrs, DATLABEL | UNKNOWN);
99+
regist_label(adrs, DATLABEL | (lblmode)UNKNOWN);
100100
return FALSE;
101101
}
102102
}

src/labelcheck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ラベルチェック
33
// Copyright (C) 1989,1990 K.Abe
44
// All rights reserved.
5-
// Copyright (C) 1997-2023 TcbnErik
5+
// Copyright (C) 2025 TcbnErik
66

77
#include <stdio.h>
88

@@ -159,7 +159,7 @@ static void search_change_data(address from, address end) {
159159
while (dependadrs < nlabel && nlabel < dependadrs + 4) {
160160
charout('!');
161161
nadrs->shift = nlabel - dependadrs;
162-
regist_label(dependadrs, DATLABEL | UNKNOWN);
162+
regist_label(dependadrs, DATLABEL | (lblmode)UNKNOWN);
163163
nadrs = Next(nadrs);
164164
nlabel = nadrs->label;
165165
}

0 commit comments

Comments
 (0)