A hello world in Assebly language tha would show the first number that is greater than 80

# 
# Simple program to stop when it gets the first number greater than 80
#

.section .data
number_store: #fixed name for the address holding
    .long 34,78,23,90,12,234,76,23,1 #Numbers to be dealt with. 
.section .text
.globl _start

_start:
    mov $0, %esi #initialize the esi 
    mov number_store(, %esi, 4), %eax # load the first number on the eax register

    begin_loop:
        cmp $80, %eax #compare the value on eax with 80
        jge exit_door #yup exit if the comparison met..
        inc %esi
        mov number_store(,%esi,4), %eax #load the next number from the array
        jmp begin_loop #go back to the loop

    exit_door:
        mov %eax, %ebx #load the last value we have to ebx register
        mov $1, %eax # call the exit call here
        int $0x80 #interubt it

This will be running on the x86 processor.
To run it on the linux do the following from the command line:
The following command would- create the object file:

as greater.asm -o greater.o 

The next one will be the linker – we need it to create the executable

ld -o greater greater.0

and run it as

./greater

Now the value would be accumulated on the register ebx.. Since the exit parameter will be stored on the ebx, and we have a value being loaded on the ebx it will be just showing that:

echo $?

this is A HELLO WORLD TO ASSEMBLY

See how you would solve these known algorithm problems

Changing decimal number to its binary equivalent

testing k complementary pairs algorithm with junit

Find longest palindrom from sequence of characters

Get maximum occurring character

Kadane’s algorithm in C – Dynamic Programming

binary tree problems with solution

Java solution for checking anagram strings – tell if phrases are anagrams

Check if two strings are anagrams or not

Check if there are three numbers a, b, c giving a total T from array A

Finding missing numbers from billion sequential number list file

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*