Modifications to work with CC64 master
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 27 May 2025 16:45:39 +0000 (17:45 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 27 May 2025 16:45:39 +0000 (17:45 +0100)
Makefile.s64 [new file with mode: 0644]
intel.c
process.c

diff --git a/Makefile.s64 b/Makefile.s64
new file mode 100644 (file)
index 0000000..aa5f91a
--- /dev/null
@@ -0,0 +1,27 @@
+CPP=pdcc
+CC=cc64
+CFLAGS=
+LD=pdld
+LDFLAGS=-s -nostdlib --no-insert-timestamp --image-base 0x400000
+AS=pdas --oformat coff --64
+COPTS=-I. -I../pdos/pdpclib -I../pdos/src -D__PDOS__ \
+    -D__WIN32__ -D__NOBIVA__ -D__64BIT__ -D__CC64__ -Dconst=
+
+OBJS=as.obj coff.obj cstr.obj elks.obj expr.obj fixup.obj frag.obj hashtab.obj \
+  intel.obj kwd.obj lex.obj lib.obj list.obj listing.obj ll.obj macro.obj \
+  process.obj report.obj section.obj symbol.obj vector.obj
+
+TARGET=sasm.exe
+
+all: clean $(TARGET)
+
+$(TARGET): $(OBJS)
+  $(LD) $(LDFLAGS) -o $(TARGET) ../pdos/pdpclib/w32start.obj $(OBJS) ../pdos/pdpclib/msvcrt.lib
+
+.c.obj:
+  $(CPP) -E $(COPTS) -o $*.i $<
+  $(CC) -c -out:$@ $*.i
+  rm -f $*.i
+
+clean:
+  rm -f $(OBJS) $(TARGET)
diff --git a/intel.c b/intel.c
index 09495f28e0a03ae579e1b168160bf05caee44226..e77595fdfbef4d5afe8abc4fbf12447d134bf699 100644 (file)
--- a/intel.c
+++ b/intel.c
@@ -66,6 +66,11 @@ static struct operand_type operand_type_and (struct operand_type a, struct opera
 
 }
 
+#ifdef __CC64__
+struct operand_type temp;
+# define operand_type_and(a, b) (operand_type_and)(temp = (a), (b))
+#endif
+
 static int operand_type_equal (const struct operand_type *pa, const struct operand_type *pb) {
     return !memcmp (pa, pb, sizeof (*pa));
 }
@@ -3062,7 +3067,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
     if (*operand_string) {
     
         report_at (get_filename (), get_line_number (), REPORT_ERROR, "junk '%s' after expression", operand_string);
+#ifdef __CC64__
+        ret = 1;
+        goto ret1;
+#else
         return 1;
+#endif
     
     } else if (!intel_state.has_offset && operand_string > operand_start && strrchr (operand_start, ']') && skip_whitespace (strrchr (operand_start, ']') + 1) == operand_string) {
     
@@ -3071,7 +3081,15 @@ static int intel_parse_operand (char *start, char *operand_string) {
     
     }
     
+#ifdef __CC64__
+    if (!ret)
+    {
+        ret = 1;
+        goto ret1;
+    }
+#else
     if (!ret) { return 1; }
+#endif
     ret = 0;
     
     if (intel_state.operand_modifier != EXPR_TYPE_ABSENT && current_templates->start->base_opcode != 0x8D /* lea */) {
@@ -3181,8 +3199,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
         } else if (instruction.suffix != suffix) {
         
             report_at (get_filename (), get_line_number (), REPORT_ERROR, "conficting operand size modifiers");
+#ifdef __CC64__
+            ret = 1;
+            goto ret1;
+#else
             return 1;
-        
+#endif
         }
     
     }
@@ -3225,8 +3247,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
                         }
                         
                         report_at (get_filename (), get_line_number (), REPORT_ERROR, "cannot infer the segment part of the operand");
+#ifdef __CC64__
+                        ret = 1;
+                        goto ret1;
+#else
                         return 1;
-                    
+#endif
                     } else if (symbol_get_section (intel_state.segment) == reg_section) {
                         is_absolute_jump = 1;
                     } else {
@@ -3241,7 +3267,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
                         resolve_expression (instruction.imms[instruction.operands]);
                         
                         if (finalize_immediate (instruction.imms[instruction.operands], operand_start)) {
+#ifdef __CC64__
+                            ret = 1;
+                            goto ret1;
+#else
                             return 1;
+#endif
                         }
                         
                         instruction.operands++;
@@ -3311,9 +3342,14 @@ static int intel_parse_operand (char *start, char *operand_string) {
                         
                         instruction.operands = 2;
                         instruction.types[0] = operand_type_and_not_disp (instruction.types[0]);
-                        
+
+#ifdef __CC64__
+                        ret = 0;
+                        goto ret1;
+#else
                         return 0;
-                    
+#endif
+
                     }
                 
                 }
