Recently, I am bored, I found the assembly tutorial learning study of this 80x86. When the memory is directly operating, it is very unclear that the book is very unclear.
Not clear yet, starting an example. (I feel like the English teacher of our feet, saying that the virtual tone will be unprepared), so I am below
Just a simple use example. I hope that you can inspire you.
First, look at the graphics controller, its port is 3CEH as long as you transfer the parameters for this port, we can use 9 stages of the graphic controller.
One set in the device is the currently operated register. Then pass the parameters through the 3CFH to send you the registers you just selected.
Second, what I said is that the 12h mode of VGA is 640 × 480 16 colors.
Finally, the assembler I use is NASM, and everyone can find it on www.sf.net.
########################################################################################################################################################################################################################################################################################################
The index of the register is as follows
Register Name Index Setting / Reset Register 0 Allow Set / Reset Register 1 Color Compare Register 2 Data Cycle / Function Register 3 Read Image Select Register 4 Mode Select Register 5 Abbreviation 6 Color-independent register 7-bit shield register 8
Regarding the specific functions of the register, do not introduce here. You can look at the second edition of the "IBM-PC assembly language program design".
Regarding reading model, I saw "IBM-PC assembly language programming" said that it is more clear. I will briefly introduce the write mode here.
. The selected register can be operated via data transfer to the 3CFH port.
######################################################################################################################################################################################################################################################################################################## #
Type of write mode
There are four types of write mode, where 0 mode is the default mode, mode 2 is a simplified version of mode 0. Mode 3 is unique to VGA. Feeling and pattern 0 difference
many. Mode 1 is a direct operation of the opposite side.
######################################################################################################################################################################################################################################################################################################## #
Operation process
0 Set the screen to 12H mode 1 to set the segment address of 0A000H by the port.
######################################################################################################################################################################################################################################################################################################## #
Simple example; ---------------------------------------------- -----; Document: Test.asm; Introduction: A simple example of VGA written. ; Phenomenon: Green black vertical stripes appears on the screen. ; Language: assembly language, using nasm assembler; Author: Big Dipper Jun; E-mail: huangxiangkui@163.com; -------------------------- -------------------------
; Set VGA mode MOV AH, 00hmov Al, 12HINT 10h by BIOS
; Settings to VGA Controller
; Set the VGA controller, set to write mode 2MOV DX, 3CEHMOV Al, 5OUT DX, AL; select mode selection register for the currently available register
MOV DX, 3CFHMOV AL, 2OUT DX, Al; set the mode 2 to the current write mode
The bit shield register is set to make the pixels of the eight pixels transmitted to 0A000H are valid. MOV DX, 3CEHMOV AL, 8OUT DX, AL; Selecting Position Shield Register For the current available register
MOV DX, 3CFHMOV Al, 11110000B; let eight four pixels valid, then four invalid OUT DX, Al
; The 0A000H address is operated; set the initial parameter MOV AX, 0A000H; segment address MOV ES, AXMOV BX, 00000H; start offset MOV Al, 0AH; green MOV CX, 0FFFH; cycle number; write JMP for memory loop operation REERE: MOV [ES: BX], Al Inc BX loop Re
The above is a simple write program, and I should be quite clear here. If there is any problem, I am very welcome to visit.
The above code is compiled with NASM. Bios interrupts cannot be operated under Win32. So, I added some code to let it run under BOCHS.
everything is normal.
If you have any questions, you can ask.
Studio Software Development Group (SDT) Studio Development Team Beidou Star (Huang Yuxi)