943,735 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1009
  • Assembly RSS
Nov 11th, 2008
0

need help generating graphic

Expand Post »
I'm having trouble with drawing squares on the x86 assembler using the XGA 8-bit linear frame buffer. I'm suppose to draw a large square containing a grid of smaller 12x12 squares using my own functions and this is what I have so far:

Assembly Syntax (Toggle Plain Text)
  1. [SECTION .text]
  2. ;----------------------------------------------------------------------------
  3.  
  4. ; code belongs in this section starting here
  5.  
  6. mystart:
  7. mov ah, 0fh ; BIOS function - get current video mode
  8. int 10h ; call BIOS video interrupt
  9. mov [vidmode], al ; save the current video mode
  10.  
  11. mov eax, 4f02h ; SVGA function - set SVGA video mode
  12. mov ebx, XGAMODE ; select XGA video mode
  13. int 10h ; call BIOS video interrupt
  14.  
  15.  
  16. mov ecx, 12
  17. mov eax, xPos
  18.  
  19. sqrver:
  20. push ecx
  21.  
  22. mov ebx, yPos
  23. mov ecx, width
  24.  
  25. mov edx, eax
  26.  
  27. push eax
  28. mov eax, ebx
  29. mov ebx, XGAXRES
  30. mul ebx
  31. pop ebx
  32. add eax, ebx
  33.  
  34. vloop:
  35. mov byte [fs:eax], 15
  36. add dword eax, 800
  37. dec ecx
  38.  
  39. jnz vloop
  40.  
  41. add dword eax, 5
  42. pop ecx
  43. loop sqrver
  44.  
  45. mov ecx, 12
  46. mov ebx, yPos
  47.  
  48. sqrhori:
  49. push ecx
  50.  
  51. mov eax, xPos
  52. mov ecx, width
  53.  
  54. mov edx, ebx
  55.  
  56. push eax
  57. mov eax, ebx
  58. mov ebx, XGAXRES
  59. mul ebx
  60. pop ebx
  61. add eax, ebx
  62.  
  63. hloop:
  64. mov byte [fs:eax], 15
  65. inc eax
  66. dec ecx
  67.  
  68. jnz hloop
  69.  
  70. add dword ebx, 5
  71. pop ecx
  72. loop sqrver
  73.  
  74.  
  75. mov ah, 1 ; select DOS function - input character
  76. int 0f1h ; call OS function to wait for key press
  77.  
  78. mov ah, 00h ; BIOS function - set video mode
  79. mov al, [vidmode] ; restore the old video mode
  80. int 10h ; call BIOS video interrupt
  81.  
  82. ret
  83.  
  84. ;----------------------------------------------------------------------------
  85. [SECTION .data]
  86. ;----------------------------------------------------------------------------
  87.  
  88. ; all initialized data variables and constant definitions go here
  89.  
  90. XGAMODE equ 4103h ; XGA video mode code (w/ linear addr bit)
  91. XGAXRES equ 800 ; horizontal resolution of XGA screen
  92. XGAYRES equ 600 ; vertical resolution of XGA screen
  93.  
  94. xPos db 300
  95. yPos db 50
  96. width equ 400
  97.  
  98. ;----------------------------------------------------------------------------
  99. [SECTION .bss]
  100. ;----------------------------------------------------------------------------
  101.  
  102. ; all uninitialized data elements go here
  103.  
  104. vidmode resb 1 ; the old video mode

When I try to run it, only a few lines appear on the screen and the program lags for a bit before exiting...

Any help would be appreciated.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocku is offline Offline
22 posts
since Nov 2007

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: help me out please, my asm code is not working
Next Thread in Assembly Forum Timeline: learning nasm assembly, need some help





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


Follow us on Twitter


© 2011 DaniWeb® LLC