@@ -3321,8 +3357,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
             }
             
             report_at (get_filename (), get_line_number (), REPORT_ERROR, "too many memory references for '%s'", current_templates->name);
+#ifdef __CC64__
+            ret = 1;
+            goto ret1;
+#else
             return 1;
-        
+#endif
         }
         
         if (intel_state.base_reg && intel_state.index_reg && intel_state.base_reg->type.word && intel_state.index_reg->type.word && intel_state.base_reg->number >= 6 && intel_state.index_reg->number < 6) {
@@ -3364,7 +3404,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
             }
             
             if (finalize_displacement (instruction.disps[instruction.operands], operand_start)) {
+#ifdef __CC64__
+                ret = 1;
+                goto ret1;
+#else
                 return 1;
+#endif
             }
         
         }
@@ -3389,15 +3434,23 @@ static int intel_parse_operand (char *start, char *operand_string) {
             if (expr->type != EXPR_TYPE_REGISTER) {
             
                 report_at (get_filename (), get_line_number (), REPORT_ERROR, "segment register name expected");
+#ifdef __CC64__
+                ret = 1;
+                goto ret1;
+#else
                 return 1;
-            
+#endif
             }
             
             if (!reg_table[expr->add_number].type.segment1 && !reg_table[expr->add_number].type.segment2) {
             
                 report_at (get_filename (), get_line_number (), REPORT_ERROR, "invalid use of register");
+#ifdef __CC64__
+                ret = 1;
+                goto ret1;
+#else
                 return 1;
-            
+#endif
             }
             
             if (more_than_1_segment) {
@@ -3413,7 +3466,12 @@ static int intel_parse_operand (char *start, char *operand_string) {
         }
         
         if (base_index_check (operand_start)) {
+#ifdef __CC64__
+            ret = 1;
+            goto ret1;
+#else
             return 1;
+#endif
         }
         
         instruction.mem_operands++;
@@ -3429,6 +3487,11 @@ static int intel_parse_operand (char *start, char *operand_string) {
     }
     
     instruction.operands++;
+
+#ifdef __CC64__
+ret1:
+#endif
+
     return ret;
 
 }
index 0402d20c4b42e36350c4b14d875ee764f03d403c..474785fe1cb0b41c952449441841953a1237163d 100644 (file)
--- a/process.c
+++ b/process.c
@@ -1021,7 +1021,11 @@ static void process_line (char *line, char *line_end) {
             
             if ((poe = find_poe (arg))) {
             
+#ifdef __CC64__
+                (*poe->handler) (start, &line);
+#else
                 poe->handler (start, &line);
+#endif
                 goto check;
             
             }
@@ -1090,8 +1094,12 @@ static void process_line (char *line, char *line_end) {
                         
                         symbol = symbol_label (start, caret, arg);
                         symbol->scope = SYMBOL_SCOPE_LOCAL;
-                        
+
+#ifdef __CC64__
+                        (*poe->handler) (start, &line);
+#else
                         poe->handler (start, &line);
+#endif
                         goto check;
                     
                     }
@@ -1244,8 +1252,12 @@ void process_file (const char *ifile) {
                 line = skip_whitespace (line);
                 
                 if ((poe = find_cond_directive (arg))) {
-                
+
+#ifdef __CC64__
+                    (*poe->handler) (start, &line);
+#else
                     poe->handler (start, &line);
+#endif
                     free (arg);
                     
                     continue;
@@ -1255,8 +1267,12 @@ void process_file (const char *ifile) {
                 if (!ignore_line) {
                 
                     if ((poe = find_directive (arg))) {
-                    
+
+#ifdef __CC64__
+                        (*poe->handler) (start, &line);
+#else
                         poe->handler (start, &line);
+#endif
                         free (arg);
                         
                         continue;
@@ -1287,8 +1303,12 @@ void process_file (const char *ifile) {
                 line = skip_whitespace (line);
                 
                 if ((poe = find_cond_directive (arg))) {
-                
+
+#ifdef __CC64__
+                    (*poe->handler) (start, &line);
+#else
                     poe->handler (start, &line);
+#endif
                     free (arg);
                     
                     continue;