Results 1 to 2 of 2

Thread: Not your average question...

  1. #1

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Arrow

    One reason this isn't your average C forum question is that it isn't really about C

    This is closest really to assembler, so I've posted the thread there. I know you C programmer people tend to work in ASM quite often, and generally work at a lower level, so if you wouldn't mind, take a look would ya? Thanks

    http://forums.vb-world.net/showthrea...threadid=43228
    Harry.

    "From one thing, know ten thousand things."

  2. #2

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    In case anyone cares, this was my solution (couldn't get the simulator to work so I could test it) and I'm pretty sure it's right.
    Code:
    imul1	OPC=0x20					// Set OPC as a counter... OPC = 32
    imul2	MAR=SP-1; rd					// Read first operand (second word on the stack)
    imul3	H=TOS						// Operands are now in H and MDR, TOS freed to be accumulator
    imul4	TOS=0						// Clear accumulator.  One 0 just handled.
    imul5	MDR=MDR; SRA1; if (notLSB) goto imul17		// Check for 00, else carry on for 10
    imul6	TOS=TOS-H; SRA1					// 10 - subtract multiplicand, start the shift
    imul7	MDR=MDR; RROT					// Bitwise rotate on MDR, LSB has the next recode bit
    imul8	OPC=OPC-1; if (Z) goto imul18			// Decrement the counter (OPC), if it's 0 then we've finished
    imul9	MDR=MDR; SRA1; if (notLSB) goto imul14		// One 1 just handled, Check for 11/10 and skip one line if 10
    imul10	TOS=TOS; SRA1; goto imul10			// 11 so start a shift then check for 10
    imul11	TOS=TOS+H; SRA1					// 01 so add multiplicand then shift
    imul12	MDR=MDR; RROT					// Bitwise rotate on MDR, LSB has the next recode bit
    imul13	OPC=OPC-1; if (Z) goto imul19 else goto imul8	// Decrement counter.  Set JAM then set again if counter=zero
    imul14	TOS=TOS; SRA1; goto imul15			// 00 so middle of string of 0s - keep shifting.
    imul15	wr; goto imul20					// Write MDR to SP-1 (most significant word).  Skip next line.
    imul16	wr						// Extra end-point, due to the way mic-1 conditional jumps work
    imul17	MAR=SP						// Prepare to write LSW to top of stack.
    imul18	MDR=TOS; wr; goto Main1				// Write least significant word to top of stack.  End instruction
    That has to be the hardest piece of coursework I have ever had to do. Still, the lecturer said he would give people high marks (80%+) just for attempting this (I picked the hardest question ).
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width