need help generating graphic

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

Join Date: Nov 2007
Posts: 22
Reputation: pocku is an unknown quantity at this point 
Solved Threads: 0
pocku pocku is offline Offline
Newbie Poster

need help generating graphic

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

  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC