readwell 0 Newbie Poster

this is my main program some of my code is working from here to where i made a comment.
let me explain what i am doing so far if i input a number let's say 63 111111 my program is
setting this value into 00101110111 which is correct but now i have to call my procedure call parity to make the bits even i am having trouble doing that. where a comment the phrase trying to call parity is where i am trying to encode this number so it can became 00111111111 if you can help me out please.
and after i do this program i have to do the decoded version can you just give me a hint on this second program if not is ok just help me with the first one.
.DATA
Prompt DB 'Enter a decimal number : '
PART1 DW ?
PART2 DW ?
PART3 DW ?
PART4 DW ?
FINALBIT DW ?

.CODE
EXTRN PUTOCT : FAR
EXTRN PUTSTRNG : FAR
EXTRN GETDEC : FAR
EXTRN NEWLINE : FAR
EXTRN parity : FAR
EXTRN PUTDEC : FAR

ENCODE PROC
_Begin

MOV AX, @DATA
MOV ES, AX
MOV AX, 0;
MOV PART1,8;
MOV PART2,0;
MOV PART3,9;


LEA DI, Prompt;
MOV CX, 25;
CALL PUTSTRNG;
MOV BX,7;
CALL GETDEC;
MOV CX,AX;
AND AX,BX;
MOV DX,AX;
MOV BX,56;
MOV AX,CX;
AND AX,BX;
SHL AX,1;
OR DX,AX;
MOV BX,64;
MOV AX,CX;
AND AX,BX;
SHL AX,2;
OR DX,AX;
MOV AX,DX;everything above this is correct from here on i don't know
MOV BX,1111B; TRYING TO CALL PARITY
AND AX,BX;
MOV PART1,AX;
; CALL PUTOCT;
MOV AX,DX; SETS AX
MOV BX,11110000B;
AND AX,BX;
MOV PART2,AX;
CALL PUTOCT;
MOV AX,DX;
MOV BX,1100110011B;
AND AX,BX;
MOV PART3,AX;
; CALL PUTOCT;
MOV AX,DX;
MOV BX,10101010101B;
AND AX,BX;
MOV PART4,AX;
; CALL PUTOCT;

_Exit 0
ENCODE ENDP
END ENCODE


this is the call parity procedure
.DATA
Prompt DB 'Enter a number : '
onesmsg DB 'The number of ones in the program is '
evenmsg DB 'The count is even = '
oddmsg DB 'The count is odd = '
counter DW ?
variable DW ?

.CODE
EXTRN PUTDEC : FAR
EXTRN PUTSTRNG : FAR
EXTRN GETDEC : FAR
EXTRN NEWLINE : FAR

PAIRS:
MOV AX, @DATA
MOV ES, AX

mov AX, 0;


LEA DI, Prompt;
MOV CX, 17;
call PUTSTRNG;
call GETDEC;
MOV CX, 16;
mov DX,ax;

try:

shl DX, 1 ;shift to the left by 1

JC plusone ; jump if c flag equals one
loop try
JMP check

plusone:
inc bx;
inc AX; increment number of ones
mov ax,bx;
loop try

check:
push BX; ;save the count of ones
mov BX,2;
div BX; divide number of ones by 2
cmp DX, 0;
pop BX; ;get the count of ones
je evens;
jmp odd

evens:
MOV AX, DX; this check if the number is even
LEA DI, evenmsg;
MOV CX,20;
CALL PUTSTRNG;
call PUTDEC;
CALL NEWLINE;
jmp numones

odd:

MOV AX, DX; this checks if the number is odd
LEA DI, oddmsg;
MOV CX,20;
CALL PUTSTRNG;
CALL PUTDEC;
CALL NEWLINE;
jmp numones

numones:

mov ax,bx; this is the count of ones
LEA DI, onesmsg;
mov CX,37;
CALL PUTSTRNG;
CALL PUTDEC;


EXIT:
.EXIT
END PAIRS

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.