projects
/
YACASL2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0e30655
)
細部の修正
author
j8takagi
<j8takagi@nifty.com>
Tue, 2 Feb 2010 15:38:09 +0000
(
00:38
+0900)
committer
j8takagi
<j8takagi@nifty.com>
Tue, 2 Feb 2010 15:38:09 +0000
(
00:38
+0900)
include/casl2.h
patch
|
blob
|
history
include/cerr.h
patch
|
blob
|
history
src/cerr.c
patch
|
blob
|
history
src/exec.c
patch
|
blob
|
history
src/word.c
patch
|
blob
|
history
test/unit/TEST.mk
patch
|
blob
|
history
test/unit/cerrtest/cerrtest.c
patch
|
blob
|
history
test/unit/hash/0.txt
patch
|
blob
|
history
diff --git
a/include/casl2.h
b/include/casl2.h
index
c269710
..
9c71c28
100644
(file)
--- a/
include/casl2.h
+++ b/
include/casl2.h
@@
-2,7
+2,7
@@
#define YACASL2_CASL2_INCLUDED
#include <stdio.h>
#define YACASL2_CASL2_INCLUDED
#include <stdio.h>
-#include <
malloc
.h>
+#include <
stdlib
.h>
#include <stdbool.h>
#include <time.h>
#include <assert.h>
#include <stdbool.h>
#include <time.h>
#include <assert.h>
diff --git
a/include/cerr.h
b/include/cerr.h
index
9c191c1
..
586ab4d
100644
(file)
--- a/
include/cerr.h
+++ b/
include/cerr.h
@@
-1,7
+1,7
@@
#ifndef YACASL2_CERR_H_INCLUDED
#define YACASL2_CERR_H_INCLUDED
#ifndef YACASL2_CERR_H_INCLUDED
#define YACASL2_CERR_H_INCLUDED
-#include <
malloc
.h>
+#include <
stdlib
.h>
#include <string.h>
#include <assert.h>
#include <string.h>
#include <assert.h>
@@
-21,6
+21,10
@@
typedef struct {
char *msg;
} CERRARRAY;
char *msg;
} CERRARRAY;
+enum {
+ MSGSIZE = 60,
+};
+
/* エラー番号とエラーメッセージを設定 */
void setcerr(int num, const char *val);
/* エラー番号とエラーメッセージを設定 */
void setcerr(int num, const char *val);
diff --git
a/src/cerr.c
b/src/cerr.c
index
dca9365
..
ceea3af
100644
(file)
--- a/
src/cerr.c
+++ b/
src/cerr.c
@@
-36,7
+36,7
@@
CERRARRAY cerr[] = {
void setcerr(int num, const char *val)
{
cerrno = num;
void setcerr(int num, const char *val)
{
cerrno = num;
- cerrmsg = malloc(
256
);
+ cerrmsg = malloc(
MSGSIZE + 1
);
if(val != NULL) {
strcpy(cerrmsg, val);
strcat(cerrmsg, ": ");
if(val != NULL) {
strcpy(cerrmsg, val);
strcat(cerrmsg, ": ");
diff --git
a/src/exec.c
b/src/exec.c
index
1862973
..
94c7925
100644
(file)
--- a/
src/exec.c
+++ b/
src/exec.c
@@
-72,12
+72,11
@@
WORD adda(WORD val0, WORD val1)
long temp;
FR = 0x0;
long temp;
FR = 0x0;
- temp = (s
hort)val0 + (
short)val1;
+ temp = (s
igned short)val0 + (signed
short)val1;
if(temp > 32767 || temp < -32768) {
FR += OF;
}
if(temp > 32767 || temp < -32768) {
FR += OF;
}
- res = (WORD)(temp & 0xFFFF);
- if((res & 0x8000) > 0x0) {
+ if(((res = (WORD)(temp & 0xFFFF)) & 0x8000) == 0x8000) {
FR += SF;
} else if(res == 0x0) {
FR += ZF;
FR += SF;
} else if(res == 0x0) {
FR += ZF;
@@
-98,12
+97,10
@@
WORD addl(WORD val0, WORD val1)
WORD res;
FR = 0x0;
WORD res;
FR = 0x0;
- temp = val0 + val1;
- if(temp < 0 || temp > 65535) {
+ if((temp = val0 + val1) < 0 || temp > 65535) {
FR += OF;
}
FR += OF;
}
- res = (WORD)(temp & 0xFFFF);
- if((res & 0x8000) > 0x0) {
+ if(((res = (WORD)(temp & 0xFFFF)) & 0x8000) == 0x8000) {
FR += SF;
} else if(res == 0x0) {
FR += ZF;
FR += SF;
} else if(res == 0x0) {
FR += ZF;
@@
-139,8
+136,8
@@
void cpl(WORD val0, WORD val1)
}
}
}
}
-/* 算術左シフト。フラグを設定して値を返す。
-
算術演算なので、第15ビットは送り出されない */
+/* 算術左シフト。フラグを設定して値を返す。
*/
+
/*
算術演算なので、第15ビットは送り出されない */
WORD sla(WORD val0, WORD val1)
{
FR = 0x0;
WORD sla(WORD val0, WORD val1)
{
FR = 0x0;
@@
-171,7
+168,7
@@
WORD sra(WORD val0, WORD val1)
res = (val0 & 0x7FFF) >> val1;
/* 符号(第15ビット)が1の場合、符号と空いたビット位置に1を設定
COMET IIの仕様で、シフトの結果空いたビット位置には符号と同じものが入る */
res = (val0 & 0x7FFF) >> val1;
/* 符号(第15ビット)が1の場合、符号と空いたビット位置に1を設定
COMET IIの仕様で、シフトの結果空いたビット位置には符号と同じものが入る */
- if((sign = val0 & 0x8000)
> 0x
0) {
+ if((sign = val0 & 0x8000)
== 0x800
0) {
for(i = 0; i <= val1; i++) {
res |= onbit;
onbit >>= 1;
for(i = 0; i <= val1; i++) {
res |= onbit;
onbit >>= 1;
@@
-224,7
+221,7
@@
WORD srl(WORD val0, WORD val1)
FR += OF;
}
/* 第15ビットが1のとき、SFは1 */
FR += OF;
}
/* 第15ビットが1のとき、SFは1 */
- if((res & 0x8000)
> 0x
0) {
+ if((res & 0x8000)
== 0x800
0) {
FR += SF;
}
/* 演算結果が0のとき、ZFは1 */
FR += SF;
}
/* 演算結果が0のとき、ZFは1 */
@@
-238,7
+235,7
@@
WORD srl(WORD val0, WORD val1)
void reset()
{
int i;
void reset()
{
int i;
- for(i = 0; i <
= 7
; i++) {
+ for(i = 0; i <
REGSIZE
; i++) {
GR[i] = 0x0;
}
SP = PR = FR = 0x0;
GR[i] = 0x0;
}
SP = PR = FR = 0x0;
diff --git
a/src/word.c
b/src/word.c
index
83ae9bd
..
0e80452
100644
(file)
--- a/
src/word.c
+++ b/
src/word.c
@@
-14,7
+14,7
@@
WORD n2word(const char *str)
}
/* nが-32768〜32767の範囲にないときは、その下位16ビットを格納 */
if(n < -32768 || n > 32767) {
}
/* nが-32768〜32767の範囲にないときは、その下位16ビットを格納 */
if(n < -32768 || n > 32767) {
- n = n
% 0x10000
;
+ n = n
& 0xFFFF
;
}
return (WORD)n;
}
}
return (WORD)n;
}
@@
-23,7
+23,7
@@
WORD n2word(const char *str)
WORD h2word(const char *str)
{
assert(*str == '#');
WORD h2word(const char *str)
{
assert(*str == '#');
- WORD w = 0x0;
+ WORD w
ord
= 0x0;
char *check;
str++;
if(*str == '-' || strlen(str) > 4) {
char *check;
str++;
if(*str == '-' || strlen(str) > 4) {
@@
-31,12
+31,12
@@
WORD h2word(const char *str)
return 0;
}
/* WORD値に変換 */
return 0;
}
/* WORD値に変換 */
- w = (WORD)strtol(str, &check, 16);
+ w
ord
= (WORD)strtol(str, &check, 16);
if(*check != '\0') {
setcerr(115, str-1); /* not hex */
return 0x0;
}
if(*check != '\0') {
setcerr(115, str-1); /* not hex */
return 0x0;
}
- return w;
+ return w
ord
;
}
/* 10進数または16進数の文字列をWORD値に変換 */
}
/* 10進数または16進数の文字列をWORD値に変換 */
diff --git
a/test/unit/TEST.mk
b/test/unit/TEST.mk
index
96c908d
..
7e49c83
100644
(file)
--- a/
test/unit/TEST.mk
+++ b/
test/unit/TEST.mk
@@
-11,9
+11,9
@@
SRCDIR = ../../../src
INCLUDE = ../../../include
CC = gcc
CFLAGS = -g -Wall -I $(INCLUDE)
INCLUDE = ../../../include
CC = gcc
CFLAGS = -g -Wall -I $(INCLUDE)
-COMMONSRC = $(SRCDIR)/word.
o $(SRCDIR)/struct.o $(SRCDIR)/hash.o $(SRCDIR)/cmd.o $(SRCDIR)/cerr.o
-ASSRC = $(SRCDIR)/assemble.
o $(SRCDIR)/token.o $(SRCDIR)/label.o $(SRCDIR)/macro.o
-EXECSRC = $(SRCDIR)/exec.
o $(SRCDIR)/dump.o
+COMMONSRC = $(SRCDIR)/word.
c $(SRCDIR)/struct.c $(SRCDIR)/hash.c $(SRCDIR)/cmd.c $(SRCDIR)/cerr.c
+ASSRC = $(SRCDIR)/assemble.
c $(SRCDIR)/token.c $(SRCDIR)/label.c $(SRCDIR)/macro.c
+EXECSRC = $(SRCDIR)/exec.
c $(SRCDIR)/dump.c
ifeq "$(UCLASS)" "AS"
SRC = $(COMMONSRC) $(ASSRC)
ifeq "$(UCLASS)" "AS"
SRC = $(COMMONSRC) $(ASSRC)
@@
-32,8
+32,6
@@
clean:
@rm -f a.out 1.txt diff.txt report.txt
cleanall: clean
@rm -f 0.txt
@rm -f a.out 1.txt diff.txt report.txt
cleanall: clean
@rm -f 0.txt
-$(SRCDIR)/%.o: $(SRCDIR)/%.c
- @$(CC) -c $(CFLAGS) $<
a.out: $(SRC) $(TESTSRCFILE)
@gcc $(CFLAGS) $(SRC) $(TESTSRCFILE)
0.txt 1.txt: a.out
a.out: $(SRC) $(TESTSRCFILE)
@gcc $(CFLAGS) $(SRC) $(TESTSRCFILE)
0.txt 1.txt: a.out
diff --git
a/test/unit/cerrtest/cerrtest.c
b/test/unit/cerrtest/cerrtest.c
index
998f510
..
ed8d0ae
100644
(file)
--- a/
test/unit/cerrtest/cerrtest.c
+++ b/
test/unit/cerrtest/cerrtest.c
@@
-9,7
+9,7
@@
int main(){
121, 122, 123, 124, 201, 202, 203, 204, 205, 206, 207, 999
};
const char *str[] = {NULL, "foobar"};
121, 122, 123, 124, 201, 202, 203, 204, 205, 206, 207, 999
};
const char *str[] = {NULL, "foobar"};
-
+
for(i = 0; i < sizeof(str)/sizeof(str[0]); i++) {
for(j = 0; j < sizeof(code)/sizeof(code[0]); j++) {
setcerr(code[j], str[i]);
for(i = 0; i < sizeof(str)/sizeof(str[0]); i++) {
for(j = 0; j < sizeof(code)/sizeof(code[0]); j++) {
setcerr(code[j], str[i]);
diff --git
a/test/unit/hash/0.txt
b/test/unit/hash/0.txt
index
b35644c
..
66daee2
100644
(file)
--- a/
test/unit/hash/0.txt
+++ b/
test/unit/hash/0.txt
@@
-1,3
+1,3
@@
HASH VALUE: 20
HASH VALUE: 11
HASH VALUE: 20
HASH VALUE: 11
-HASH VALUE:
3
+HASH VALUE:
21