Consider the following
JMP start
leftbr DB '('
rightbr DB ')'
key DB ''
start:
MOV AH, 08
INT 21h ; Read keypress
MOV [key], AL ; Store the key pressed in variable 'key'
output:
MOV DL, leftbr ; Move the value from 'leftbr' to DL
MOV AH, 02
INT 21h ; Should output (
MOV DL, [key] ; Put the value from 'key' in the DL register
INT 21h ; Output 'key'
MOV DL, rightbr
INT 21h ; Output )
exit:
MOV AH, 4Ch
MOV AL, 00
INT 21h ; Terminate the program
The output I get from this in DosBox is:
According to this site (https://www.ascii-codes.com/) the smiley face and heart are the STX and ETX characters, instead of the brackets as expected.
If I alter the start:
block as follows I get the correct output:
start:
MOV BH, "("
MOV BL, ")"
MOV [leftbr], BH
MOV [rightbr], BL
MOV AH, 08
INT 21h ; Read keypress
MOV [key], AL ; Store the key pressed in variable 'key'
Can anyone explain why this would be? I should be able to declare a variable with a initial value.