2014-09-30 26 views
0

需要获取有关当前视频模式的信息。函数0fh返回此信息ALAHBH寄存器。如何从这个寄存器打印信息(十进制格式)?装配:从AL,AH和BH打印信息

感谢您的回答。

.model tiny 
.code 

org 100h 
start: 
    mov ah,9 
    lea dx, select_video_mode_msg 
    int 21h 
    call readsymb 

change_video_mode: 
    mov ah,00h 
    int 10h 

change_video_page_msg: 
    mov ah,9 
    lea dx, select_video_page_msg 
    int 21h 
    call readsymb 

change_video_page: 
    mov ah,05h 
    int 10h 

print_info: 
    mov ah,0fh 
    int 10h 
    ; print info from AL, AH, BH 

endprog: 
    ret 


readsymb: 
    mov ah,01h 
    int 21h 
    cmp al,2fH 
    jz endprog 
    cmp al,'0' 
    jz endprog 
    cmp al,'9' 
    ja endprog 
    xor ah,ah 
    sub al,30h 
    ret 

.data 
select_video_mode_msg db 'Select video mode (0-7): ','$' 
select_video_page_msg db 'Select video page: ','$' 
info_msg_cols   db 'Symbs cols: ','$' 
info_msg_mode   db 'Current mode: ','$' 
info_msg_page   db 'Current page: ','$' 
md      db '$' 


end start 
+0

它不能没有编写代码就可以完成。 – 2014-09-30 17:27:11

+0

@ 500-InternalServerError,添加了我的代码。 – dedoki 2014-09-30 17:31:35

+0

1)将AL,AH,BH值转换为ASCII字符串2)像对其他字符串一样打印它们。 – m0skit0 2014-09-30 17:45:07

回答

1

网络中有这么多的解释和例子。诀窍是重复将寄存器除以10并存储余数。这里是我的建议,尤其是您的需求:

.MODEL tiny 
.CODE 
ORG 100h 

start: 

    call print_info 

    mov ax, 4C00h     ; Exit(0) 
    int 21h 


print_info: 
    mov ah,0fh      ; GET CURRENT VIDEO MODE 
    int 10h       ; Call Video-BIOS 
    mov WORD PTR HOLD_AL, ax  ; This affects also HOLD_AH 
    mov HOLD_BH, bh 

    ; AL 
    mov ah, 09h      ; WRITE STRING TO STANDARD OUTPUT 
    lea dx, INFO1     ; Pointer to string 
    int 21h       ; Call MS-DOS 
    mov al, HOLD_AL     ; Argument for al2dec 
    call al2dec      ; Convert AL to decimal-string 
    mov ah, 09h      ; WRITE STRING TO STANDARD OUTPUT 
    mov dx, di      ; Result of al2dec 
    int 21h       ; Call MS-DOS 

    ; AH 
    mov ah, 09h      ; WRITE STRING TO STANDARD OUTPUT 
    lea dx, INFO2     ; Pointer to string 
    int 21h       ; Call MS-DOS 
    mov al, HOLD_AH     ; Argument for al2dec 
    call al2dec      ; Convert AL to decimal-string 
    mov ah, 09h      ; WRITE STRING TO STANDARD OUTPUT 
    mov dx, di      ; Result of al2dec 
    int 21h       ; Call MS-DOS 

    ; BH 
    mov ah, 09h      ; WRITE STRING TO STANDARD OUTPUT 
    lea dx, INFO3     ; Pointer to string 
    int 21h       ; Call MS-DOS 
    mov al, HOLD_BH     ; Argument for al2dec 
    call al2dec      ; Convert AL to decimal-string 
    mov ah, 09h      ; WRITE STRING TO STANDARD OUTPUT 
    mov dx, di      ; Result of al2dec 
    int 21h       ; Call MS-DOS 

    ret 

al2dec: 
    mov bl, 10      ; Base 10 -> divisor 
    lea di, DEC_END 
    L1: 
    dec di       ; fill the decimal-string in reverse order 
    xor ah, ah      ; Clear AH for division 
    div bl       ; AL = AX/BL Remainder AH 
    or ah, 30h      ; Convert AH to ASCII 
    mov BYTE PTR [di], ah   ; Save AH in the decimal-string 
    test al, al      ; AL == 0? 
    jnz L1       ; No: once more 
    ret        ; Return DS:DI Pointer to the decimal-string 


      DB "000"    ; String 
    DEC_End EQU $     ; with label pointing to its end (+1) 
      DB 13, 10, '$'   ; and line feed and '$'-terminator 
    INFO1 DB "AL (display mode): $" 
    INFO2 DB "AH (number of character columns): $" 
    INFO3 DB "BH (active page): $" 
    HOLD_AL DB ?     ; Uninitialized space for saving AL 
    HOLD_AH DB ?     ; Uninitialized space for saving AH 
    HOLD_BH DB ?     ; Uninitialized space for saving BH 

END start