假设我有以下内容:
output: db 1Eh
以二进制形式显示为11110
我想打印出来“####” 我怎么会这样做我明白我需要一些如何在循环中逐步通过它但我正在努力思考我需要调用哪些命令将每个位加载到一个单独的寄存器中所以我可以比较它是1还是0并输出所需的字符。
即时通讯使用NASM和使用16位运行它的Windows XP。
先谢谢了。
EDIT --- 这是我正在测试的一些代码虽然它完全不起作用
bits 16
org 0x100
jmp main
dollar: db "$"
hash: db "#"
printd:
mov dx,dollar
call disply
ret
printh:
mov dx,hash
call disply
ret
disply: mov ah,09h ;This function displays what is currently in the DX register
int 21h
ret
main:
mov ax,1Eh
mov bx,5
shl ax,10
loop1: shl ax,1
JB printd
JAE printh
sub bx,1
JNS loop1
int 20h
答案 0 :(得分:2)
示例:
BITS 16 ORG 100h mov cx, 8 _Loop: shl byte [output], 1 setc dl add dl, 30h mov ah, 02h int 21h loop _Loop mov ax, 4C00h int 21h output: db 1Eh
另一个例子:
BITS 16 ORG 100h bsr cx, [output] _Loop: bt [output], cx mov dl, '0' adc dl, 0 mov ah, 02h int 21h sub cl, 1 jnc _Loop mov ax, 4C00h int 21h output: dw 1Eh
答案 1 :(得分:0)
bits 16
jmp main
axbinout:
push cx
push dx
mov cx, 5
.top:
rcr ax, 1 ; Rotate and set the carry with what we rotated off
push ax ; Save AX
mov dl, ' ' ; Set DL to "0", the default value
mov al, 4 ; the offset the dollar sign is from space
mov bl, 0 ;setting bl to zero
adc bl, 0 ; adding the carry bit to bl
mul bl ; multiplying it by the offset set in al
add dx,ax ; adding ax to dx
mov ah, 0x0A ; 0x0A is the "print byte at cursor" argument to INT 0x10
mov al, dl ; Our result is in DL, but INT 0x10 uses AL
int 0x10 ; Print the byte
pop ax ; Restore AX
loop .top
pop dx
pop cx
ret
main:
mov ax, 1Eh
call axbinout
int 20h