View Single Post
Old Nov 29th, 2004, 3:58 PM   #1
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
hi,

i had a problem converting a number to characters to output it to the screen.

i solved this problem by writing a macro, but now when i try to call the macro 3 times within the same code i get the following error while compiling:

Quote:

Turbo Assembler Version 2.01 Copyright © 1988, 1990 Borland International

Assembling file: 1.asm
**Error** 1.asm(20) PRINTVALUE(6) Symbol already defined elsewhere: THOUSAND
**Error** 1.asm(20) PRINTVALUE(8) Relative jump out of range by 000Ah bytes
**Error** 1.asm(20) PRINTVALUE(13) Symbol already defined elsewhere: HUNDRED
**Error** 1.asm(20) PRINTVALUE(15) Relative jump out of range by 0001h bytes
**Error** 1.asm(20) PRINTVALUE(25) Symbol already defined elsewhere: NEXT1
**Error** 1.asm(20) PRINTVALUE(27) Relative jump out of range by 000Bh bytes
**Error** 1.asm(20) PRINTVALUE(32) Symbol already defined elsewhere: TEN
**Error** 1.asm(20) PRINTVALUE(34) Relative jump out of range by 000Dh bytes
**Error** 1.asm(20) PRINTVALUE(36) Relative jump out of range by 0002h bytes
**Error** 1.asm(20) PRINTVALUE(38) Symbol already defined elsewhere: GO_ON
**Error** 1.asm(20) PRINTVALUE(48) Symbol already defined elsewhere: LAST
**Error** 1.asm(20) PRINTVALUE(50) Relative jump out of range by 000Ch bytes
**Error** 1.asm(20) PRINTVALUE(55) Symbol already defined elsewhere: FINAL
**Error** 1.asm(20) PRINTVALUE(57) Relative jump out of range by 000Eh bytes
**Error** 1.asm(20) PRINTVALUE(59) Relative jump out of range by 0008h bytes
**Error** 1.asm(20) PRINTVALUE(61) Symbol already defined elsewhere: NEXT2
**Error** 1.asm(20) PRINTVALUE(69) Symbol already defined elsewhere: FINISH
**Error** 1.asm(23) PRINTVALUE(6) Symbol already defined elsewhere: THOUSAND
**Error** 1.asm(23) PRINTVALUE(8) Relative jump out of range by 009Dh bytes
**Error** 1.asm(23) PRINTVALUE(13) Symbol already defined elsewhere: HUNDRED
**Error** 1.asm(23) PRINTVALUE(15) Relative jump out of range by 0094h bytes
**Error** 1.asm(23) PRINTVALUE(25) Symbol already defined elsewhere: NEXT1
**Error** 1.asm(23) PRINTVALUE(27) Relative jump out of range by 009Eh bytes
**Error** 1.asm(23) PRINTVALUE(32) Symbol already defined elsewhere: TEN
**Error** 1.asm(23) PRINTVALUE(34) Relative jump out of range by 00A0h bytes
**Error** 1.asm(23) PRINTVALUE(36) Relative jump out of range by 0095h bytes
**Error** 1.asm(23) PRINTVALUE(38) Symbol already defined elsewhere: GO_ON
**Error** 1.asm(23) PRINTVALUE(48) Symbol already defined elsewhere: LAST
**Error** 1.asm(23) PRINTVALUE(50) Relative jump out of range by 009Fh bytes
**Error** 1.asm(23) PRINTVALUE(55) Symbol already defined elsewhere: FINAL
**Error** 1.asm(23) PRINTVALUE(57) Relative jump out of range by 00A1h bytes
**Error** 1.asm(23) PRINTVALUE(59) Relative jump out of range by 009Bh bytes
**Error** 1.asm(23) PRINTVALUE(61) Symbol already defined elsewhere: NEXT2
**Error** 1.asm(23) PRINTVALUE(69) Symbol already defined elsewhere: FINISH
Error messages: 34
Warning messages: None
Passes: 1
Remaining memory: 472k

i know what is wrong, but i do not know how to solve it

since the code in the macro is put into the place where i put the calling, i get multiple labels with the same name.
how can i make this work without having to create at least 3 different macros with as only difference the label names?

here's the macro i have written:

;####################
;printvalue macro
;print value 0234 = 234
;####################
printvalue macro number

push ax bx cx dx

mov ax,number
xor cx,cx
thousand:
cmp ax,1000
jl hundred
sub ax,1000
inc cx
jmp thousand

hundred:
cmp cx,0
je next1
mov bx,1
push ax
mov dl,cl
add dl,48
mov ah,02h
int 21h
pop ax
xor cx,cx

next1:
cmp ax,100
jl ten
sub ax,100
inc cx
jmp next1

ten:
cmp bx,1
je go_on
cmp cx,0
je last

go_on:
mov bx,2
push ax
mov dl,cl
add dl,48
mov ah,02h
int 21h
pop ax
xor cx,cx

last:
cmp ax,10
jl final
sub ax,10
inc cx
jmp last

final:
cmp bx,2
je next2
cmp cx,0
je finish

next2:
push ax
mov dl,cl
add dl,48
mov ah,02h
int 21h
pop ax

finish:
mov dl,al
add dl,48
mov ah,02h
int 21h

pop dx cx bx ax

endm
;##################

i also don't want to create a procedure from this since i would like to use it in multiple programs without having to rewrite the proc everytime i start writing another program.


any ideas?


thanks in advance
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote