6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 2:52 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: U* and U/
PostPosted: Tue Jul 30, 2024 7:41 pm 
Offline

Joined: Sat Jun 22, 2024 6:21 am
Posts: 14
I have implemented these words for U* and U/ in figforth 6502.
When I try $100 $10 U* the answer is $0, the same with U/.
Are the routines correct?

Thanks for any help.
Jan



[code];
; U*
; SCREEN 23 LINE 1
;
L386 .BYTE $82,"U",$AA
.WORD L365 ; link to CMOVE
USTAR .WORD *+2
LDA 2,X
STA N
STY 2,X
LDA 3,X
STA N+1
STY 3,X
LDY #16 ; for 16 bits
L396 ASL 2,X
ROL 3,X
ROL 0,X
ROL 1,X
BCC L411
CLC
LDA N
ADC 2,X
STA 2,X
LDA N+1
ADC 3,X
STA 3,X
LDA #0
ADC 0,X
STA 0,X

L411 DEY
BNE L396
JMP NEXT
;
; U/
; SCREEN 24 LINE 1
;
L418 .BYTE $82,"U",$AF
.WORD L386 ; link to U*
USLAS .WORD *+2
LDA 4,X
LDY 2,X
STY 4,X
ASL A
STA 2,X
LDA 5,X
LDY 3,X
STY 5,X
ROL A
STA 3,X
LDA #16
STA N
L433 ROL 4,X
ROL 5,X
SEC
LDA 4,X
SBC 0,X
TAY
LDA 5,X
SBC 1,X
BCC L444
STY 4,X
STA 5,X
L444 ROL 2,X
ROL 3,X
DEC N
BNE L433
JMP POP/code]


Top
 Profile  
Reply with quote  
 Post subject: Re: U* and U/
PostPosted: Tue Jul 30, 2024 11:46 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
U* takes two unsigned single numbers and returns an unsigned double number result. With the numbers $100 and $10 the high cell of the result will be zero.
Likewise, U/ takes a double number unsigned dividend and a single number unsigned divisor. It returns a single number unsigned remainder and quotient


Top
 Profile  
Reply with quote  
 Post subject: Re: U* and U/
PostPosted: Wed Jul 31, 2024 12:08 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
If you are going to use the multiply and division routines from Fig-Forth, you might want to read this post on carry problems in U* and U/.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: agsb and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: