. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->转移指令的原理
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  【实验】9修正版  [待解决] 回复[ 1次 ]   点击[ 317次 ]  
regex
[帖 主]   [ 发表时间:2010-01-20 10:59 ]   [引用]   [回复]   [ top ] 
荣誉值:61
信誉值:0
注册日期:2009-12-19 01:51
$ cat lab9a.asm
assume  cs:code
string  segment
  1 assume  cs:code
  2 string  segment
  3         db      'Welcome to masm!'         ;定义 要显示字符串
  4 string  ends
  5
  6 attrib  segment
  7         db      02h,24h,0f1h               ;定义字符串的属性
  8 attrib  ends
  9
 10 code    segment
 11 start:
 12         mov ax,string                      ;装入字符串所在地址
 13         mov ds,ax
 14
 15         mov ax,0b800h                      ;预设显示区地址
 16         mov es,ax
 17
 18         mov bx,10h                         ;从DS:10处遍历字符属性
 19         mov cx,3                           ;3种字符属性
 20         mov bp,780h                        ;显示缓存起始行ES:0780H
 21
 22 b:      push cx                            ;开始内循环, 保存外循环计数
 23         push bp                            ;保存目的行计数
 24         mov si,0                           ;初始化列
 25         mov cx,16                          ;内循环计数开始
 26
 27 a:      mov al,[si]                        ;读入第一字节
 28         mov ah,[bx]                        ;设定字符属性
 29         mov es:[bp+40h],ax                 ;将字符传送至显示缓存
 30
 31         inc si                             ;增量操作
 32         add bp,2                           ;
 33         loop a
 34
 35         pop bp                             ;内循环结束,恢复计数
 36         pop cx                             ;
 37         inc bx                             ;增量操作
 38         add bp,0a0h                        ;由于每行字符160个字节,故+A0H
 39         loop b                             ;
 40
 41         mov ah,4ch                         ;程序返回
 42         int 21h
 43
 44 code    ends
 45 end     start
csusuntao
[第1楼]   [ 回复时间:2010-01-29 21:02 ]   [引用]   [回复]   [ top ] 
荣誉值:3
信誉值:2
注册日期:2010-01-04 23:00
下面是我的代码,请各位指点。

assume cs:codeseg

dataseg segment
    db 'welcome to masm!'
    db 02H, 24H, 0CAH
dataseg ends

stackseg segment
    db 16 dup(0)
stackseg ends

codeseg segment

START:
    mov ax, dataseg
    mov ds, ax
    
    mov ax, stackseg
    mov ss, ax
    mov sp, 16
    
    mov ax, 0B800H
    mov es, ax
    
    mov bx, 480   ; the byte offset for each row
    mov si, 0   ; the byte offset for each column
    mov di, 0   ; the iterator number
    mov cx, 3
    S1:
        push cx
        push di
        push si
        mov ah,ds:[16+di]       ; save the color value
        mov cx, 16
        mov di, 0               ; the iterator for "welcome to masm!"
        mov si, 0
        S2:
            mov al, ds:[di]     ; save the ascii value
            mov es:[bx+si], ax  ; write the [color,ascii] to the screen buffer
            add di, 1           ; ready to process next charactor
            add si, 2
        LOOP S2
        pop si
        pop di
        pop cx
        
        add bx, 160
        add si, 2   
        add di, 1 
    LOOP S1
    
    mov ax, 4C00H
    int 21H
    
codeseg ends

end START
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved