General discussion

Locked

Programming in assembler

By viper2k29 ·
I am required to take an input from a user - a four digit code, store it in a register and then compare against a pre-stored value (stored in another register, another four digit code). I am a complete assembler novice and so need help with this.

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Programming in assembler

by epepke In reply to Programming in assembler

You haven't given many details. What assembler? What processor? What environment?

WRT your project, though, by far the most difficult part is going to be taking the input from the user. Everything else is trivial. With a four-digit code, theeasiest thing to do is to pack it into a 32-bit word and use some sort of comparison (depending on the assembler and your preference: cmp, xor, or sub) and then do a conditional jump based on what is in the flags register. A handful of instructionsat the most. Some processors have instructions to do packing of BCD easily; some you will have to dink with using shift instructions. In any event, it's simple, conceptually like this:

Start with rWhatever = 0;
For each of four input digits Shift rWhatever left 8 bits
Or it with the input digit

At the end, rWhatever is the BCD expression. Then just do a comparison to the other register holding the check code, similarly built up.

Collapse -

Programming in assembler

by viper2k29 In reply to Programming in assembler

The question was auto-closed by TechRepublic

Collapse -

Programming in assembler

by ms_saini3302 In reply to Programming in assembler

you can stroe input number in a array and then you can compare one by one digit with pre stroe digits. First try it your self.

Collapse -

Programming in assembler

by viper2k29 In reply to Programming in assembler

The question was auto-closed by TechRepublic

Collapse -

Programming in assembler

by viper2k29 In reply to Programming in assembler

I am using Motorola Assembler 68k.

Collapse -

Programming in assembler

by xorex In reply to Programming in assembler

See a book: A.Norton The Assembler Language.

Collapse -

Programming in assembler

by viper2k29 In reply to Programming in assembler

The question was auto-closed by TechRepublic

Collapse -

Programming in assembler

by xorex In reply to Programming in assembler

See a book: A.Norton The Assembler Language.

Collapse -

Programming in assembler

by viper2k29 In reply to Programming in assembler

The question was auto-closed by TechRepublic

Collapse -

Programming in assembler

by viper2k29 In reply to Programming in assembler

This question was auto closed due to inactivity

Back to Web Development Forum
10 total posts (Page 1 of 1)  

Related Forums