I’m trying to learn Assembler and following a tutorial, and the first examples worked perfectly. I know a bit of the basics, but I’m having problems with variables. Here’s the code I’m trying to compile:
leftbr db "("
rightbr db ")"
input db
start:
mov ah,08
int 21h
mov input,al
output:
mov dl,leftbr
mov ah,02
int 21h
mov dl,key
int 21h
mov dl,rightbr
int 21h
exit:
mov ah,4ch
mov al,00
int 21h
It crashes at “input db” saying “invalid argument”. If I change it to “input db “” ” then it crashes at “mov input,al” claiming “invalid operands”. I changed it to the following and it now works.
start:
mov ah,08
int 21h
mov [input],al
output:
mov [leftbr], "("
mov [rightbr], ")"
mov dl,[leftbr]
mov ah,02
int 21h
mov dl,[input]
int 21h
mov dl,[rightbr]
int 21h
exit:
mov ah,4ch
mov al,00
int 21h
leftbr db 0
rightbr db 0
input db 0
The line
mov input, altries to move al into the value defined by the lineinput db 0, e.g. the compiler translates it intomov 0, al. What you want to do, is move al to the position “input”, so I guess (ASM coding was some time ago for me)mov [input], alormov byte ptr:[input], alwould work better.Edit: this is what displays “(a)” for me. Running CrunchBang Linux/Wine/FASM for windows.