moving from memory to register

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Sep 2007
Posts: 33
Reputation: carson myers has a little shameless behaviour in the past 
Solved Threads: 1
carson myers carson myers is offline Offline
Light Poster

moving from memory to register

 
0
  #1
Dec 11th, 2008
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:

  1. outp proc
  2.  
  3. push cx
  4. push ax
  5. push bx
  6. push dx
  7.  
  8. xor cx,cx
  9. xor bx,bx
  10.  
  11. nxchr: add dx,cx
  12. mov al,[dx]
  13. cmp al,00h
  14. jz stwrt
  15. cmp al,01h
  16. jnz skp01
  17. mov attrCUR,attrWHT
  18. skp01: cmp al,02h
  19. jnz skp02
  20. mov attrCUR,attrGRN
  21. skp02: mov ah,09h
  22. mov bl,attrCUR
  23. push cx
  24. xor cx,cx
  25. int 10h
  26. pop cx
  27. inc cx
  28. mov ah,03h
  29. int 10h
  30. inc dl
  31. mov ah,02h
  32. int 10h
  33. jmp nxchr
  34.  
  35. stwrt: pop dx
  36. pop bx
  37. pop ax
  38. pop cx
  39. ret
  40.  
  41. 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.
Last edited by carson myers; Dec 11th, 2008 at 11:00 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 26
Reputation: jt_murphree is an unknown quantity at this point 
Solved Threads: 1
jt_murphree's Avatar
jt_murphree jt_murphree is offline Offline
Light Poster

Re: moving from memory to register

 
0
  #2
Dec 13th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 33
Reputation: carson myers has a little shameless behaviour in the past 
Solved Threads: 1
carson myers carson myers is offline Offline
Light Poster

Re: moving from memory to register

 
0
  #3
Dec 14th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum


Views: 1162 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC