Understanding Assembly Language: Solving AX Contents with MOV Command

Click For Summary

Discussion Overview

The discussion revolves around understanding the assembly language command "MOV AX, [SI]" in the context of the 8088 microprocessor. Participants explore the implications of this command, including how to determine the contents of the AX register after execution, the meaning of the brackets in the command, and the addressing modes involved.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • Some participants clarify that the brackets indicate the contents of a memory address, not the direct value of the SI register.
  • One participant explains how to calculate the physical address using the segment and offset values, suggesting that the contents at that address will be moved into AX.
  • Another participant notes that Intel processors do not restrict 16-bit values to even byte boundaries and discusses the little-endian format affecting how values are stored in AX.
  • Some participants mention the use of a debugger to observe register and memory contents, particularly in the context of MS-DOS.
  • There is a discussion about the LEA instruction, which loads effective addresses and operates differently than MOV, with examples provided for clarity.
  • One participant highlights the historical context of instruction times and the efficiency of using LEA over ADD in certain scenarios.

Areas of Agreement / Disagreement

Participants generally agree on the basic function of the MOV command and the meaning of the brackets, but there are varying interpretations regarding the specifics of addressing modes and the implications of using LEA versus MOV. The discussion remains somewhat unresolved with multiple perspectives on the nuances of assembly language operations.

Contextual Notes

Some limitations include potential misunderstandings about the addressing modes and the specific behavior of the MOV and LEA instructions in different contexts. There are also unresolved assumptions regarding the use of specific debuggers and their capabilities.

math_girl
Messages
6
Reaction score
0
DS = 1342, SI = 0111.

I'm trying to figure out the contents of AX after this command?

MOV AX, [SI]

Can someone point me in the right direction?
 
Physics news on Phys.org
math_girl said:
DS = 1342, SI = 0111.

I'm trying to figure out the contents of AX after this command?

MOV AX, [SI]

Can someone point me in the right direction?

Which processor is this for? What do the [] brackets mean in that assembly language construct? What documentation do you have for this assembler?
 
8088 microprocessor

do I find the the Physical Address is 13420 + 0111 = 13531 = 1342:0111

then whatever is at the position becomes AX?
 
ax is a register
mov ax [blah] means move the contents of address [blah] into register ax
 
math_girl said:
I find the the Physical Address is 13420 + 0111 = 13531 = 1342:0111 ... then whatever is at the position becomes AX?
Yes. Intel processors don't care if a 16 bit value is on an odd byte boundary. Note that little endian format is used, so the low order byte is first.

If [13531] = 34 and [13532] = 12, then AX becomes 1234.
 
math_girl said:
DS = 1342, SI = 0111.

I'm trying to figure out the contents of AX after this command?

MOV AX, [SI]

Can someone point me in the right direction?

Do you have some kind of debugger to work with, particularly one that shows the contents of the registers and memory locations? If you're working with MS-DOS, there is a very primitive one named debug.exe that can show this information.

It has been a while since I did any 8088 assembly, so I'm a little rusty. I seem to recall that the brackets ([]) indicate that you're not moving the contents of SI into AX, but instead are moving the contents of the memory location pointed to by the SI register. If my memory is correct, the MOV instruction won't move 0111 into AX; instead it will move the value at memory location DS:0111 into AX.
 
The [] just means that the operand is the content of a memory address. The two other operand options are an immediate or a register. One exception is LEA (load effective address): LEA AX,[SI] would load the effective address into AX (not including the DS part). In this case AX ends up with the value 0111 instead of the content of [13531]. The Intel cpu's don't have a indirect addressing mode, the equivalent of a [[13531]].

Back in the days of real 8088's and when people cared about instruction times, LEA was faster than add, but it can only be used with registers BP, BX, SI, or DI as operands, or with BP|BX + SI|DI.

LEA BX,1234[BX] (or LEA BX,[BX+1234]) is the same as ADD BX,1234, but it executes faster.

Also the destination register can be diferent, such as LEA AX, 1234[BX+SI] => AX = (1234 + BX + SI).

In 32 bit mode, there is an optional "sib" byte appended to the opcode, allowing for more addressing modes, which allows indexing via any register, and scaling (1x -> 8x) on the second index:

MOV ECX,12345678[EAX+EBX*4]
LEA EAX,[EAX*8] ; multiply by 8 or shift left 3 ; probably not faster than SHL EAX,3

For other examples of "clever" coding, look at the output from microsoft compilers using the -Fa option to produce assembly code.
 
Last edited:

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 13 ·
Replies
13
Views
16K
  • · Replies 29 ·
Replies
29
Views
4K
Replies
8
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 122 ·
5
Replies
122
Views
17K
  • · Replies 5 ·
Replies
5
Views
4K