add general multiplication implementation
This commit is contained in:
parent
bc3e07356e
commit
9a06f770c2
7 changed files with 48 additions and 2 deletions
4
wip-hugo/routines/arithmatic/arithmatic.inc
Normal file
4
wip-hugo/routines/arithmatic/arithmatic.inc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
;; public args
|
||||||
|
VAL_A = ARGVEC + 0
|
||||||
|
VAL_B = ARGVEC + 1
|
27
wip-hugo/routines/arithmatic/mult.s
Normal file
27
wip-hugo/routines/arithmatic/mult.s
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
;;I thoughtout russan thing
|
||||||
|
;;X * %1111001
|
||||||
|
;;= X + X*%1111000
|
||||||
|
;;= X + X*%1000 *%11111
|
||||||
|
;; to remember this for later, for duuqnds papper
|
||||||
|
|
||||||
|
.proc mult; user-procedure :clobbers A :clobbers-arguments 2
|
||||||
|
|
||||||
|
;; https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication#Russian_peasant_multiplication
|
||||||
|
|
||||||
|
.include "arithmatic.inc"
|
||||||
|
|
||||||
|
LDA #$00
|
||||||
|
loop:
|
||||||
|
ASL VAL_B
|
||||||
|
ROR VAL_A; add to awnser if VAL_A is odd
|
||||||
|
BCC loop
|
||||||
|
|
||||||
|
LSR VAL_B
|
||||||
|
ADC VAL_B; add val_b because val_a was odd.
|
||||||
|
ASL VAL_B
|
||||||
|
|
||||||
|
BNE loop
|
||||||
|
endloop:
|
||||||
|
RTS
|
||||||
|
.endproc
|
10
wip-hugo/routines/arithmatic/mult_test.s
Normal file
10
wip-hugo/routines/arithmatic/mult_test.s
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
;;Calculates $11 * $0E = $EE
|
||||||
|
.scope mult_test
|
||||||
|
.include "arithmatic.inc"
|
||||||
|
LDA #$0F
|
||||||
|
STA VAL_A
|
||||||
|
LDA #$07
|
||||||
|
STA VAL_B
|
||||||
|
JSR mult; A = $69 if it works as it should
|
||||||
|
.endscope
|
|
@ -1,3 +1,4 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
.scope pixel_test
|
.scope pixel_test
|
||||||
.include "pixel.inc"
|
.include "pixel.inc"
|
||||||
LDA #$40
|
LDA #$40
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
;; public args
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
;; public args
|
||||||
X_pos = ARGVEC + 0
|
X_pos = ARGVEC + 0
|
||||||
Y_pos = ARGVEC + 1
|
Y_pos = ARGVEC + 1
|
||||||
code = ARGVEC + 2
|
code = ARGVEC + 2
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
.scope char_draw_test
|
.scope char_draw_test
|
||||||
.include "char.inc"
|
.include "char.inc"
|
||||||
LDA #$10
|
LDA #$10
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
.include "STARTUP.s"
|
.include "STARTUP.s"
|
||||||
;.include "dubbel_buffer/raster_irqs.s"
|
;.include "dubbel_buffer/raster_irqs.s"
|
||||||
|
|
||||||
|
.include "routines/arithmatic/mult_test.s"
|
||||||
;.include "routines/line/line_test.s"
|
;.include "routines/line/line_test.s"
|
||||||
;.include "routines/text/char_draw_test.s"
|
;.include "routines/text/char_draw_test.s"
|
||||||
;.include "routines/pixel/pixel_test.s"
|
;.include "routines/pixel/pixel_test.s"
|
||||||
;.include "routines/memory/memcpy_test.s"
|
;.include "routines/memory/memcpy_test.s"
|
||||||
.include "routines/memory/memset_test.s"
|
;.include "routines/memory/memset_test.s"
|
||||||
;.include "routines/triangle/triangle_test.s"
|
;.include "routines/triangle/triangle_test.s"
|
||||||
exit:
|
exit:
|
||||||
JMP exit
|
JMP exit
|
||||||
|
@ -23,4 +24,5 @@ JMP exit
|
||||||
.include "routines/text/char_draw.s"
|
.include "routines/text/char_draw.s"
|
||||||
.include "routines/memory/memset.s"
|
.include "routines/memory/memset.s"
|
||||||
.include "routines/memory/memcpy.s"
|
.include "routines/memory/memcpy.s"
|
||||||
|
.include "routines/arithmatic/mult.s"
|
||||||
.include "END.s"
|
.include "END.s"
|
||||||
|
|
Loading…
Add table
Reference in a new issue