ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
View Poll Results: Did you find this question to be a cool post?
Yes I did!
0
0%
I like Assembly Language so yea.
0
0%
No I most certainly did not!
0
0%
No but go ahead.
1
50.00%
Stop posting maniac!
1
50.00%
Multiple Choice Poll. Voters: 2. You may not vote on this poll
I just want to inquire for small talk if there is a way to do
the following without all the arbitrary source.
So you don't exactly have to read it I am taking a byte and
printing its decimal number the code below is the tenth place
of the byte I am trying to print.
Please excuse the poor source but my editor has a mind of it's own.
Also answer my poll all casual comedy is welcome.
Code:
MOV BH, 100
CMP BL, BH
JL PRINT_INTEGER.SKIP100
MOV AL, 1
MOV BH, 200
CMP BL, BH
JL PRINT_INTEGER.SKIP200
SUB BL, 200
MOV BL, '2'
INT 21H
JMP PRINT_INTEGER.SKIP100
.SKIP200
SUB BL, 100
MOV BL, '1'
INT 21H
.SKIP100
1) Why are you writing asm code for a 16 bit MS-DOS environment? If someone told you that is a place to start before learning modern asm, they misled you.
2) Why are you trying to learn ASM before you learn the basics of programming? Given the terrible formatting, I chose not to examine every detail of your code. But from an overview, I can see you are doing significant excess work as a result of not thinking like a programmer. Before you learn ASM, learn how to use more thought in order to use less code. That type of thinking applies across a range of languages.
"This is what language compilers are for." In almost every case, it's entirely pointless for you to waste your time coding a complete algorithm in assembler. The odds are much better that an optimizing compiler will do a better job at producing object-code than you will.
If you want to see how assembly-code is actually used "today," just look at the Linux kernel source-tree. You'll find that it's used in these ways:
For the necessarily architecture-specific "trampoline" code that is used when the computer is first IPLed started up.
For (once again, architecture-specific) subroutines which embody specific implementations of those functions. These subroutines are called by code that has been written in "C." The vast majority of the kernel is written in "C," and: There's A Reason For That.™
Quite frankly, today's microprocessors are not engineered to handle "human-generated" opcode sequences. They're designed to efficiently process the output of compilers ... which are, in turn, designed to generate outputs that can be efficiently processed. As Greyhound Bus Lines used to say, "and leave the driving to us.™" Sage advice.
Well i am just practicing assembly that's why I am using assembly language to do that. I was just inquiring if anyone here new any tricks. Thanks guys.
I was just inquiring if anyone here new any tricks.
Using a divide operation or even a subtract loop when you want an operation like divide is not a "trick".
Testing each of a uniform set of possibilities individually is not competent programming. There is almost always a simple way to generalize, so that far less code is needed to transform the desired input into the desired output.
If you are "practicing assembly," then I suggest that you confine your practice sessions only to realistic situations in which (these days ...) assembly-language programming is actually used. Just look at the /arch subdirectory of any Linux-kernel source tree: almost all of the entries in there are C-language source files with asm { ... } directives. The only real exceptions to be found are those that have to do with the "trampoline" (pre-boot ...) phase.
There is a reason for this. Modern microprocessors are not engineered to handle human-generated assembly code! They are prepared to expect the output of compilers which have been built according to the "suggestions" of the silicon-chip companies. asm {} is therefore reserved only for very short pieces of code that cannot be expressed in any other way.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.