hamming code

how to convert binary to hamming code?

Page 1 of 1

2 Replies - 3078 Views - Last Post: 15 August 2009 - 12:17 AM Rate Topic: -----

#1 norielsoria  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 14-August 09

hamming code

Posted 14 August 2009 - 10:18 PM

lea di,msg
lea si,msg2
mov hexctr b,0

mov ah,08h
int 21h
cmp al,0dh
je process
add hexctr,1
cmp al,'0'
jb input2
cmp al,'9'
ja input2
call disp
sub al,30h
call conv_bin
jmp input

cmp al,'A'
jb input3
cmp al,'F'
ja input3
call disp
sub al,37h
call conv_bin
jmp input

cmp al,'a'
jb input
cmp al,'f'
ja input
call disp
sub al,57h
call conv_bin
jmp input

mov bl,0
add bl,4
sub hexctr,1
jnz numbins
add bl,1 ;number of binary bits + 1
mov bh,2 ;r
mov cl,2 ;2

add cl,cl
cmp bl,cl
jbe outnum
add bl,bh
add bl,1
mov bh,0
;add cl,cl
jmp computebits

mov ah,02
mov dl,' '
int 21h

mov ah,09
lea dx,msg
int 21h

mov ah,02
mov dl,' '
int 21h

add bl,30h
mov ah,02
mov dl,bl
int 21h

int 20h

hexctr db ?

msg db 255 dup('$')
msg2 db 255 dup('$')

mov ah,02
mov dl,al
int 21h

mov ch,4
mov cl,3
mov bl,al
mov dh,0

mov al,bl
ror al,cl
and al,01
add al,30h
mov [di],al
add di,1
add dh,1

dec cl
dec ch
jnz convert


mov dl,[di]
mov [si],dl
add si,1
sub di,1
jnz invert

den wats nxt on this code??

Is This A Good Question/Topic? 0
  • +

Replies To: hamming code

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1505
  • View blog
  • Posts: 8,259
  • Joined: 07-September 06

Re: hamming code

Posted 14 August 2009 - 10:19 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

#3 wildgoose  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 468
  • Joined: 29-June 09

Re: hamming code

Posted 15 August 2009 - 12:17 AM

Okay I picked this code apart. You didn't post what was wrong or what it did, etc.

There are faster ways of bit scanning with an 80X86 processor then what's being used here!

You definitely have what appears to me to be a defective conv_bin. You convert upper/lower case hex code into a decimal value from 0...15 but the method used to convert it to 4-bit BINARY bits is hinky!

I've rewritten it here, and this is more straight forward clocking only 4 bits like your version MSB to LSB and converting to ASCII 1's and 0's bits.

	mov	cl,4
	mov	bl,al
	shl	bl,cl; Shift Lower Nibble MSB into carry

	mov	al,'0'
	shl	bl,1; Shift bit into carry
	adc	al,0; '0' : '1'
	mov	[di],al
	inc	 di
	dec	cl
	jne	convert; Loop for 4 bits


This post has been edited by wildgoose: 15 August 2009 - 12:19 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1