Question

Please only simple assembly language Create a program to use ecx to count from the value...

Please only simple assembly language

Create a program to use ecx to count from the value in eax to the value in ebx. So, for example, if eax contains 5 and ebx contains 9, then you should have a loop in which ecx takes the values 5, 6, 7, 8, and 9. Verify that your program runs using the debugger.

Homework Answers

Answer #1

Live Demo

section    .text

   global _start         ;must be declared for using gcc

_start:                     ;tell linker entry point

   mov eax, [num1] ;move number 5 to eax

   mov     ebx, [ num2] ;move number 9 to ebx

   mov   [count],eax ; move 9 to count space

   next:

   mov   ecx,count ; move count to ecx

   mov   edx, 2 ;print the value of ecx using the following statements

   mov   ebx,1 ;file descriptor (stdout)

   mov   eax,4 ;system call number (sys_write)

   int   0x80 ;call kernel

   inc   ecx ; increment ecx by 1

   mov   [count],ecx ;move the increment value to count

   cmp   ecx,ebx ;compare the value of ecx with ebx

   jne   next ;if ecx is not equal to ebx the goto next

   mov   eax, 1 ;exit the program

   int   80h

section    .data

      num1 dd '5'

   num2 dd '9'

   segment .bss

   count resb 2

output

5

6

7

8

9

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a simple ARM assembly language program that finds the mean (as an integer) of all...
Write a simple ARM assembly language program that finds the mean (as an integer) of all values of an integer array. When your program starts, you should assume that r0 contains the address of the array and r1 contains the number of integers in the array. When you program finishes, the mean should be stored in r2. You may use other registers as stack registers.
Implement the following expression in assembly language:                                  &nb
Implement the following expression in assembly language:                                                 BX = –val2 + 7 - (- val3 + val1) * 2 Assume that val1, val2, and val3 are 8-bit integer variables Initialize val1 with 12, val2 with 9, and val3 with 2 You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. Use ONLY mov, add, sub, movzx, movzx, or neg instructions whenever needed. Use the debugger to verify your answer. Please answer using this format for...
PLEASE SOLVE WILL RATE AND THUMBS UP Simple assembly code question: In this question you will...
PLEASE SOLVE WILL RATE AND THUMBS UP Simple assembly code question: In this question you will write a simple program to loop through an array (i.e., writing while statements in assembly) of non-zero numbers. Write an LC3 assembly program for converting a list of non-zero integers into their absolute values. The program starts at x3000. It will first load the address ARRAY of the start of the list into register R0. After this, R0 now contains the location in memory...
Follow the instructions below to create a full running Assembly program: Create a ​WORD ​sized array...
Follow the instructions below to create a full running Assembly program: Create a ​WORD ​sized array with ​5​ elements of ​A2D5h ​using the ​DUP​ operator. Move the ​OFFSET ​of this array into register ​ESI​. Move the number of elements in the array initialized using the ​LENGTHOF​ instruction and move it into ECX as your loop counter. Create a ​LOOP​ that adds the value 1F33h to each element. Traverse through the array by adding the size of each element to the...
In assembly masm use the code below! Write a program that reverse a string using indirect...
In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ;...
Write an assembly program to compute the following expressions Create a list named ‘z’ of size...
Write an assembly program to compute the following expressions Create a list named ‘z’ of size 3 using DUP operator. Leave the list ‘z’ uninitialized. You can denote the items in the list as [z0, z1, z2]. z0 =x+13 z1 = y-x z2= r+z1-13 Where x, y, r are 16-bit integer memory variables. x = 7, y = 20, r = 4 Use the debugger to verify your answer. Please answer using this format for code: .386 .model flat, stdcall...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your variables here .code main PROC    ; write your assembly code here    INVOKE ExitProcess,0 main...
Using a loop (not the output format character %o), create a program that takes a positive...
Using a loop (not the output format character %o), create a program that takes a positive integer n, and then displays the polynomial for the octal representation of that integer. Use successive division, as demonstrated in the binary conversion example from the lesson, to do this. For example, for n = 157, the program should output the following: 157 = + (5 * 8^0) + (3 * 8^1) + (2 * 8^2) When this part is working properly, “surround” this...
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
In C programming language please. -Construct a program that will make use of user defined functions,...
In C programming language please. -Construct a program that will make use of user defined functions, the do/while loop, the for loop and selection. -Using a do/while loop, your program will ask/prompt the user to enter in a positive value representing the number of values they wish to have processed by the program or a value to quit/exit. -If the user enters in a 0 or negative number the program should exit with a message to the user indicating they...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT