Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Example code. Makes Mario crazy.
- !Devidend = $55FFAA
- !Devisor = $FFFF
- ;$55FFAA/$FFFF = $56 R:#00
- main:
- print "breakpoint------------------------",pc
- REP #$20
- LDA.w #!Devidend ;\FFAA [AA FF]
- STA $00 ;/
- LDA.w #!Devidend>>16 ;\0055 [55 00]
- STA $02 ;/
- LDA.w #!Devisor ;\FFFF
- STA $04 ;/
- SEP #$20
- JSL MathDiv32_16
- rtl
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Unsigned 32bit / 16bit Division
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Arguments
- ; $00-$03 : Dividend
- ; $04-$05 : Divisor
- ; Return values
- ; $00-$03 : Quotient
- ; $04-$05 : Remainder
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- MathDiv32_16: REP #$20
- ASL $00
- ROL $02
- LDY #$1F
- LDA.w #$0000
- - ROL A
- CMP $04
- BCC +
- SBC $04
- + ROL $00
- ROL $02
- DEY
- BPL -
- STA $04
- SEP #$20
- RTL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement