Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Need help with an Assembly (x86) program?
I want to make a program which prints out numbers from 1 to 10, with the least amount of code. How can I achieve this?
2 Answers
- Anonymous9 years agoFavorite Answer
declare PrintOut Function first with one integer parameter to print out them on the screen.
then call that function like this :
======================
mov esi,1
Loop:
push esi
call PrintOut
inc esi
cmp esi,10
jle Loop
//put ur next code here...
- 9 years ago
You create a string that consists of 3 characters (= 3 bytes). The ascii character '1', then '0' and then a 0 byte for termination.
I don't know what assembler you are using so I don't know what syntax your assembler supports. But it's probably something like this.
db 49,48,0
or if your assembler supports characters you may be able to write
db '1', '0', 0
Then you just increase the value of the second byte in a loop and print out the string using the address of the second byte. At the end of your program you print out the string again but this time use the address of the first byte.
But that's not really the shortest one. The shortest possible way to write it is to define a string like this
db '1', 10, '2', 10, '3', 10, '4', 10, '5', 10, '6', 10, '7', 10, '8', 10, '9', 10, '1', 10, '1', '0', 0
and then print that string