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.
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
Get Answers For Free
Most questions answered within 1 hours.