so, I want to avoid using int 21h and start working with BIOS level code. I'm trying to write something equivalent to int 21h, function 09h, using int 10h functions 09h, 03h, and 02h, except I want the reading to terminate when it reaches a 00h character, switch to green text when it reaches a 02h character, and switch back to normal when it reaches a 01h character.
Here is my code:

outp proc

		push cx
		push ax
		push bx
		push dx
		
		xor cx,cx
		xor bx,bx
		
nxchr:	add dx,cx
		mov al,[dx]
		cmp al,00h
		jz stwrt
		cmp al,01h
		jnz skp01
		mov attrCUR,attrWHT
skp01:	cmp al,02h
		jnz skp02
		mov attrCUR,attrGRN
skp02:	mov ah,09h
		mov bl,attrCUR
		push cx
		xor cx,cx
		int 10h
		pop cx
		inc cx
		mov ah,03h
		int 10h
		inc dl
		mov ah,02h
		int 10h
		jmp nxchr
		
stwrt:	pop dx
		pop bx
		pop ax
		pop cx
		ret

outp endp

to use this I would set dx to the offset of the beginning of the string andthen call outp.
I'm getting the error that mov al,[dx] is an "illegal indexing mode," and that mov attrCUR,attrWHT and mov attrCUR,attrGRN are illegal memory references, although now that I look at it I can see exactly why. Anyways, how can I move the contents of the memory location in dx into the al register?
Also, I changed mov attrCUR,attrWHT to "mov attrCUR,[offset attrWHT]" and it said constant too large... how do I fix this?

help please...thanks in advance.


----edit----
fixed the mov attrCUR,attrWHT problem... just put the value into bl directly instead of using a memory location intermediate.

Firs of all what assembler are you using. The main problem is that you can not move a word to a byte. That is what you are trying to do when you do mov al, dx. Second, if dx is an offset you should be using si ( I am assuming this is a 16 bit program). As for you rsecond question, you can not move a value from one memory address to another. You must move it to a register and then to the second memory location. Hope this helps. I am fairly new to assembly myself so if I have stated something wrong I hope someone will correct me but I am pretty sure this is correct.

yeah that seems right, also, I wasn't moving dx into al, I was trying to move the address contained in dx to al, "mov al,[dx]." I tried using si instead of dx and it seemed to work. Thanks.

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.