0

Possible Duplicate:
NASM 16bit Intel

I am working on assembly code for simple microprocessor in microprocessor course. I am writing a program that:sums six elements, stored in memory starting from address 300, but ignores those that are 80 hex or above (>=80h) OR 20 hex or below (<=20h). The program should stop after 6 comparisons even numbers were added or not.

Here's my code:

    E 300 30 40 50 60 70 75
    A 100
100:MOV AX,2FF
103:ADD AX,1
106:CMP AX,306
109:JAE 11C
10B:MOV BL,[AX]
10E:CMP BL,20
111:JBE 103
113:CMP BL,80
116:JAE 103
118:ADD CL,BL
11A:JMP 103
11C:INT3

But I'm receiving an error on this line:

10B:MOV BL,[AX]

Does anyone know why?

1
  • You should really be more specific about the error. Or maybe you just don't want to be helped? Sep 28, 2012 at 21:08

2 Answers 2

5

16-bit addressing modes contain an optional offset, an optional base register (bx, bp), and an optional index register (si, di). That's it! "[ax]" ain't on the list. 32-bit addressing modes are more flexible - any General Purpose Register can be base and any GPR but esp can be index - and a "scale" of 2, 4, or 8 can be multipied by the index. Folks who have learned 32-bit addressing mode are delighted to forget 16-bit addressing mode... and apparently some folks have. :)

Best, Frank

1
  • Never did it down to 16 bit :-/ I like to see there are still people around who have not forgotten that stuff :-) Sep 29, 2012 at 6:36
0

Well, I don't know for sure but I'll guess that you're trying to copy the content of an extended (aX) register into the low part (bL) of another register.

Probably the lower part is just half the size of the extended...

3
  • no no this statement means that go to the memory address stored in register AX and copy the value stored in that memory location into BL. hint : the value is 2 hex bits so it comes in BL Sep 28, 2012 at 20:22
  • no way... AX contains the address to be read, and the byte from this address is moved to BL. Sep 28, 2012 at 20:27
  • -1: Your answer is incorrect. "you're trying to copy the content of an extended (aX) register into the low part (bL) of another register". That is incorrect. mov bl,[ax] fails because there is no such addressing form in 16-bit x86 assembly as [ax]. If there was, in Intel syntax it would copy the value of the byte from the memory offset defined by ax to bl. There is eg. mov al,[bx] which copies the value of the byte from the memory offset defined by bx to al.
    – nrz
    Sep 28, 2012 at 22:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.