flat assembler
Message board for the users of flat assembler.
Index
> DOS > Compare command |
Author |
|
Matrix 30 Oct 2004, 23:32
Hello,
you meant something like this? Code: ; COM file is loaded at CS:0100h ORG 100h MOV AX, 0B800H push ds MOV DS, AX MOV BX,0 MOV byte [BX],'x' MOV byte [BX+1],3 MOV byte [40],'+' MOV byte [41],5 pop ds MAIN: MOV AH,$10 INT 16H push ds push 0B800H pop ds add bx,4 MOV [BX],AL inc bx MOV byte [BX],4 sub bx,5 CMP AX,$4BE0 JE ML CMP AX,$4DE0 JE MR CMP AX,$50E0 JE MD CMP AX,$48E0 JE MU pop ds CMP AL,27 ; esc JE escape JMP MAIN escape: int 20h ML: add bx,2 MOV byte [BX],'L' inc bx MOV byte [BX],$F sub bx,3 pop ds JMP MAIN MR: MOV byte [BX+2],'R' MOV byte [BX+3],$F pop ds JMP MAIN MD: MOV byte [BX+2],'D' MOV byte [BX+3],$F pop ds JMP MAIN MU: MOV byte [BX+2],'U' MOV byte [BX+3],$F pop ds JMP MAIN |
|||
30 Oct 2004, 23:32 |
|
beppe85 30 Oct 2004, 23:37
gildash wrote:
Well, I see an ADD in the place of SUB...and you are not using the result of CMP. Usually after a CMP you writes a Jcc to do a jump. The subtraction(addition) takes place every time. |
|||
30 Oct 2004, 23:37 |
|
gildash2 31 Oct 2004, 01:54
the code doesnt work in my version of emu, could you perhaps point out what is specifically wrong with my code in that spot? because i had it once work perfectly and the CMP code was extremely familiar. what exactly could i change to make that section of my code work, rather than change the whole thing.
thank you so much for your continueing help |
|||
31 Oct 2004, 01:54 |
|
Matrix 31 Oct 2004, 09:23
i have changed your cmp ah, s to cmp ax,
and MOV AH,00H INT 16H to MOV AH,10H INT 16H and bios now returns extended scancodes (word in ax) so i used to use this function. what is the task of your code? what do you mean by emu? sorry for changing all, but i didn't understand what were you gonna do. however i'd recommend stosw and its nicer to use es as segment than ds, what if you start putting variables in video mem? |
|||
31 Oct 2004, 09:23 |
|
gildash2 31 Oct 2004, 12:03
ok im sorry for not properly explaining this. what i basically am doing here is im having the character '+' move when the up,down,left,right arrows are clicked on the keyboard. that works perfectly as you can see in the code. now, the thing that isnt working which i want to work is that when the location of bx ([bx]) hits or is equal to character '|' then i want it to move back 2 spaces, as if the character hit a wall and cannot pass. '|' is supposed to act as a barrier or a wall in a game that the character cannot pass. understand? what i have written in the code makes sense but is for some reason not working. it does this:
CMP [BX], '|' ;compares the position of BX to that character ADD BX, 2 ;basically if the comparison shows that it is equal, then the position in bx is subtracted by two, and moves the character back however, this is not working, im assuming that the code to fix this, or even do this task is simple, because i had done it before in almost the exact format. everything except the barrier code works. thank you again for your continueing help |
|||
31 Oct 2004, 12:03 |
|
Matrix 02 Nov 2004, 15:57
Here you are:
Code: ; COM file is loaded at CS:0100h barrier1=178 barrier2=177 ;barrier2=176 ORG 100h push es push $B800 pop es call cursoroff MOV word [ES:884],4 shl 8+barrier1 MOV word [ES:876],4 shl 8+barrier1 MOV word [ES:878+160],4 shl 8+barrier2 MOV word [ES:880+160],4 shl 8+barrier2 MOV word [ES:882+160],4 shl 8+barrier2 MOV BX,880 MOV word [ES:BX],3 shl 8+'+' MAIN: MOV AH,$10 INT 16H CMP AX,$4BE0 JE ML CMP AX,$4DE0 JE MR CMP AX,$50E0 JE MD CMP AX,$48E0 JE MU CMP AL,27 ; esc JE escape JMP MAIN escape: call cursoron pop es int 20h ; exit ML: mov ax,bx mov cl,160 div cl cmp ah,2 jb .skip cmp byte [ES:BX-2],barrier1 je .skip cmp byte [ES:BX-2],barrier2 je .skip MOV word [ES:BX],3 shl 8+' ' sub bx,2 MOV word [ES:BX],3 shl 8+'+' .skip: JMP MAIN MR: mov ax,bx mov cl,160 div cl cmp ah,158 jae .skip cmp byte [ES:BX+2],barrier1 je .skip cmp byte [ES:BX+2],barrier2 je .skip MOV word [ES:BX],3 shl 8+' ' add bx,2 MOV word [ES:BX],3 shl 8+'+' .skip: JMP MAIN MD: mov ax,bx mov cl,160 div cl cmp al,24 jae .skip cmp byte [ES:BX+160],barrier1 je .skip cmp byte [ES:BX+160],barrier2 je .skip MOV word [ES:BX],3 shl 8+' ' add bx,160 MOV word [ES:BX],3 shl 8+'+' .skip: JMP MAIN MU: mov ax,bx mov cl,160 div cl cmp al,1 jb .skip cmp byte [ES:BX-160],barrier1 je .skip cmp byte [ES:BX-160],barrier2 je .skip MOV word [ES:BX],3 shl 8+' ' sub bx,160 MOV word [ES:BX],3 shl 8+'+' .skip: JMP MAIN cursoron: ; Turns CURSOR ON. mov ah,1 mov cx,0x0607 int 10h ret cursoroff: ; Turns CURSOR OFF. mov ah,1 mov cx,0x1400 int 10h ret cursorhidden: ; Returns 1 if cursorhidden, 0 otherwise. mov ah,0x03 int 10h xor al,al cmp ch,$20 jne .skip mov al,1 .skip: ret |
|||
02 Nov 2004, 15:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.