2017-11-29 15 views
1

テキストCSC 112.1をセンタリングするよう指示しました。 DB命令とオフセットを使用しました。 これは私のコードターボアセンブラ言語のカーソル位置、オフセット

.model small 
.stack 
.data 

c db 10,13,10,13," лллл ",10,13 
    db    " лллллл ",10,13 
    db    "лл лл",10,13 
    db    "лл  ",10,13 
    db    "лл  ",10,13 
    db    "лл  ",10,13 
    db    "лл  ",10,13 
    db    "лл  ",10,13 
    db    "лл  ",10,13 
    db    "лл лл",10,13 
    db    " лллллл ",10,13 
    db    " лллл ",10,13,"$" 

.code 


    mov ax,@data 
    mov ds,ax 


call ccall         ;call the procedure ccall which outputs C 
call scall         ;call the procedure scall which outputs S 
call numcall        ;call the procedure numcall which outputs 112.1 
call exit         ;call the procedure exit and end terminate the program 


         ccall proc   ;procedures   
mov ah,02h       
mov bh,00 
mov dx,043h         ;set the cursor position where "04 is y coordinate" and "3 is x coordinate" 
int 10h 

mov ah,09h         ;ouputs a string 
mov dx,offset c 
int 21h 
call delay 
         ccall endp   ;end of the procedure ccall 
         scall proc 
mov ah,02h       
mov bh,00 
mov dx,04ah         ;set the cursor position where "04 is y coordinate" and "A is x coordinate" 
int 10h 


mov ah,09h         ;ouputs a string 
mov dx,offset s 
int 21h 
call delay 
         scall endp   ;end of the procedure 
         numcall proc  ;procedure 
mov ah,02h       
mov bh,00 
mov dx,041dh        ;set the cursor position where "04 is y coordinate" and "1D is x coordinate" 
int 10h 

mov ah,09h         ;ouputs a string 
mov dx,offset num 
int 21h 
call delay 
         numcall endp 
         exit proc 
mov ah,4ch         ;terminate process 
int 21h 
         exit endp 

           delay proc 
mov cx,300h   
D: push cx 
mov cx,0ffffh 
E: loop E 
pop cx 
loop D 
ret 
           delay endp 

end 

出力がこれであると、左側のみです。

It only outputs like this?なぜカーソル位置に表示されないのですか?また、私のDB命令も例として1つだけです。これはcです。

提案がありますか?助けが必要!

+0

各文字の冒頭にCR-LFがありますか? – prl

+0

あなたはどんな文字を意味しますか? –

答えて

1

すべての文字がそのCと同じ方法で定義されている場合、カーソルセットは正しい開始行を設定するだけですが、13,10行の新しい行はカーソルを次の行の先頭にリセットします。

また、DOSの終了行は13,10であり、10,13ではありません。これについて

mov ah,02h       
mov bh,00 
mov dx,043h 
    ; set the cursor position where "04 is y coordinate" 
    ; and "3 is x coordinate" 
int 10h 

、カーソル位置がDH =行、DL =列であるべきです。しかし、43hは列= 3、行= 4ではありません。それは列67、行= 0です。 DH=4, DL=3をロードするには、mov dx,403hを実行するか、より良いバイトバイトと比較する必要があります。mov dx,0403h 16進数フォーマットの1桁= 4ビットなので、2桁= 8ビット(1つの小さなレジスタ)です。 "43h"は単一のレジスタ(DL)をカバーし、DH00hです。または、16進1桁= 4ビットという考えが得られない場合は、mov dx,3 + 4*256(上位バイトは* 256値)を使用できます。

このような文字を特定の位置に出力したい場合は、改行文字を含まないように定義を変更する必要があります。私は:

c label byte 
    db " лллл " 
    db " лллллл " 
    db "лл лл" 
    db "лл  " 
    db "лл  " 
    db "лл  " 
    db "лл  " 
    db "лл  " 
    db "лл  " 
    db "лл лл" 
    db " лллллл " 
    db " лллл " 

そして、1文字としてah = 9ではなく、8x12回、charごとに出力します。

そして、あなたの手紙は8つの文字幅であり、単一の印刷可能な文字で、あなたが実際にビットとして、それらのデータを保存することができ、あなたは8文字以上(「ドット」をしたい場合、すなわち

; C letter, 8x12 bitmask 
c db 03Ch, 07Eh, 0C3h, 0C0h, 0C0h, 0C0h 
    db 0C0h, 0C0h, 0C0h, 0C3h, 07Eh, 03Ch 

これが壊れるなど)私はあなたの "数"の定義が使用されるのを恐れているが、あなたは別の数字からそれを構築することができますが、比例フォント、すなわちビットマスクよりも先にもう一つの値を加え、 ...それをやりましょう、それを16ビット値と比例/サイズ情報でバンプしてください:

; C letter, proportional width + 16x12 bitmask 
c dw 0C09h ; width is 9 dots, height is 12 lines 
    dw 03Ch, 07Eh, 0C3h, 0C0h, 0C0h, 0C0h ; 16x12 bitmask 
    dw 0C0h, 0C0h, 0C0h, 0C3h, 07Eh, 03Ch 

