2016-11-06 10 views
2

제 목표는 모든 바이트의 0 번째와 3 번째 비트의 합계를 인쇄하는 것입니다. 이것은 지금까지 내 코드입니다 :Assembly (TASM) : 특정 비트의 합계를 바이트로 인쇄합니다.

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)
GETBYTEBITSUM (2)을 마우스 오른쪽 대괄호가 필요
GETBYTEBITSUM (1)을 마우스 오른쪽 대괄호 필요
GETBYTEBITSUM이 (2)를 마우스 오른쪽 대괄호가 필요 우측 대괄호가 필요

내 생각 엔입니다 I buffer과 그 오프셋이 어떻게 작동하는지 이해하지 못합니다. 내 추측이 옳다면 누구든지이 예제를 사용하여 어떤 일이 벌어지고 있는지 설명 할 수 있습니까?

현재 : 현재 전체 입력란이 아닌 처음 3 바이트 만 인쇄하려고합니다.

감사합니다.

답변

3
getByteBitSum [dataBuffer + 2] 

매크로 확장이 포함 된 공백 문자 어려움이있다!
작성하여 해결 :

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

* printLine의 DataBuffer + 2 * 여기에 같은 문제에주의! 이번에는 컴파일러가 오류를주지 않을 것입니다. 왜냐하면 * + 2 * 매크로 확장이 없어도 오류가 발생하기 때문입니다. 반면에 프로그램의 출력에 결함이 있습니다. –