. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->直接定址表
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  完成试验16啦,测试通过  [待解决] 回复[ 15次 ]   点击[ 1461次 ]  
lloveasm
[帖 主]   [ 发表时间:2008-09-16 09:00 ]   [引用]   [回复]   [ top ] 
荣誉值:18
信誉值:0
注册日期:2008-08-31 11:07
assume cs:code
stack segment
    db 128 dup(0)
stack ends
code segment
start:  mov ax, stack
        mov ss, ax
        mov sp, 128 

        mov ax, cs
        mov ds, ax
        mov si, offset setscreen
        mov ax, 0
        mov es, ax
        mov di, 200h
        mov cx, offset setscreenend - offset setscreen
        cld
        rep movsb

        mov ax, 0
        mov es, ax
        mov word ptr es:[7ch*4], 0h
        mov word ptr es:[7ch*4+2], 20h 

        mov ax, 4c00h
        int 21h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;屏幕设置
setscreen:  jmp short set           ;安装后这条语句地址是0020:0000,下一条0020:0002
table:     dw offset sub1 - offset setscreen, offset sub2 - offset setscreen, offset sub3 - offset setscreen, offset sub4 - offset setscreen
set:        push bx
            cmp ah, 3
            ja sret
            mov bl, ah
            mov bh, 0
            add bx, bx                  ;bx是偏移地址
            call word ptr cs:2h[bx]     ;即0020:(0002+bx)
sret:       pop bx
            iret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;清屏
sub1:   push bx
        push cx
        push es
        mov bx, 0b800h
        mov es, bx
        mov bx, 0
        mov cx, 2000
sub1s:  mov byte ptr es:[bx], ' '
        add bx, 2
        loop sub1s
        pop es
        pop cx
        pop bx
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;设置前景色
sub2:   push bx
        push cx
        push es
        mov bx, 0b800h
        mov es, bx
        mov bx, 1
        mov cx, 2000
sub2s:  and byte ptr es:[bx], 11111000b
        or es:[bx], al
        add bx, 2
        loop sub2s
        pop es
        pop cx
        pop bx
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;设置背景色
sub3:   push bx
        push cx
        push es
        mov cl, 4
        shl al, cl
        mov bx, 0b800h
        mov es, bx
        mov bx, 1
        mov cx, 2000
sub3s:  and byte ptr es:[bx], 10001111b
        or es:[bx], al
        add bx, 2
        loop sub3s
        pop es
        pop cx
        pop bx
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;向上滚动一行
sub4:   push cx
        push si
        push di
        push es
        push ds

        mov si, 0b800h
        mov es, si
        mov ds, si
        mov si, 160
        mov di, 0
        cld
        mov cx, 24
sub4s:  push cx
        mov cx, 160
        rep movsb
        pop cx
        loop sub4s
        mov cx, 80
        mov si, 0
sub4s1: mov byte ptr [160*24+si], ' '
        add si, 2
        loop sub4s1
        pop ds
        pop es
        pop di
        pop si
        pop cx
        ret
setscreenend: nop
code ends
end start
lloveasm
[第1楼]   [ 回复时间:2008-09-16 09:01 ]   [引用]   [回复]   [ top ] 
荣誉值:18
信誉值:0
注册日期:2008-08-31 11:07
测试:
assume cs:code
code segment
start:  mov ah, 1
        mov al, 010b
        int 7ch         ;调用1号子程序,设置前景色为绿色
        call delay

        mov ah, 2
        mov al, 001b    ;调用2号子程序,设置背景色为蓝色
        int 7ch
        call delay

        mov ah, 3
        int 7ch         ;调用3号子程序,上滚一行
        call delay
        
        mov ah, 3
        int 7ch         ;调用3号子程序,上滚一行
        call delay

        mov ax, 4c00h
        int 21h
;;;;;;;;;;;;;;;;;;;;;;;;;
;暂停
delay:  push ax
        push dx
        mov dx, 4000h
        mov ax, 0
s1:     sub ax, 1
        sbb dx, 0
        cmp ax, 0
        jne s1
        cmp dx, 0
        jne s1
        pop dx
        pop ax
        ret
