ASMODE asmode = {false, false, false, false, false};
/**
- * アセンブルのプロパティ: ptr, lptr, *prog
+ * アセンブル時の、現在およびリテラルのアドレスとプログラム入口名: ptr, lptr, prog
*/
ASPTR *asptr;
{
assert(str != NULL);
WORD r;
+
/* 「GR[0-7]」以外の文字列では、0xFFFFを返して終了 */
if(!(strlen(str) == 3 && strncmp(str, "GR", 2) == 0 &&
(*(str+2) >= '0' && *(str+2) <= '0' + (GRSIZE - 1))))
*/
WORD getliteral(const char *str, PASS pass)
{
- WORD adr = asptr->lptr;
assert(*str == '=');
+ WORD adr = asptr->lptr;
+
if(*(++str) == '\'') { /* 文字定数 */
writestr(str, true, pass);
} else {
{
int i = 0;
MACROCMDID cmdid = 0;
- MACROCMD macrocmd[] = {
+ MACROCMD macrocmd[] = {
{ IN, 2, 2, "IN" },
{ OUT, 2, 2, "OUT" },
{ RPUSH, 0, 0, "RPUSH" },
*/
void writeIN(const char *ibuf, const char *len, PASS pass)
{
- char *line = malloc_chk(LINESIZE+1, "writeIN.line");
+ char *line = malloc_chk(LINESIZE + 1, "writeIN.line");
assembleline(" PUSH 0,GR1", pass);
assembleline(" PUSH 0,GR2", pass);
*/
void writeOUT(const char *obuf, const char *len, PASS pass)
{
- char *line = malloc_chk(LINESIZE+1, "writeOUT.line");
+ char *line = malloc_chk(LINESIZE + 1, "writeOUT.line");
assembleline(" PUSH 0,GR1", pass);
assembleline(" PUSH 0,GR2", pass);
void writeRPUSH(PASS pass)
{
int i;
- char *line = malloc_chk(LINESIZE+1, "writeRPUSH.line");
+ char *line = malloc_chk(LINESIZE + 1, "writeRPUSH.line");
for(i = 1; i <= GRSIZE-1; i++) {
sprintf(line, " PUSH 0,GR%d", i);
void writeRPOP(PASS pass)
{
int i;
- char *line = malloc_chk(LINESIZE+1, "writeRPOP.line");
+ char *line = malloc_chk(LINESIZE + 1, "writeRPOP.line");
for(i = GRSIZE-1; i >= 1; i--) {
sprintf(line, " POP GR%d", i);
*/
void writestr(const char *str, bool literal, PASS pass)
{
- assert(cerr->num == 0 && *str == '\'');
+ assert(*str == '\'');
const char *p = str + 1;
bool lw = false;
void writeDC(const char *str, PASS pass)
{
WORD adr = 0x0;
+
if(*str == '\'') {
writestr(str, false, pass);
} else {
WORD getadr(const char *prog, const char *str, PASS pass)
{
WORD adr = 0x0;
+
if(*str == '=') {
adr = getliteral(str, pass);
} else if(isdigit(*str) || *str == '-' || *str == '#') {
{
int lineno = 0;
bool status = true;
- char *line = malloc_chk(LINESIZE + 1, "line");
+ char *line = malloc_chk(LINESIZE + 1, "assemble.line");
FILE *fp;
if((fp = fopen(file, "r")) == NULL) {