943,752 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Marked Solved
  • Views: 1850
  • Assembly RSS
Dec 11th, 2008
0

moving from memory to register

Expand Post »
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:

asm Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 5
Solved Threads: 1
Unverified User
carson myers is offline Offline
33 posts
since Sep 2007
Dec 13th, 2008
0

Re: moving from memory to register

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.
Reputation Points: 34
Solved Threads: 2
Light Poster
jt_murphree is offline Offline
40 posts
since Dec 2008
Dec 14th, 2008
0

Re: moving from memory to register

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.
Reputation Points: 5
Solved Threads: 1
Unverified User
carson myers is offline Offline
33 posts
since Sep 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Need help if possible pls!!!
Next Thread in Assembly Forum Timeline: bios level video instructions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC