wu :: forums
« wu :: forums - How to divide with SIC sbn instruction »

Welcome, Guest. Please Login or Register.
Apr 25th, 2024, 1:18pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Eigenray, ThudnBlunder, towr, Icarus, SMQ, william wu, Grimbal)
   How to divide with SIC sbn instruction
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: How to divide with SIC sbn instruction  (Read 7024 times)
MOR
Newbie
*





   


Posts: 2
How to divide with SIC sbn instruction  
« on: Mar 25th, 2013, 2:26am »
Quote Quote Modify Modify

Hello there,
 
I want to implement the C code  
Code:
c = a div b;

on SIC with sbn instruction.
Any help with this?
 
The command does the following:  
 
sbn a,b,c # Mem[a] = Mem[a] – Mem[b];if (Mem[a]<0) go to c  
 
I am looking forward to hearing from you and i would appreciate any kind of help. thank you.
IP Logged
akasina9
Newbie
*



x = 0x2B | ~ 0x2B. x is the question

   


Gender: male
Posts: 9
Re: How to divide with SIC sbn instruction  
« Reply #1 on: Apr 2nd, 2013, 9:29pm »
Quote Quote Modify Modify

You can look at division as a subtraction loop. The following code block assumes that the initial instruction starts at address n:
 
Code:
sbn u, u   # Initialize u to 0
sbn c, c   # Initialize c to 0
sbn u, ONE   # Initialize u to -1
sbn a, b, n+6   # Subtract b from a until it is less than  zero
sbn c, u   # increment c by one each time a is positive
sbn ZERO, ONE, n+3   # Unconditional jump to the subtraction step
exit
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board