我正在尝试将01011011B AND 11000111b
显示为二进制数字的ASCII字符串。我在跳跃和获取任何打印方面遇到了麻烦。我是新手,所以任何帮助都会很棒。持续7个小时,进度最小。谢谢
.stack 100h
.model small
.386
.data
str1 db 20 dup(?)
lstring EQU 9
.code
main:
mov ax, @data ; initialize DS
mov ds, ax
mov cx, lstring
L1:
mov al,01011011b
and al,11000111b
shl al, 1
loop L1
mov str1, al
mov ax, 8
int 21h
mov ax, 9 ; dos service to display...
mov bx, 1 ; to screen
mov cx, lstring ; number of bytes
mov dx, OFFSET str1 ; where to get data
int 21h
MOV AH, 4CH ; return control to DOS
INT 21H
end main
答案 0 :(得分:1)
编辑: 请记住,自从我(简要)与x86汇编程序相关并且我没有DOS设置来测试它以来已经很多年了。
mov al,01011011b
and al,11000111b ; Only need to do this once
; now al is the intermediate result
mov cx, 8 ; Do this 8 times, cx is the loop ctr (I think)
mov bx, OFFSET str1 ; Destination for resulting chars - start at beginning
L1: ; This is the loop
mov dl, '0' ; Ascii character zero
shl al, 1 ; Upper bit now in carry flag
adc dl, 0 ; Adds carry flag - 0 or 1
mov [bx], dl ; Save digit to current position
inc bx ; Next position
loop L1 ; Counts down cx
mov [bx], 0 ; Zero terminate (might need to use register)
mov ax, 9 ; dos service to display...
mov bx, 1 ; to screen
mov cx, lstring ; number of bytes
mov dx, OFFSET str1 ; where to get data
int 21h
MOV AH, 4CH ; return control to DOS
INT 21H
尝试这一点,但也学会使用调试器来查看它出错的地方。