そして、私は最後にビットデータを "ミラーリング"していますので、一番左のドットは画面の最下位ビット(バイナリ/ 16進数で "右端"です)にあるので、 "C" 。そして私は、印刷ルーチンを検証するために、いくつかの黒四角とスペースを追加しました:

; file: BIGLETER.ASM 
; author: Peter Ped7g Helcmanovsky, (C) 2017 
; license: CC0 (public domain) 
; builded with TASM v4.1, TLINK v5.0 under dosbox v0.74 by commands: 
; tasm /m5 /w2 /t /l bigleter 
; tlink bigleter.obj 

.model small 
.stack 
.data 

; C letter, proportional width + 16x12 bitmask 
; bitmask is "mirrored", the bottom (right) bit goes out first 
; (left side of letter) 
c dw 0C0Ah ; width is 10 dots (8 dots have pixels), height is 12 lines 
    dw 03Ch, 07Eh, 0C3h, 003h, 003h, 003h ; 16x12 bitmask 
    dw 003h, 003h, 003h, 0C3h, 07Eh, 03Ch 

square12x12 LABEL WORD 
    dw 0C0Ch ; width is 12 dots, height is 12 lines 
    dw 0FFFh, 0FFFh, 0FFFh, 0FFFh, 0FFFh, 0FFFh ; 16x12 bitmask 
    dw 0FFFh, 0FFFh, 0FFFh, 0FFFh, 0FFFh, 0FFFh 

space2d LABEL WORD 
    dw 0C02h ; width is 2 dots, height is 12 lines 
    dw 12 DUP (0)  ; 16x12 bitmask 
    ; (12 lines to clear screen over full common letter height) 

space1d LABEL WORD 
    dw 0C01h ; width is 1 dot, height is 12 lines 
    dw 12 DUP (0)  ; 16x12 bitmask 
    ; (12 lines to clear screen over full common letter height) 

.286 
.code 

start: 
    mov  ax,@data 
    mov  ds,ax 
    mov  ax,3  ; ah=0, al=3 => VGA text mode 80x25 
    int  10h   ; (expensive "clear screen") 
    ; print 2x big C at specific position 
    mov  dx,0604h ; row=6, column=4 starting position 
    mov  si,OFFSET c ; data of "C" letter 
    call PrintBigLetter 
    mov  si,OFFSET c ; data of "C" letter 
    call PrintBigLetter 
    ; print white squares and different type of spaces 
    ; (to test print routine well, including proportional feature) 
    mov  si,OFFSET square12x12 ; data of filled square 12x12 
    call PrintBigLetter 
    mov  si,OFFSET space2d  ; data of 2 dots "space" 
    call PrintBigLetter 
    mov  si,OFFSET square12x12 ; data of filled square 12x12 
    call PrintBigLetter 
    mov  si,OFFSET square12x12 ; data of filled square 12x12 
    call PrintBigLetter 
    mov  si,OFFSET space1d  ; data of 1 dot "space" 
    call PrintBigLetter 
    mov  si,OFFSET square12x12 ; data of filled square 12x12 
    call PrintBigLetter 

    ; return to DOS with exit code 0 
    mov  ax,4c00h 
    int  21h 

; in: dh:dl = row:column, ds:si = letter definition 
; out: dh:dl = row:column adjusted for next letter 
; modifies: ax, bx, cx, si, di (basically ALL except dx and bp) 
PrintBigLetter PROC 
    mov  cx,[si]  ; ch = line count, cl = column size 
    add  si,2 
    ; store next letter position on stack 
    add  dl,cl 
    push dx 
    sub  dl,cl  ; restore position back for this letter 
PBL_row_loop: 
    ; set cursor to start of next line 
    mov  ah,2 
    xor  bh,bh 
    int  10h   ; dh:dl = row:column to set (left dot on line) 
    ; load "mirrored" bitmask and prepare for printing line 
    mov  di,[si]  ; di = bitmask of line 
    add  si,2 
    mov  ah,0Eh  ; int 10h 0E service 
    ; print CL-many dots on screen 
    push cx 
PBL_dot_loop: 
    mov  al,' '  ; space 
    shr  di,1  ; bottom bit into CF 
    jnc  PBL_dot_empty 
    mov  al,0DBh  ; 0xDB = '█' filled rectangle character 
PBL_dot_empty: 
    ; ah=0E, al=dot_char, bh=0, bl=? => ready to call int 10h 
    int  10h   ; print single "dot" of char 
    dec  cl   ; print column-size many dots 
    jnz  PBL_dot_loop 
    pop  cx 
    ; move to next line 
    inc  dh   ; next row 
    dec  ch 
    jnz  PBL_row_loop; CH-many rows 
    pop  dx   ; set dx to position of next letter 
    ret 
ENDP 

END start 

私がいない場合は、見て(最初のデバッガを試してみてください。..ので、うまくいけば、ビットマスクデータが印刷されているかの仕組みが理解できる、広範囲のソースをコメント印刷ループ内のレジスタで値がどのように変化するか)、まだ混乱している場合は、ここで躊躇しないでください。

関連する問題