Understanding Assembly Language: Solving AX Contents with MOV Command

In summary: For instance, the following code will move the value 12345678 into EAX, using the register EBX as the offset:MOV ECX,12345678[EAX+EBX*4]In summary, 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.
  • #1
math_girl
6
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
  • #2
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?
 
  • #3
8088 microprocessor

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

then whatever is at the position becomes AX?
 
  • #4
ax is a register
mov ax [blah] means move the contents of address [blah] into register ax
 
  • #5
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.
 
  • #6
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.
 
  • #7
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:

1. What is assembly language and why is it important?

Assembly language is a low-level programming language used to communicate directly with a computer's hardware. It is important because it allows programmers to write code that can be executed more quickly and efficiently than high-level languages.

2. How does assembly language differ from high-level programming languages?

Assembly language is a symbolic representation of machine code, meaning each instruction corresponds to a specific operation that the computer can understand. High-level languages, on the other hand, use English-like syntax and are translated into machine code by a compiler or interpreter.

3. What are some common issues that programmers may encounter when using assembly language?

Some common issues include a steep learning curve, the need for in-depth knowledge of computer architecture, and difficulties with debugging due to the lack of high-level features like variable names and functions.

4. Can assembly language be used for modern programming tasks?

Yes, assembly language can still be used for modern programming tasks, especially in areas where performance is critical, such as operating systems, device drivers, and embedded systems.

5. Are there any alternatives to using assembly language?

Yes, there are higher-level languages that are specifically designed for low-level programming tasks, such as C and C++. These languages offer a balance between efficiency and ease of use, making them popular alternatives to assembly language.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
13K
  • Programming and Computer Science
4
Replies
122
Views
13K
  • Programming and Computer Science
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
  • Programming and Computer Science
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
5K
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
Back
Top