changeset 106:6566b9f47f4a

asm macro fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 29 Dec 2018 18:29:06 +0900
parents 6eef99bb4771
children c5dd5c363d43
files os9/mc09/mc.c os9/mc09/mc2.c os9/mc09/mclibos9.c
diffstat 3 files changed, 32 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/os9/mc09/mc.c	Sat Dec 29 12:25:26 2018 +0900
+++ b/os9/mc09/mc.c	Sat Dec 29 18:29:06 2018 +0900
@@ -2823,12 +2823,8 @@
 		}
 		else if (macroeq("asm"))
 		{	if (asmf) error(MCERR);
-			asmf = 1;
-			getline();
-			while (asmf)
-			{	printf("%s",linebuf);
-				getline();
-			}
+			asmf = 2; lineno--; glineno--;
+                        chptr = ";;";
 		}
 		else if (macroeq("endasm"))
 		{	if (!asmf) error(MCERR);
@@ -2838,6 +2834,13 @@
 			getline();
 		else error(MCERR);
 	}
+        if (asmf==2) asmf=1;    /* return ";" to get correct macro alignment */
+        else if (asmf==1) {
+            while (asmf)
+            {	printf("%s",linebuf);
+                    getline();
+            }
+        }
 }
 
 macroeq(s)
--- a/os9/mc09/mc2.c	Sat Dec 29 12:25:26 2018 +0900
+++ b/os9/mc09/mc2.c	Sat Dec 29 18:29:06 2018 +0900
@@ -2813,15 +2813,11 @@
 			++filep;
 			*(chptr = linebuf) = '\0';
 		}
-		else if (macroeq("asm"))
-		{	if (asmf) error(MCERR);
-			asmf = 1;
-			getline();
-			while (asmf)
-			{	printf("%s",linebuf);
-				getline();
-			}
-		}
+                else if (macroeq("asm"))
+                {       if (asmf) error(MCERR);
+                        asmf = 2; lineno--; glineno--;
+                        chptr = ";;";
+                }
 		else if (macroeq("endasm"))
 		{	if (!asmf) error(MCERR);
 			asmf = 0;
@@ -2830,6 +2826,14 @@
 			getline();
 		else error(MCERR);
 	}
+        if (asmf==2) asmf=1;    /* return ";" to get correct macro alignment */
+        else if (asmf==1) {
+            while (asmf)
+            {   printf("%s",linebuf);
+                    getline();
+            }
+        }
+
 }
 
 macroeq(s)
--- a/os9/mc09/mclibos9.c	Sat Dec 29 12:25:26 2018 +0900
+++ b/os9/mc09/mclibos9.c	Sat Dec 29 18:29:06 2018 +0900
@@ -116,7 +116,6 @@
 	if ( i >= NFILES) return NULL;
 	if ( (fcbp = malloc(FCBSIZE)) == NULL ) return NULL;
 	if ( _setname(name,fcbp) == 0 ) return NULL;
-        0;
 #asm
         pshs      x,y,u
         ldx       -4,u
@@ -126,13 +125,14 @@
         os9       I$Open
         bcc        _LC0001
         ldx       -4,u
-        clrb
+        tfr       a,b
+        clra
         std       ,x
         bra       _LC0002
 _LC0001
         ldx       -4,u
         clra
-        stD       2,x          err code
+        std       2,x          err code
         ldd       #-1
         std       ,x
 _LC0002
@@ -154,7 +154,6 @@
 	if ( i >= NFILES) return NULL;
 	if ( (fcbp = malloc(FCBSIZE)) == NULL ) return NULL;
 	if ( _setname(name,fcbp) == 0 ) return NULL;
-        0;
 #asm
         pshs      x,y,u
         ldx       -4,u
@@ -164,7 +163,8 @@
         os9       I$Create
         bcc        _LC0003
         ldx       -4,u
-        clrb
+        tfr       a,b
+        clra
         std       ,x
         bra       _LC0004
 _LC0003
@@ -190,11 +190,10 @@
 	if ( i >= NFILES ) return EOF;
 	_fcbtbl[i] = NULL;
 	if ( (fcbp == STDIN) || (fcbp == STDOUT) || (fcbp == STDERR) ) return 0;
-        0;
 #asm
         pshs      x,y,u
         ldx       -4,u
-        lda       ,x
+        lda       1,x
         os9       I$Close
         puls      x,y,u
 #endasm
@@ -234,9 +233,7 @@
 {
     int c;
 #asm
-        pshs      x,y,u
-        ldd       ,u        c
-        PSHS      A,B
+        pshs      d,x,y,u
         ldx       2,u         
         lda       1,x       file descriptor
         leax      1,S
@@ -256,12 +253,10 @@
 {	
     int ret;
 #asm
-        pshs      x,y,u
-        ldd       ,u        c
-        PSHS      A,B
-        ldx       2,u         
+        pshs      d,x,y,u
+        ldx       4,u         
         lda       1,x       file descriptor
-        leax      1,S
+        leax      3,u
         ldy       #1
         os9       I$Write
         puls      d,x,y,u