Skip to content

Commit

Permalink
Cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsk2 committed Jan 10, 2023
1 parent 14a840f commit 786c8f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
41 changes: 27 additions & 14 deletions arith32.a
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ mul32BitUnsignedInt
rts


; SQUARE_BUFFER_LSB
; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

; SQUARE_BUFFER_MSB
; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

!macro carryLoop {
.carryLoopSquare2 ; handle the case where one or more carries to the following digits occur
iny
Expand Down Expand Up @@ -282,12 +276,12 @@ square32BitUnsigned
ldy COUNT_L
iny ; skip sign byte
lda (ADDR_OPER_LEFT), y ; load COUNT_L digit of left operand
beq noExtraCarrySquare ; result will be zero => skip rest of code
beq noExtraCarrySquare ; result will be zero => skip rest of code
tax ; and store it in X register
ldy COUNT_R ; load COUNT_R digit of right operand in accu
iny ; skip sign byte
lda (ADDR_OPER_LEFT), y
beq noExtraCarrySquare ; result will be zero => skip rest of code
beq noExtraCarrySquare ; result will be zero => skip rest of code
;jsr mul16Bit ; multiply these 8 bit values. Result MSB in accu, LSB in x register
+mul16BitBankedRAM
; multiply multiplication result by two
Expand All @@ -314,7 +308,7 @@ square32BitUnsigned
sta TEMP_MUL, y
iny
tya
and #8 ; "compare" with 8 without influencing the carry
and #8 ; "compare" with 8 without influencing the carry. This works if y < 8 before the iny
bne noExtraCarrySquare
lda HELP_MUL_3
adc TEMP_MUL, y
Expand Down Expand Up @@ -480,13 +474,32 @@ halve32Bit

rts

LEFT_GREATER_EQUAL_RIGHT
!byte 0

!macro prepareAddSub {
lda #0
sta LEFT_GREATER_EQUAL_RIGHT
jsr cmp32BitUnsigned
stz LEFT_GREATER_EQUAL_RIGHT
;jsr cmp32BitUnsigned
ldy #4 ; start at MSB
lda (ADDR_OPER_LEFT), y
cmp (ADDR_OPER_RIGHT), y
beq .next1 ; continue if equal
bra .endCmp ; carry contains result
.next1
dey
lda (ADDR_OPER_LEFT), y
cmp (ADDR_OPER_RIGHT), y
beq .next2 ; continue if equal
bra .endCmp ; carry contains result
.next2
dey
lda (ADDR_OPER_LEFT), y
cmp (ADDR_OPER_RIGHT), y
beq .next3 ; continue if equal
bra .endCmp ; carry contains result
.next3 ; We get here only if all bytes before were equal
dey
lda (ADDR_OPER_LEFT), y
cmp (ADDR_OPER_RIGHT), y ; carry contains result even if values are equal
.endCmp
bcc .leftLessThanRight
inc LEFT_GREATER_EQUAL_RIGHT
.leftLessThanRight
Expand Down
3 changes: 2 additions & 1 deletion zeropage.a
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ TEMP_MUL = $48;-$4F
COUNT_L = $50
COUNT_R = $51
HELP_MUL = $52
DRAW_HELP = $53;/54
DRAW_HELP = $53;/54
LEFT_GREATER_EQUAL_RIGHT = $55

0 comments on commit 786c8f1

Please sign in to comment.