Question

Need help with x86 NASM Assembly Arrays. I cannot find a clear explanation on the internet...

Need help with x86 NASM Assembly Arrays. I cannot find a clear explanation on the internet of how to print arrays and sort through them. So far I only know how to declare an array.

Here is my code: ARRAY DW 0, 32, 54, 26, 78, 10, 12, 44, 16, 18, 13, 72, 24, 86, 9, 30

Please show me how I would go about printing this array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You cannot print a number, you first need to convert it to ASCII. For example:-

  1. include '../../include/syscalls32.inc'
  2. section .bss
  3. section .data
  4. array dd 1,2,3,4,5
  5. arraylen equ ($ - array) / 4 ; array length * 4 = number of elements
  6. section .text
  7. global _start:
  8. _start:
  9. mov esi, array ; get pointer to array
  10. mov edi, arraylen - 1 ; edi = number of array elements
  11. .PrintArray:
  12. mov edx, 1 ; print 1 byte
  13. mov ecx, [esi] ; get current array element
  14. add ecx, 48 ; add 48 to convet to ASCII
  15. push ecx ; push to stack since we need an address of item to print
  16. mov ecx, esp ; mov address of char to ecx
  17. mov ebx, stdout
  18. mov eax, sys_write
  19. int 80h ; now print it
  20. pop ecx ; balance stack
  21. add esi, 4 ; get next element, 4 because it's an array of dwords
  22. dec edi ; decrease loop counter
  23. jns .PrintArray ; if edi ! -1 continue loop
  24. .PrintLineFeed:
  25. sub esp, 4
  26. mov byte [esp], 10
  27. mov edx, 1
  28. mov ecx, esp
  29. mov ebx, stdout
  30. mov eax, sys_write
  31. int 80h
  32. add esp, 4 ; not needed since next call is exit, but learn good techniques.
  33. exit:
  34. mov ebx, 0
  35. mov eax, sys_exit
  36. int 80H
Add a comment
Know the answer?
Add Answer to:
Need help with x86 NASM Assembly Arrays. I cannot find a clear explanation on the internet...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • I need to develop the 7 functions below into the main program that's given on top...

    I need to develop the 7 functions below into the main program that's given on top Write a C program to create array, with random numbers and perform operations show below. Il Project 3 (53-20). 1 Projects CS5,00 This file contains the function Programcution Dagine and one include <timo // Defining some constants definer_SIZE 20 define LOVE LIMIT 1 eine UPR UNIT define TALSE eine Tut 1 wold randomizery (int[], int, Int, int) wold pinay in. St, Int); En find...

  • The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random...

    The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random numbers from 1 to 100. – It asks the user for an index value between 0 and 99. – Prints the element at that position. – If a number > 99 is entered by the user, the class will abort with an ArrayIndexOutOfBoundsException • Modify the ExceptionLab: – Add a try-catch clause which intercepts the ArrayIndexOutOfBounds and prints the message: Index value cannot be...

  • I literally have no idea what I’m doing. Help!!! Please show work!! Write an essay using...

    I literally have no idea what I’m doing. Help!!! Please show work!! Write an essay using Word and post it as an attachment to the discussion. Cover the following points. Choose a data set from Stat Disk using one of the following files from 13th Edition Elementary Statistics: Oscar Winner Freshman 15 Word Count Garbage Weights Passive and Active Smoke If the file contains more than one variable, choose a quantitative variable. Create a histogram using your chosen variable and...

  • I need help making this work correctly. I'm trying to do an array but it is...

    I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...

  • Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a =...

    Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a = [ [93, 80, 99, 72, 86, 84, 85, 41, 69, 31], [15, 37, 58, 59, 98, 40, 63, 84, 87, 15], [48, 50, 43, 68, 69, 43, 46, 83, 11, 50], [52, 49, 87, 77, 39, 21, 84, 13, 27, 82], [64, 49, 12, 42, 24, 54, 43, 69, 62, 44], [54, 90, 67, 43, 72, 17, 22, 83, 28, 68], [18, 12, 10,...

  • Hallo! I have a problem in my code, I need help please in java code. My...

    Hallo! I have a problem in my code, I need help please in java code. My task is : Write a program that can read a text from a file and do frequency analysis on the letters that occur . To store information (frequency) you must use an array. Tip! The place where you collect the frequency of eg the letter A is the equivalent of the ASCII code of "A" ie 65. The array should be 127 elements. For...

  • Question 1 Question 2 Answer last part Question 3: Do a graph for actors and actresses...

    Question 1 Question 2 Answer last part Question 3: Do a graph for actors and actresses Question Help 4.1.5 Which of the following values cannot be probabilities? 0.03, 1.38, 5/3. 2,0. -0.52,1. 3/5 Select all the values that cannot be probabilities. A. 5 B. 0 C. -0.52 D. 3 5 E. 2 F. 0.03 G. 1 H 1.38 3.3.33 Question Help Use the same s Use the boxplot ling data sets Pulse rates for men and women Click the i...

  • Hello, I need help with the question 6. I don't understand what is asking. I have...

    Hello, I need help with the question 6. I don't understand what is asking. I have provided my work and I hope I can follow along with your step by step guidance. Thank you! WHAT-IF ANALYSIS 6. Wilson initially invested $9,000 in the business. Could he have invested less? How little could he have invested initially and never have his cash balance go below zero? To help different amounts in cell B8 to help determine an answer. When you have...

  • so i have my c++ code and ive been working on this for hours but i...

    so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT