Problems with CMP and JZ
So far I've learned some assembly, and i've tried using cmp and jz as a means of somewhat if statements. I just started learning so I don't know much complex stuff, but here is the code
The problem is, in my POLLING section, only The ESC does what it's supposed to do, close it. Any other key will do the same thing, draw a pixel up. So I'm guessing it's jumping straight to UP
The problem is, in my POLLING section, only The ESC does what it's supposed to do, close it. Any other key will do the same thing, draw a pixel up. So I'm guessing it's jumping straight to UP
Code:
;simple drawing program using bios and dos interrupts ;ASCII codes, using the numpad ;Up(8) 56 ;Down(2) 50 ;Left(4) 52 ;Right(6) 54 ;ESC 27 org 100h INIT: mov ah, 00 ;to set video mode mov al, 13 ;graphics mode 320x200 256 color vga int 10h ;change mode mov bh, 00 ;change video mode mov cx, 160 ;set x mov dx, 100 ;set y -should be middle of screen..hopefully POLLING: mov ah, 08 ;to get input without echo, return stored in al int 21h ;get the input cmp al, 56 ;is the return value up? jz UP ;if so jump to UP cmp al, 50 ;is the return value down? jz DOWN ;if so jump to DOWN cmp al, 52 ;is the return value left? jz LEFT ;if so jump to LEFT cmp al, 54 ;is the return value right? jz RIGHT ;if so jump to RIGHT cmp al, 27 ;is the return value esc? jz EXIT UP: dec dx ;decrement dx, the Y axis..The lower X is higher on the screen jmp DRAW ;jump to DRAW ^^ at least i'm pretty sure it is. DOWN: inc dx ;increment dx, the Y axis jmp DRAW LEFT: dec cx ;decrement cx, the X axis jmp DRAW RIGHT: inc cx ;increment cx, the X axis jmp DRAW DRAW: mov ah, 0ch ;for drawing pixel mov al, 0Fh ;color int 10h ;draw pixel. bh(page) cx, dx(axes) are already set jmp POLLING ;go back to get more presses EXIT: mov ah, 00 ;to set video mode mov al, 03 ;80x25 16 color text mode int 10h ;return to video mode for dos int 20h ;terminate
