浏览代码

* patch by Christo Crause: combine code paths for avr1 and avrtiny when converting lds/sts to in/out, resolves #36697

git-svn-id: trunk@44163 -
(cherry picked from commit fd4fb5fa192b149d7f5c33d1820eca00af8430e1)
florian 5 年之前
父节点
当前提交
b65e3288aa
共有 1 个文件被更改,包括 24 次插入52 次删除
  1. 24 52
      compiler/avr/aasmcpu.pas

+ 24 - 52
compiler/avr/aasmcpu.pas

@@ -509,61 +509,33 @@ implementation
                           end;
                         A_STS:
                           begin
-                            { certain cpu types do not support some instructions, so replace them }
-                            case current_settings.cputype of
-                              cpu_avr1:
-                                begin
-                                  with taicpu(curtai).oper[0]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_OUT;
-                                        taicpu(curtai).loadconst(0,ref^.offset);
-                                      end
-                                    else
-                                      begin
-                                        remove_instruction;
-                                        result:=false;
-                                      end;
-                                end;
-                              cpu_avrtiny:
-                                begin
-                                  with taicpu(curtai).oper[0]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_OUT;
-                                        taicpu(curtai).loadconst(0,ref^.offset);
-                                      end;
-                                end;
-                            end;
+                            if current_settings.cputype in [cpu_avrtiny, cpu_avr1] then
+                              with taicpu(curtai).oper[0]^ do
+                                if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
+                                  begin
+                                    taicpu(curtai).opcode:=A_OUT;
+                                    taicpu(curtai).loadconst(0,ref^.offset);
+                                  end
+                                else if current_settings.cputype=cpu_avr1 then
+                                  begin
+                                    remove_instruction;
+                                    result:=false;
+                                  end;
                           end;
                         A_LDS:
                           begin
-                            { certain cpu types do not support some instructions, so replace them }
-                            case current_settings.cputype of
-                              cpu_avr1:
-                                begin
-                                  with taicpu(curtai).oper[1]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_IN;
-                                        taicpu(curtai).loadconst(1,ref^.offset)
-                                      end
-                                    else
-                                      begin
-                                        remove_instruction;
-                                        result:=false;
-                                      end;
-                                end;
-                              cpu_avrtiny:
-                                begin
-                                  with taicpu(curtai).oper[1]^ do
-                                    if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
-                                      begin
-                                        taicpu(curtai).opcode:=A_IN;
-                                        taicpu(curtai).loadconst(1,ref^.offset)
-                                      end;
-                                end;
-                            end;
+                            if current_settings.cputype in [cpu_avrtiny, cpu_avr1] then
+                              with taicpu(curtai).oper[1]^ do
+                                if (ref^.base=NR_NO) and (ref^.index=NR_NO) and (ref^.symbol=nil) and (ref^.offset<$40) then
+                                  begin
+                                    taicpu(curtai).opcode:=A_IN;
+                                    taicpu(curtai).loadconst(1,ref^.offset)
+                                  end
+                                else if current_settings.cputype=cpu_avr1 then
+                                  begin
+                                    remove_instruction;
+                                    result:=false;
+                                  end;
                           end;
                         A_SBIW,
                         A_MULS,