I wrote the program, it gives errors. I do not know how to fix them, and it seems like because of one thing the others have appeared. Please help me fix them, and if necessary I can comment in more detail.

Task: A two-byte code is entered from the keyboard in binary form. Display its numeric value in hex form.

My code

.386 dseg segment use16 text1 db 13,10,'Type BIN: $' text2 db 13,10,0Dh,0Ah,'Result..: ',0Dh,0Ah,'$' Buf db 17,18 dup(?) dseg ends cseg segment use16 assume cs:cseg, ds:dseg m1: mov cx,dseg mov ah,9 lea DX,text1 int 21h mov ah,0Ah lea DX,Buf int 21h mov DX,DS:Buf lea Di,DS:Buf+2 mov CX,DS:Buf+1 m2: cmp DS:[DI],31h jne short m3 ;если не равно or AX, 00000001b m3: shl AX,1 inc DI loop m2 mov ah,9 lea DX,text2 int 21h mov DX,AX call PECHAT mov ah, 4ch int 21h ;Печатает символ и переводит курсор на позицию вправо WRITE proc mov AH,9 xor BH,BH mov BL,07H ;mov CX,1 mov AL,DL int 10h inc DL ret WRITE endp ;Печатает одну шестнадцатеричную цифру (младшую тетраду DL) ;(старшая тетрада должна быть равна 0) ;DL - цифра ;-------------------------------------------------------- NA_CONSOL proc cmp DL,0Ah jae BUKVA add DL,30h JMP POKAZ BUKVA: add DL,37h POKAZ: call WRITE ret NA_CONSOL endp ;Печатает две шестнадцатеричные цифры RASHIREN proc mov DH,DL mov CL,4 shr DL,CL call NA_CONSOL mov DL,DH and DL,0Fh call NA_CONSOL ret RASHIREN endp PECHAT proc ;двухбайтное число на консоль mov CX,DX call RASHIREN xchg DL,CH call RASHIREN ret PECHAT endp cseg ends end m1 

Errors gives the following:

  1. do not match operand types - mov DX,DS:Buf
  2. do not match operand types - mov CX,DS:Buf+1
  3. argument needs type override - cmp DS:[DI],31h
  • one
    Errors we get through the pipe from libastral? Put them here! - gbg
  • @gbg Here, I wrote. - papalimer

1 answer 1

Thanks to the kind person, the program works. All.

 .386 dseg segment use16 text1 db 13,10,'Type BIN: $' text2 db 13,10,'Result..: $' Buf db 17,0,17 dup(?) dseg ends sseg segment stack use16 db 256 dup(?) sseg ends cseg segment use16 assume cs:cseg,ds:dseg,ss:sseg m1: mov cx,dseg mov ds,cx mov ah,09h lea dx,text1 int 21h mov ah,0Ah lea dx,Buf int 21h lea di,ds:[Buf+2] xor ch,ch mov cl,byte ptr ds:[Buf+1] xor ax,ax m2: shl ax,1 cmp byte ptr ds:[di],31h jne short m3 or ax,00000001b m3: inc di loop m2 push ax mov ah,09h lea dx,text2 int 21h pop dx call pechat mov ah,4Ch mov al,00h int 21h write proc mov ah,02h int 21h ret write endp na_consol proc cmp dl,0Ah jae bukva add dl,30h jmp pokaz bukva: add dl,37h pokaz: call write ret na_consol endp rashiren proc mov dh,dl mov cl,4 shr dl,cl call na_consol mov dl,dh and dl,0Fh call na_consol ret rashiren endp pechat proc push dx xchg dh,dl call rashiren pop dx call rashiren ret pechat endp cseg ends end m1