有2个疑问求解答。拜托fmlyht了。

[复制链接]
查看11 | 回复1 | 2010-9-26 10:18:02 | 显示全部楼层 |阅读模式
问题1。2个直接定址表的区别是什么,什么时候该加0?

menu_tab dw offset b_menu1-offset boot+7c00h

fun_table dw offset reset_pc-offset boot+7c00h,0
上面的2个直接定址表的区别是一个后面要加个0,一个不加0,什么时候该加0,什么时候不用加0?
问题2。;Get the user input
choice: mov ah,0
---->下面开始读取键盘输入,判断调用哪个子程序。
int 16h

cmp al,'1'
----->这里是判断什么?然后转到choice.
jb choice
cmp al,'4'
----->这里是判断什么?然后转到choice.
ja choice

;Clear Screen first
call clear

;Call the sub function

sub al,'1'
----->这里为什么要al减一呢?
mov bl,4
mul bl
mov si,ax

mov bx,offset fun_table-offset boot+7c00h
call dword ptr es:[bx][si]

boot_ok:mov ax,4c00h

int 21h
------------------------------------------------------------------------------------
补上显示菜单的代码,以及子程序的直接定址表。
;Define the boot menu
b_menu1:db "1) Reset PC",0

b_menu2:db "2) Start system",0
b_menu3:db "3) Clock",0
b_menu4:db "4) Set clock",0

b_menu5:db "Please enter your choice:[1-4]",0
time_str:db "yy/mm/dd hh:mm:ss",0
set_clock_p:db "Please enter the new time(yy/mm/dd hh:mm:ss):",0
set_clock_s:db "__/__/__ __:__:__",0

set_clock_top dw 0
menu_tab dw offset b_menu1-offset boot+7c00h,offset b_menu2-offset boot+7c00h,offset b_menu3-offset boot+7c00h,offset b_menu4-offset boot+7c00h,offset b_menu5-offset boot+7c00h

fun_table dw offset reset_pc-offset boot+7c00h,0,200h,0,offset clock-offset boot+7c00h,0,offset set_clock-offset boot+7c00h,0
org_int9_addr dw 0,0

回复

使用道具 举报

千问 | 2010-9-26 10:18:02 | 显示全部楼层
问题1。我希望,这是最后一次解释这个问题call dword ptr es:[bx][si],这就是使用直接定址表调用相应子功能的指令,它需要一个双字,低字用于修改IP,高字用于修改CS,fun_table的表项高位字填0,表明,该子功能的段基为0,但不是一定为0,是按相应子功能的实际段基设置的。如果调用指令形如call word ptr es:[bx][si],近转移的call不修改CS,则无需存储段基,menu_tab的表项占一个字,作偏移地址,不需要修改数据段段基寄存器,无需存储段基。如果你有多个数据段,可以将各菜单项的段基地址存放在定指表中,然后可以使用形如下面的指令序列PUSH DSLDS DI,[BX]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行