code ends
programmer
[第2楼]   [ 回复时间:2008-10-10 11:32 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:2
注册日期:2008-09-10 20:50
table:dw offset sub1 - offset setscreen, offset sub2 - offset setscreen, 
         offset sub3 - offset setscreen, offset sub4 - offset setscreen
这句话是什么意思?
programmer
[第3楼]   [ 回复时间:2008-10-10 11:35 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:2
注册日期:2008-09-10 20:50
mov word ptr es:[7ch*4], 0h 
mov word ptr es:[7ch*4+2], 20h  
中断例程入口地址为什么要这样写?
写成   mov word ptr es:[7ch*4], 200h
      mov word ptr es:[7ch*4+2], 0h 
      为什么不行?
lloveasm
[第4楼]   [ 回复时间:2008-10-10 14:58 ]   [引用]   [回复]   [ top ] 
荣誉值:18
信誉值:0
注册日期:2008-08-31 11:07
Sorry, now I can not use Hanzi

0000:0200 and 0020:0000 is the same address

we copy "setscreen  to setscreenend codes" to that memerys

setscreen:  jmp short set           ;安装后这条语句地址是0020:0000,下一条0020:0002 
It's mean we can call "setscreen" use this address 0020:000, now, sub1' s address = ???

offset sub1 - offset setscreen = ???  Goto Debug, you will know.

You can look this link, use "org" is easy code
http://www.asmedu.net/blog/user/postcontent.jsp?neighborId=13489&kindLevel=1&kindId=17298&postId=23340&readSg=1
li4096255
[第5楼]   [ 回复时间:2008-11-28 18:17 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2007-10-17 09:53
table dw sub1
bx=0
call word ptr table[bx](现在table[bx]是不是就是sub1的偏移地址呢?)
debug 不是。。。。

那书上的288页说的是什么呢,可?
greatbob2008
[第6楼]   [ 回复时间:2008-12-30 18:23 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-10-27 02:35
呵呵,居然我和LZ写得一样。。
suiyueran
[第7楼]   [ 回复时间:2009-02-03 18:24 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-01-31 16:41
调试了两天 终于成功 
assume cs:code 
code segment 
start:mov ax,cs 
    mov ds,ax 
    mov si,offset screen   
    mov ax,0 
    mov es,ax 
    mov di,200h 
    mov cx,offset screenend-offset screen 
    cld 
    rep movsb 
    mov word ptr es:[7ch*4],200h 
    mov word ptr es:[7ch*4+2],0 
  
     
     
          mov ax,4c00h 
          int 21h 

;=========screen=====     
screen:jmp short set 
   table dw  offset sub1-offset screen+200h ,offset sub2-offset screen+200h, offset sub3-offset screen+200h , offset sub4-offset screen+200h                     
 set:push bx  
     
    cmp ah,3 
    ja sret     
    mov bl,ah 
    mov bh,0 
    add bx,bx 
     
    call word ptr cs:[bx].202h 
    sret:pop bx 
    iret             
     
;-----------sub1===== 
sub1:push bx 
    push cx 
    push es 
    mov bx,0b800h 
    mov es,bx 
    mov bx,0 
    mov cx,2000 
sub1s:mov byte ptr es:[bx],' ' 
    add bx,2 
    loop sub1s 
    pop es 
    pop cx 
    pop bx 
    ret 
;=======sub2====== 
sub2:push bx 
    push cx 
    push es 
    mov bx,0b800h 
    mov es,bx 
    mov bx,1 
    mov cx,2000 
sub2s:and byte ptr es:[bx],11111000b 
    or es:[bx],al 
    add bx,2 
    loop sub2s 
    pop es 
    pop cx 
    pop bx 
    ret 
;------------    sub3    ----- 
sub3:push bx 
    push cx 
    push es 
    mov cl,4 
    shl al,cl 
    mov bx,0b800h 
    mov es,bx 
    mov bx,1 
    mov cx,2000 
sub3s:and byte ptr es:[bx],10001111b 
    or es:[bx],al 
    add bx,2 
    loop sub3s 
    pop es 
    pop cx 
    pop bx 
    ret 
;============sub4     ===== 
sub4:push cx 
    push si 
    push di 
    push es 
    push ds 
    mov si,0b800h 
    mov es,si 
    mov ds,si 
    mov si,160 
    mov di,0 
    cld 
    mov cx,24 
sub4s:push cx 
    mov cx,160 
    rep movsb 
    pop cx 
    loop sub4s 
    mov cx,80 
    mov si,0 
sub4s1:mov byte ptr [160*24+si],' ' 
    add si,2 
    loop sub4s1 
    pop ds 
    pop es 
    pop di 
    pop si 
    pop cx 
    ret 
screenend:nop         
code ends 
    end start                         
大家多多指教
wping
[第8楼]   [ 回复时间:2009-05-06 09:53 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-01-15 17:32
screen:jmp short set  
   table dw  offset sub1-offset screen+200h ,offset sub2-offset screen+200h, offset sub3-offset screen+200h , offset sub4-offset screen+200h   

这里没必要这么麻烦。在安装7CH中断时只需要把
mov word ptr es:[7ch*4],200h  
mov word ptr es:[7ch*4+2],0  
   
改成
mov word ptr es:[7ch*4],0
mov word ptr es:[7ch*4+2],0020H

这样的话,table dw sub1,sub2,sub3,sub4可以保持不变

欢迎交流
abcdwzxy
[第9楼]   [ 回复时间:2009-07-08 14:45 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:3
注册日期:2009-03-13 16:19
我和7楼写的代码一样!其实不管用哪种方法,关键是要在中断例程中,CALL指令能正确的定位到每一个子程序!也就是要正确的找到每个子程序的偏移地址!
zhao129999
[第10楼]   [ 回复时间:2009-07-21 15:28 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-05-02 11:54
17814260 汇编群 欢迎汇编爱好者一起学习..
zwz_good
[第11楼]   [ 回复时间:2009-10-19 20:51 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-03-18 14:35
七楼的比较符合正常人的思维习惯,楼主的尽管实现了,但是给人的感觉很绕。
sparkl
[第12楼]   [ 回复时间:2010-03-16 15:01 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-03-23 12:51
一直在这个实验困惑当中:
冒昧的问一下:
假如第26行有数据
向上滚动一行-----
是不是第N行的内容,显示在显示器的第N-1行,同样第26行的内容就应该显示在第25行?
而楼主的子程序是不是有点问题?
楼主的向上滚动一行是不是等于向上滚动一行且最后一行为空?
sparkl
[第13楼]   [ 回复时间:2010-03-16 17:22 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-03-23 12:51
我的向上滚动一行的子程序如下:
sub4:push cx  
    push si  
    push di  
    push es  
    push ds  
    mov si,0b800h  
    mov es,si  
    mov ds,si  
    mov si,160  
    mov di,0  
    cld  
    mov cx,24 
sub4s:
        push cx
        mov cx,160 ;这里可以变为mov cx,80
        rep movsb  ;同时这句变为rep movsw
        pop cx
        loop sub4s
        pop ds
        pop es
        pop di
        pop si
        pop cx
        ret
安装好新的int 7ch中断程序以后:
接着在debug里面跟踪,(这里请注意:把cmd的窗口属性中的
屏幕缓冲区大小中的 高度 设为大于25的数如:43,窗口大小 高度也设为:43,
这样,CMD就可以显示43行)
接着试验4号功能:

g:\HB>debug
-d 0:200   ;证明int 7ch中断程序已经安装
0000:0200  EB 08 1C 00 37 00 55 00-77 00 53 80 FC 03 77 0A   ....7.U.w.S...w.
0000:0210  8A DC B7 00 03 DB 2E FF-57 02 5B CF 53 51 06 BB   ........W.[.SQ..
0000:0220  00 B8 8E C3 BB 00 00 B9-70 0D 26 C6 07 20 83 C3   ........p.&.. ..
0000:0230  02 E2 F7 07 59 5B C3 53-51 06 BB 00 B8 8E C3 BB   ....Y[.SQ.......
0000:0240  01 00 B9 D0 07 26 80 27-F8 26 08 07 83 C3 02 E2   .....&.'.&......
0000:0250  F4 07 59 5B C3 53 51 06-B1 04 D2 E0 BB 00 B8 8E   ..Y[.SQ.........
0000:0260  C3 BB 01 00 B9 70 0D 26-80 27 8F 26 08 07 83 C3   .....p.&.'.&....
0000:0270  02 E2 F4 07 59 5B C3 51-56 57 06 1E BE 00 B8 8E   ....Y[.QVW......
-a         
17CF:0100 mov ah,3
17CF:0102 int 7c
17CF:0104 mov bx,8   ;用于检验中断程序的返回,是否回到这里
17CF:0107
-
接下来,按10次'T'命令,后再按'U',如图
0020:0012 B700                MOV        BH,00
-t

AX=0300  BX=0003  CX=0000  DX=0000  SP=FFE6  BP=0000  SI=0000  DI=0000
DS=17CF  ES=17CF  SS=17CF  CS=0020  IP=0014   NV UP DI PL ZR NA PE NC
0020:0014 03DB          ADD     BX,BX
-t

AX=0300  BX=0006  CX=0000  DX=0000  SP=FFE6  BP=0000  SI=0000  DI=0000
DS=17CF  ES=17CF  SS=17CF  CS=0020  IP=0016   NV UP DI PL NZ NA PE NC
0020:0016 2E            CS:
0020:0017 FF5702        CALL    [BX+02]                        CS:0008=0077  ;跳到4号子程序
-t

AX=0300  BX=0006  CX=0000  DX=0000  SP=FFE4  BP=0000  SI=0000  DI=0000
DS=17CF  ES=17CF  SS=17CF  CS=0020  IP=0077   NV UP DI PL NZ NA PE NC
0020:0077 51            PUSH    CX
-u
0020:0077 51            PUSH    CX
0020:0078 56            PUSH    SI
0020:0079 57            PUSH    DI
0020:0079 57            PUSH    DI
0020:007A 06            PUSH    ES
0020:007B 1E            PUSH    DS
0020:007C BE00B8        MOV     SI,B800
0020:007F 8EC6          MOV     ES,SI
0020:0081 8EDE          MOV     DS,SI
0020:0083 BEA000        MOV     SI,00A0
0020:0086 BF0000        MOV     DI,0000
0020:0089 FC            CLD
0020:008A B91800        MOV     CX,0018
0020:008D 51            PUSH    CX
0020:008E B95000        MOV     CX,0050
0020:0091 F3            REPZ
0020:0092 A5            MOVSW
0020:0093 59            POP     CX
0020:0094 E2F7          LOOP    008D
0020:0096 1F            POP     DS
-
接下来输入'g 0096'跳出循环,如下图:
-t

AX=0300  BX=0003  CX=0000  DX=0000  SP=FFE6  BP=0000  SI=0000  DI=0000
DS=17CF  ES=17CF  SS=17CF  CS=0020  IP=0014   NV UP DI PL ZR NA PE NC
0020:0014 03DB          ADD     BX,BX
-t

AX=0300  BX=0006  CX=0000  DX=0000  SP=FFE6  BP=0000  SI=0000  DI=0000
DS=17CF  ES=17CF  SS=17CF  CS=0020  IP=0016   NV UP DI PL NZ NA PE NC
0020:0016 2E            CS:
0020:0017 FF5702        CALL    [BX+02]                            CS:0008=0077
-t

AX=0300  BX=0006  CX=0000  DX=0000  SP=FFE4  BP=0000  SI=0000  DI=0000
DS=17CF  ES=17CF  SS=17CF  CS=0020  IP=0077   NV UP DI PL NZ NA PE NC
0020:0077 51            PUSH    CX
-u
0020:0077 51            PUSH    CX
0020:0078 56            PUSH    SI
0020:0079 57            PUSH    DI         ;这里是屏幕的第25行,它的内容已经变为第26行的内容
0020:0079 57            PUSH    DI
0020:007A 06            PUSH    ES
0020:007B 1E            PUSH    DS
0020:007C BE00B8        MOV     SI,B800
0020:007F 8EC6          MOV     ES,SI
0020:0081 8EDE          MOV     DS,SI
0020:0083 BEA000        MOV     SI,00A0
0020:0086 BF0000        MOV     DI,0000
0020:0089 FC            CLD
0020:008A B91800        MOV     CX,0018
0020:008D 51            PUSH    CX
0020:008E B95000        MOV     CX,0050
0020:0091 F3            REPZ
0020:0092 A5            MOVSW
0020:0093 59            POP     CX
0020:0094 E2F7          LOOP    008D
0020:0096 1F            POP     DS
-g 0096

AX=0300  BX=0006  CX=0000  DX=0000  SP=FFDA  BP=0000  SI=0FA0  DI=0F00
DS=B800  ES=B800  SS=17CF  CS=0020  IP=0096   NV UP DI PL NZ NA PE NC
0020:0096 1F            POP     DS
-

通过上例,大家发现了什么?
其实我的子程序只是为了试验我的想法,
我认为,是不是把CX的值设为:25行*8页-1(显存地址的行号从0开始),然后最后一行设为空行??
这样就可以实现了向上滚动一行呢?
请牛人指教!!!
mgf1988629
[第14楼]   [ 回复时间:2010-03-22 22:12 ]   [引用]   [回复]   [ top ] 
荣誉值:14
信誉值:2
注册日期:2009-11-30 11:46
我觉得书上有错,在loop sub4s之前应加上add si,160 add di,160
tjh5151
[第15楼]   [ 回复时间:2010-10-03 10:57 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2010-07-17 15:48
si ,di 在命令movsb中自动完成add si,160 add di,160
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved