Re: Comparisons and contrasts
Posted: Mon Sep 21, 2020 8:15 am
Here are a couple of prototypes of the same for the 8080. Can this be improved?
Code: Select all
0100 3A 0015 [13] 00043 lda S0 ; Get variable value
00044
0103 67 [5] 00045 mov H,A ; Stash a copy
00046
0104 2F [4] 00047 cma ; Get one's complement
0105 6F [5] 00048 mov L,A
00049
0106 7C [5] 00050 mov A,H ; Recover the variable value
00051
0107 17 [4] 00052 ral ; Sign extend it
0108 9F [4] 00053 sbb A
0109 2F [4] 00054 cma ; Get one's complement
010A 67 [5] 00055 mov H,A
00056
010B 11 0103 [10] 00057 lxi D,258+1 ; Constant plus one for 1's compl to 2's
010E 19 [10] 00058 dad D
00059 ; 0 := v W0 -> 1
010F 22 000D [16] 00060 shld W0
85 cycles
Code: Select all
0112 3A 0015 [13] 00063 lda S0 ; Get variable value
00064
0115 6F [5] 00065 mov L,A ; Stash a copy
00066
0116 17 [4] 00067 ral ; Sign extend it
0117 9F [4] 00068 sbb A
0118 67 [5] 00069 mov H,A
00070
0119 3E 02 [7] 00071 mvi A,2 ; Subtract low bytes
011B 95 [4] 00072 sub L
011C 6F [5] 00073 mov L,A
00074
011D 3E 01 [7] 00075 mvi A,1 ; Subtract high bytes
011F 9C [4] 00076 sbb H
0120 67 [5] 00077 mov H,A
00078 ; 0 := v W0 -> 1
0121 22 000D [16] 00079 shld W0
79 cycles