How to Write an 8086 Assembly Program for Min/Max Comparison?

0
18
Asked By CuriousCoder85 On

I'm working on an exercise in 8086 Assembly language and I need some help. The task is to compare the values in the AL, BL, and CL registers to find both the minimum and maximum values among them. Once I determine these values, I need to store the minimum at the memory location with offset address 112H and the maximum at 114H. Does anyone have tips on how to approach this?

2 Answers

Answered By AssemblyAce32 On

When starting with assembly, it's helpful to first write a high-level version of your program that outlines how you'd solve the problem using pseudocode. This way, you can identify the equivalent assembly patterns for if-else structures or loops. Once you have that blueprint, translating it to assembly will be much easier. For your specific case, sketch out how to find the max and min values in a higher-level language, then turn that into assembly.

Answered By HelpfulHacker99 On

It sounds like you need to use the CMP instruction to compare the values in the registers. You can then use instructions like JA (jump if above) or JB (jump if below) to decide where to store your min and max values. After that, utilize the MOV instruction to store those results at the specified memory addresses.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.