@@ -1011,33 +1011,23 @@ def load16(cls, ins: Quad) -> list[str]:
10111011 output .append ("push hl" )
10121012 return output
10131013
1014+ @classmethod
1015+ def store16 (cls , ins : Quad ) -> list [str ]:
1016+ """Stores 2nd operand content into address of 1st operand.
1017+ store16 a, x => *(&a) = x
1018+ Use '*' for indirect store on 1st operand.
1019+ """
1020+ output = Bits16 .get_oper (ins [2 ])
10141021
1015- def _store16 (ins : Quad ) -> list [str ]:
1016- """Stores 2nd operand content into address of 1st operand.
1017- store16 a, x => *(&a) = x
1018- Use '*' for indirect store on 1st operand.
1019- """
1020- output = Bits16 .get_oper (ins [2 ])
1022+ value = ins [1 ]
1023+ indirect = False
10211024
1022- value = ins [1 ]
1023- indirect = False
1025+ try :
1026+ if value [0 ] == "*" :
1027+ indirect = True
1028+ value = value [1 :]
10241029
1025- try :
1026- if value [0 ] == "*" :
1027- indirect = True
1028- value = value [1 :]
1029-
1030- value = int (value ) & 0xFFFF
1031- if indirect :
1032- output .append ("ex de, hl" )
1033- output .append ("ld hl, (%s)" % str (value ))
1034- output .append ("ld (hl), e" )
1035- output .append ("inc hl" )
1036- output .append ("ld (hl), d" )
1037- else :
1038- output .append ("ld (%s), hl" % str (value ))
1039- except ValueError :
1040- if value [0 ] in "_." :
1030+ value = int (value ) & 0xFFFF
10411031 if indirect :
10421032 output .append ("ex de, hl" )
10431033 output .append ("ld hl, (%s)" % str (value ))
@@ -1046,32 +1036,42 @@ def _store16(ins: Quad) -> list[str]:
10461036 output .append ("ld (hl), d" )
10471037 else :
10481038 output .append ("ld (%s), hl" % str (value ))
1049- elif value [0 ] == "#" :
1050- value = value [1 :]
1051- if indirect :
1039+ except ValueError :
1040+ if value [0 ] in "_." :
1041+ if indirect :
1042+ output .append ("ex de, hl" )
1043+ output .append ("ld hl, (%s)" % str (value ))
1044+ output .append ("ld (hl), e" )
1045+ output .append ("inc hl" )
1046+ output .append ("ld (hl), d" )
1047+ else :
1048+ output .append ("ld (%s), hl" % str (value ))
1049+ elif value [0 ] == "#" :
1050+ value = value [1 :]
1051+ if indirect :
1052+ output .append ("ex de, hl" )
1053+ output .append ("ld hl, (%s)" % str (value ))
1054+ output .append ("ld (hl), e" )
1055+ output .append ("inc hl" )
1056+ output .append ("ld (hl), d" )
1057+ else :
1058+ output .append ("ld (%s), hl" % str (value ))
1059+ else :
10521060 output .append ("ex de, hl" )
1053- output .append ("ld hl, (%s)" % str (value ))
1061+ if indirect :
1062+ output .append ("pop hl" )
1063+ output .append ("ld a, (hl)" )
1064+ output .append ("inc hl" )
1065+ output .append ("ld h, (hl)" )
1066+ output .append ("ld l, a" )
1067+ else :
1068+ output .append ("pop hl" )
1069+
10541070 output .append ("ld (hl), e" )
10551071 output .append ("inc hl" )
10561072 output .append ("ld (hl), d" )
1057- else :
1058- output .append ("ld (%s), hl" % str (value ))
1059- else :
1060- output .append ("ex de, hl" )
1061- if indirect :
1062- output .append ("pop hl" )
1063- output .append ("ld a, (hl)" )
1064- output .append ("inc hl" )
1065- output .append ("ld h, (hl)" )
1066- output .append ("ld l, a" )
1067- else :
1068- output .append ("pop hl" )
1069-
1070- output .append ("ld (hl), e" )
1071- output .append ("inc hl" )
1072- output .append ("ld (hl), d" )
10731073
1074- return output
1074+ return output
10751075
10761076
10771077def _jzero16 (ins : Quad ) -> list [str ]:
0 commit comments