8086 array offset address

Discussion in 'Programmer's Corner' started by ecjohnny, Feb 6, 2012.

  1. ecjohnny

    Thread Starter Senior Member

    Jul 16, 2005
    142
    0
    Hi
    Can anyone help me with basic 8086 programming. i need to display the offset address of an element in an array. For example address of arr[2], arr[6] etc...

    Here is what i've tried but i got a bunch of "rubbish" on display. It compile fine with no error/warning.

    data segment

    arr db 12,45,34,3 ;examples

    data ends

    code segment
    assume cs:code, ds:data
    start :


    MOV AH, 9
    LEA DX, arr+1 ;display arr[1]???
    INT 21H

    MOV AH, 4CH
    INT 21H


    code ends
    end start
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,432
    3,360
    INT 21h / AH=9 - output of a string at DS: DX.
    String must be terminated by '$'.
    Code ( (Unknown Language)):
    1.  
    2. example:
    3.   [FONT=Terminal][SIZE=3]        
    4.      [COLOR=#000064]org[/COLOR] 100h
    5.      [COLOR=#0000FF]mov[/COLOR] [COLOR=#C80000]dx[/COLOR], [COLOR=#000064]offset[/COLOR] msg
    6.      [COLOR=#0000FF]mov[/COLOR] [COLOR=#C80000]ah[/COLOR], 9
    7.      [COLOR=#0000FF]int[/COLOR] 21h
    8.      [COLOR=#0000FF]ret
    9.  
    10. [/COLOR] msg [COLOR=#000064]db[/COLOR] [COLOR=#800080]"hello world $"[/COLOR][/SIZE][/FONT]
     
    Last edited: Feb 6, 2012
  3. ecjohnny

    Thread Starter Senior Member

    Jul 16, 2005
    142
    0
    i still dont get it:confused:
    am i using the wrong interrupt? should i use ah = 02
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,432
    3,360
    You have to write a routine to convert the binary into a character format.
     
  5. ecjohnny

    Thread Starter Senior Member

    Jul 16, 2005
    142
    0
    Oh i see.. no wonder i got bunch of funny chars. just to clarify so my offset address is in binary form? or hexadecimal? to convert it to ASCII for display.

    Thanks
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,432
    3,360
    This is always a misunderstanding with someone not in the know.
    Everything is always in binary. Hexadecimal is all smoke and mirrors.

    As my other quote: There are only 10 types of people in this world, those who understand binary and those who don't.
     
Loading...