Skip to main content
Code Review

Return to Question

Notice removed Draw attention by Community Bot
Bounty Ended with SirPython's answer chosen by Community Bot
Tweeted twitter.com/StackCodeReview/status/678098222779375616
Notice added Draw attention by Bun
Bounty Started worth 100 reputation by Bun
deleted 15 characters in body; edited tags
Source Link
200_success
  • 145.6k
  • 22
  • 190
  • 479

I have the following algorithm to find a minimum of three input numbers:

min(a,b,c):
 x := a
 if b < x then x := b
 if c < x then x := c
 return x
end min(a,b,c)

I'm trying to implement a Mic-1 micro code following the algorithms above:

OP1, OP2, OP3 = any 16 bit 2s complement value

OPRES: 0
 .LOC 50
main: LODD OP1: push
 LODD OP2: push
 LODD OP3: push
 CALL min:
 INSP 2
 STOD OPRES
 HALT
min: LODL 1; OP1
 SUBL 2; OP2 - OP1
 JPOS op1small
 SUBL 3; OP3 - OP1
 JPOS op1small
op1small: 
 LODL 1
 RETN ; OP1

I'm pretty new to Mic-1 and would like to get any input on this Mic-1 code above. Is there a better or shorter way I can find a min of three numbers in Mic-1? Please advise.

I have the following algorithm to find a minimum of three input numbers:

min(a,b,c):
 x := a
 if b < x then x := b
 if c < x then x := c
 return x
end min(a,b,c)

I'm trying to implement a Mic-1 micro code following the algorithms above:

OP1, OP2, OP3 = any 16 bit 2s complement value

OPRES: 0
 .LOC 50
main: LODD OP1: push
 LODD OP2: push
 LODD OP3: push
 CALL min:
 INSP 2
 STOD OPRES
 HALT
min: LODL 1; OP1
 SUBL 2; OP2 - OP1
 JPOS op1small
 SUBL 3; OP3 - OP1
 JPOS op1small
op1small: 
 LODL 1
 RETN ; OP1

I'm pretty new to Mic-1 and would like to get any input on this Mic-1 code above. Is there a better or shorter way I can find a min of three numbers in Mic-1? Please advise.

I have the following algorithm to find a minimum of three input numbers:

min(a,b,c):
 x := a
 if b < x then x := b
 if c < x then x := c
 return x
end min(a,b,c)

I'm trying to implement a Mic-1 micro code following the algorithms above:

OP1, OP2, OP3 = any 16 bit 2s complement value

OPRES: 0
 .LOC 50
main: LODD OP1: push
 LODD OP2: push
 LODD OP3: push
 CALL min:
 INSP 2
 STOD OPRES
 HALT
min: LODL 1; OP1
 SUBL 2; OP2 - OP1
 JPOS op1small
 SUBL 3; OP3 - OP1
 JPOS op1small
op1small: 
 LODL 1
 RETN ; OP1

I'm pretty new to Mic-1 and would like to get any input on this Mic-1 code above. Is there a better or shorter way I can find a min of three numbers in Mic-1?

Source Link
Bun
  • 83
  • 5

Implementing min of 3 numbers in Mic-1 code

I have the following algorithm to find a minimum of three input numbers:

min(a,b,c):
 x := a
 if b < x then x := b
 if c < x then x := c
 return x
end min(a,b,c)

I'm trying to implement a Mic-1 micro code following the algorithms above:

OP1, OP2, OP3 = any 16 bit 2s complement value

OPRES: 0
 .LOC 50
main: LODD OP1: push
 LODD OP2: push
 LODD OP3: push
 CALL min:
 INSP 2
 STOD OPRES
 HALT
min: LODL 1; OP1
 SUBL 2; OP2 - OP1
 JPOS op1small
 SUBL 3; OP3 - OP1
 JPOS op1small
op1small: 
 LODL 1
 RETN ; OP1

I'm pretty new to Mic-1 and would like to get any input on this Mic-1 code above. Is there a better or shorter way I can find a min of three numbers in Mic-1? Please advise.

lang-lisp

AltStyle によって変換されたページ (->オリジナル) /