汇编(TASM):以字节为单位打印某些位的总和

Assembly (TASM): print the sum of certain bits in bytes

我的目标是打印每个字节的第 0 位和第 3 位的总和。到目前为止,这是我的代码:

printLine macro line
    mov ah, 09
    mov dx, offset line
    int 21h
endm
;-----------------------------
readLine macro buffer
    mov ah, 0Ah
    mov dx, offset buffer
    int 21h
endm
;-----------------------------
getByteBitSum macro theByte
    mov al, byte ptr theByte
    mov cl, byte ptr theByte
    shr al, 3
    and al, 01
    and cl, 01
    add al, cl
endm
;-----------------------------
;-----------------------------
;-----------------------------
.model small
    ASSUME CS:code, DS:data, SS:stack
;-----------------------------
data segment para public 'DATA'
    message_1:
        db 'Enter a line'

    newLine:
        db 0Dh, 0Ah, '$'

    message_2:
        db 'You entered ',0Dh, 0Ah, '$'

    dataBuffer:
        db 20, 00, 20 dup (00)
data ends
;-----------------------------
code segment para public 'CODE'
    start:

    mov ax, seg data
    mov ds, ax

    printLine message_1

    readLine dataBuffer
    printLine newLine

    printLine message_2
    printLine newLine

    mov bx, 0000
    mov bl, byte ptr[dataBuffer + 1]
    mov word ptr [dataBuffer + bx + 3], 240Ah

    printLine dataBuffer + 2
    printLine newLine

    getByteBitSum [dataBuffer + 2]
    printLine newLine

    getByteBitSum [dataBuffer + 3]
    printLine newLine

    getByteBitSum [dataBuffer + 4]
    printLine newLine

    mov ah, 4ch
    int 21h
code ends
;-----------------------------
stack seg para stack 'STACK'
    dw 400h dup ('**')
stack ends
;-----------------------------
    end start

我得到的错误是:

GETBYTEBITSUM (1) Need right square bracket
GETBYTEBITSUM (2) Need right square bracket
GETBYTEBITSUM (1) Need right square bracket
GETBYTEBITSUM (2) Need right square bracket

我的猜测是我不太了解 buffer 及其偏移量是如何工作的。如果我的猜想是正确的,谁能用这个例子简单解释一下它发生了什么?

顺便说一句:截至目前,我只尝试打印前 3 个字节,而不是整个输入行。

谢谢。

getByteBitSum [dataBuffer + 2]

宏扩展对嵌入的 space 个字符有困难!
通过写作解决它:

getByteBitSum [dataBuffer+2]   ;No more embedded spaces!