PE11) Using Jump Instructions

Implement the following logic in assembly:

; Make a,b,c Random Numbers
if ((a > b) && (b > c))
printf("a is greater than b, b is greater than c\n";
else if ((a < b) && (b < c))
printf("a is less than b, b is less than c\n");
else if ((a == 0) || (b == 0))
print("Either a or b is zero\n");
else
printf("Either a equals b or b equals c. None are zero.\n");

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE12) Least Common Multiple

The Least Common Multiple (LCM) of two integers is the lowest positive integer that is perfectly divisible by both integers.   The LCM algorithm involves integer division in a loop, described by the following pseudocode:

int LCM(int num1, int num2){
int max;
if (num1 > num2)
    max = num1;
else
    max = num2;
while(1)                       /* Always true. */
{
      if ( (max%num1==0) && (max%num2==0))
     {
         break;          /* while loop terminates. */
      }
      max = max + 1;
}
return max;
}

Implement this logic in assembly language.   Have the user input two numbers and find the LCD.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE13) College Registration Lab Using Jump Instructions

Look at the College Registration example from Section 6.7.3. Then do the following:

  • Recode the logic using CMP and conditional jump instructions (instead of the .IF and.ELSEIF directives).
  • Prompt the user for the grade average and credits values.
  • Perform range checking on the credit values.  It cannot be less than 1 or greater than 30.
  • Invalid entries should trigger an error message. Display a message that shows the outcome of the evaluation, such as “The student can register” or “The student cannot register”.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE14) Find Elapse Time For Searching An Array

First Fill a DWORD array with numbers 1-1000.   Then search that array for a number 0FFFFFFh times (to add time length).  Searching for the number 20. Then search for the number 950.   Print out the number of milliseconds it takes to search for them each.   Notice how fast it is to search for the smaller number.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE15) Shift Instructions And Extended Arithmetic Techniques

COMPUTE result = (4 * op1 + op2) / 2 using regular shift instructions (Part 1).
COMPUTE result = (4 * op3 + op4) / 2 using extended arithmetic techniques (Part 2).

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE16) Extended Arithmetic Techniques

Compute: result = (4 * op1 + op2) / 8  using extended arithmetic techniques.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE17) Calling Printf Using Macro

Write a macro named mCallC that can be used to call a C function from assembly.  Use Invoke.

Driver

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE18) Concatenate A String

Write a procedure named Str_concat that concatenates a source string to the end of a target string. Sufficient space must exist in the target string to accommodate the new characters.  Pass pointers to the source and target strings.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE19) Using Mul Imul Div And Idiv

Use the 32-bit versions of the mul, imul, div and idiv instructions.  Multiply two hexadecimals and show the results of your math.  Divide two hexadecimals and show the results of your math.  Come up with 4 equations using: (1 mul) (1 imul) (1 div) (1 idiv). For the mul and imul instructions, show both the hex and signed hex results.   For the div and idiv instructions, show both the quotient and remainder.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂

PE20) Push Numbers On Stack And Identify Locals, Parameters

Push 5 items on the stack.  Identify the locals and parameters in the memory window.

Show Code

Oops! You must be logged in as a PRO MEMBER to see the code for this post. If you're a returning member, please click the LOGIN tab above to log in. If you're not a member yet, head over the Home page and scroll down to SIGN UP 🙂