1

I have error in line 13 called "Comma, colon or end of line expected". I want to write a program that's gonna write ascii heart at the X, Y possitions. As you can see i use pattern

(Y*80+X)*2

 org 100h

MOV AX,0A000H
MOV ES,AX
MOV AX,poz_y
MOV BX,80
MUL BX
ADD AX,poz_x
MOV BX,2
MUL BX
MOV DI,AX
MOV AL,9825
MOV BYTE PTR ES:[DI],AL
poz_x dw 160 
poz_y dw 100 

NOW:

Thanks to you all for your response :) Now Im trying to display ASCII character at this point, its compiling but doesnt do anything:

 org 100h

MOV AX,0b800h
MOV ES,AX
MOV AX,poz_y
MOV BX,80
MUL BX
ADD AX,poz_x
MOV BX,2
MUL BX
MOV DI,AX
MOV [ES:DI], word 2d04h     

mov ax, 0x4c00
int 21h

poz_x dw 160 
poz_y dw 100 
Mateusz
  • 19
  • 2
  • 1
    right after `move [di],al` you have to do something to stop execution (e.g. return to OS, return to called, whatever), otherwise the program will run into `dw 160 ....` and execute it – Tommylee2k Jun 23 '17 at 09:26

2 Answers2

1

The PTR operator is only used in MASM.

NASM doesn't use it, so in order to assemble your code, you will need to remove it:

MOV AX,0A000H
MOV ES,AX
MOV AX,poz_y
MOV BX,80
MUL BX
ADD AX,poz_x
MOV BX,2
MUL BX
MOV DI,AX
MOV AL,9825
MOV BYTE [ES:DI],AL      ; ← change this line
poz_x dw 160 
poz_y dw 100 

Note that the BYTE isn't actually needed here—the assembler can tell that you're storing a BYTE-sized value, since the source register is the BYTE-sized AL. However, it doesn't hurt to include it.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
gawi
  • 2,843
  • 4
  • 29
  • 44
  • I don't know nasm, is the "BYTE" really needed? since AL is moved it's clear it's byte size? – Tommylee2k Jun 23 '17 at 09:27
  • 1
    @Tommylee2k no, it's redundant. However, I always use the size specifier so that memory accesses stand out. To gawi, `es:[di]` should be `[es:di]` – Margaret Bloom Jun 23 '17 at 09:41
  • Thanks to you all for your response :) Now Im trying to display ASCII character at this point, its compiling but doesnt do anything: `org 100h MOV AX,0b800h MOV ES,AX MOV AX,poz_y MOV BX,80 MUL BX ADD AX,poz_x MOV BX,2 MUL BX MOV DI,AX MOV [ES:DI], word 2d04h mov ax, 0x4c00 int 21h poz_x dw 160 poz_y dw 100` – Mateusz Jun 23 '17 at 10:17
  • @MargaretBloom Hi, can you help me with something? If I want to put ASCII character in position X and Y, what should I add to my code? I thought it's gonna be okay, but nothing happen :/ I can't find solution, Im looking for 2hours – Mateusz Jun 23 '17 at 13:04
  • 2
    Hi @Mateusz, the correct way to ask a question on SO is, well... asking a question :) Writing code in the comment is frowned upon because it is unreadable, unsearchable and we are ultimately disturbing gawi since every comment generates an inbox notification for them. From what I can read: you are writing to column 160 and row 100 which are outside the 80x25 screen of the default DOS text mode. Further, the word 2d04h is writing the char with ASCII 04h (and attribute 2dh) that is not printable (switch the bytes). – Margaret Bloom Jun 23 '17 at 13:12
0

Thanks for help :)

 org 100h

MOV AX,0b800h
MOV ES,AX
MOV AX,poz_y
MOV BX,80
MUL BX
ADD AX,poz_x
MOV BX,2
MUL BX
MOV DI,AX
MOV [ES:DI], word 2d04h     

mov ax, 0x4c00
int 21h

poz_x dw 160 
poz_y dw 100 
Mateusz
  • 19
  • 2