News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Urgent Intel help

Started by Jalano, February 03, 2007, 08:38:01 PM

Previous topic - Next topic

Jalano

I  am  beginner, trying to use masm6.11.  (Intel 8086)
How do I point to these values without using "inc" or  #[SI].
The displacement value comes frm a memory location that produces various values based on
previous cod conditions.  eg.  I might table to be loaded in SI  ("DATA_1" amount of times)

          ORG 100H
TABLE     DB    '0', '1', '5' ,'3' ,'4' ,'8' ,'6' ,'7' ,'8' ,'9'

if I do

"mov si, OFFSET TABLE "

Si would hold the value for 0, which is 30H.

Let's say I want to point to '8'.  What do I do without having to tyoe "8" in the code.


I really really need help as soon as possible.

TNick

Hello! Welcome aboard!


mov   si,  TABLE
mov   si,  TABLE[0]
;both instructions put "0" in si
mov   si,   TABLE[2]
;put "5" in si


This is a quick answer, there are another ways. You should do some reading, 'cause this stuff is in the intro part of any material concerning assambly!
Forum search and your favorite search engine can do the job! :U

Regards,
Nick

Jalano

Ok, but that is something that I did before.  However, I am upgrading a program that does division, and stores the remainder in a memory location "REM". 
si is alerady OFFSET to table. 
Let's say the contents of REM is suppose to take SI to a specific location in "TABLE" so that I could put it into a register for the 21H INT.
I.E.  I am suppose to get the correct displacement without typing in the displacement value.

              ORG   100H
REM          DB   ?
             
              ORG   140H
TABLE       DB   '0', '1', '2', '3', '4', 5', '6', '7', '8', '9'


My professor doesn't want me to do
 
                               mov al TABLE[3]

He wants the contents of "REM" to take it there. 
It has to be that way for later expansion, if "TABLE" contents change to Letters and HEX values.
I'm working hard at it, but no progress.

                         
note.  "REM" is remainder from a division function.

eek

mov bp,TABLE
mov al,[bp+REM]

sinsi

Light travels faster than sound, that's why some people seem bright until you hear them.

Jalano

Those do not work. 
Every other part of my code works but that part.  I have tried other ways pn my own, but It just ended up giving me the correct values, but not from mthe tabel.  I found that out when I re-arranged the numbers in the table to test it.

sinsi

I really must learn to read the whole post... ::)
QuoteLet's say the contents of REM is suppose to take SI to a specific location in "TABLE" so that I could put it into a register for the 21H INT.
Try this
  movzx bx,rem
  mov al,[bx+si]

Light travels faster than sound, that's why some people seem bright until you hear them.

Jalano

It says.
Instruction or register not accepted in current cpu mode.

Is movzx correct?

eek

 :lol

mov bp,TABLE
add bp,REM
mov si,bp
mov al,[si]

Jalano

The correct value shows up in si  and bp, but nothing goes into al.   At the same time, the value that goes into  si may look correct because the table goes in ascending order,  but when I changed the values in the table,  It was not actually pointing at the values "in" the table (it just added values to the 30H).  I already got this far since a week ago.   But, I am learning through u guys.

sinsi

  mov bl,rem
  sub bh,bh
  mov al,[bx+si]


movzx is a 386(?) instruction...
Light travels faster than sound, that's why some people seem bright until you hear them.

Jalano


sinsi

If SI points to TABLE and REM has a valid (0,1,2...9) value then it should work. Post all of your code. Or fail your assignment  ::).
Light travels faster than sound, that's why some people seem bright until you hear them.

Jalano

This is suppose to be part of 300 line code.   all other parts work.  I see nothing going into al.
     .MODEL SMALL
        .STACK 64
        .DATA

         ORG    100H
TABLE   DW      '0','1','2','3','4','5','6','7','8','9'

        ORG    140H
REM      DB    05H
        .CODE
          .STARTUP

PNT    PROC
  mov si, TABLE
  mov bl,REM
  sub bh,bh
  mov al,[bx+si]
   ret
PNT    ENDP
           END

sinsi

Since you've declared TABLE to be words, you need BX*2

  mov bl,rem
  sub bh,bh
  shl bx,1
  mov al,[bx+si]

and use

  mov si,OFFSET TABLE

since you want the address of TABLE, not its first element
Light travels faster than sound, that's why some people seem bright until you hear them.