1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Assembly Language issue

  1. Jul 9, 2009 #1
    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?
     
  2. jcsd
  3. Jul 9, 2009 #2

    berkeman

    User Avatar

    Staff: Mentor

    Which processor is this for? What do the [] brackets mean in that assembly language construct? What documentation do you have for this assembler?
     
  4. Jul 9, 2009 #3
    8088 microprocessor

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

    then whatever is at the position becomes AX?
     
  5. Jul 9, 2009 #4

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    ax is a register
    mov ax [blah] means move the contents of address [blah] into register ax
     
  6. Jul 11, 2009 #5

    rcgldr

    User Avatar
    Homework Helper

    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.
     
  7. Jul 12, 2009 #6

    Mark44

    Staff: Mentor

    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.
     
  8. Jul 12, 2009 #7

    rcgldr

    User Avatar
    Homework Helper

    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: Jul 12, 2009
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Assembly Language issue
  1. Assembly Language (Replies: 0)

  2. Assembly Language (Replies: 13)

Loading...