
jmp word ptr cs:table[bx] 正确
jmp word ptr table[bx] 错误
为什么第二条是错误的,据教程上所说,数据标号的默认段地址是cs段
而我下面使用top 为什么是正常的
如果我将table 与 top 的数据定义放到start (即程序入口)前 ,运行两次将发生错误
assume cs:code,ds:data
code segment
start:
mov ax,2000
mov ds,ax
mov si,0
mov dl,0
mov dh,0
call getstr
mov ax,4c00h
int 21h
getstr: push ax
getstrs: mov ah,0
int 16h ;接收键盘输入 ah返回扫描码 al返回ascii码
cmp al,20h
jb nochar ;ascii码小于20h说明不是字符
mov ah,0
call charstack ;字符入栈
mov ah,2
call charstack ;显示栈中的字符
jmp getstrs
nochar: cmp ah,0eh ;退格键的扫描码
je backspace
cmp ah,1ch ;enter键的扫描码
je enter
jmp getstrs
backspace: mov ah,1
call charstack ;字符出栈
mov ah,2
call charstack ;显示栈中的字符
jmp getstrs
enter: mov al,0
mov ah,0
call charstack ;0入栈
mov ah,2
call charstack ;显示栈中的字符
pop ax
ret
charstack: jmp short charstart
table dw charpush,charpop,charshow
top dw 0 ;栈顶(字符地址、个数记录器)
charstart: push bx
push dx
push di
push es
cmp ah,2