% Remember to use the lgrind style \File{egmasm.asm}{1996}{Jun}{21}{11:19}{2863} \L{\LB{\C{};\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*}} \CE{}\L{\LB{\C{};_vgac.asm}} \CE{}\L{\LB{\C{};_PC_VGA_graphics_control_in_assembly_language}} \CE{}\L{\LB{\C{};_uses_BIOS_for_keyboard_read_and_setting_graphics}} \CE{}\L{\LB{\C{};_modes,_and_procedure_for_setting_a_VGA_pixel}} \CE{}\L{\LB{\C{};_version_for_C_calling_convention_:-}} \CE{}\L{\LB{\C{};}\Tab{8}{LARGE_model}} \CE{}\L{\LB{\C{};}\Tab{8}{no_MAIN_entry_point}} \CE{}\L{\LB{\C{};}\Tab{8}{assemble_only_(no_link)}} \CE{}\L{\LB{\C{};}\Tab{8}{underscore_for_C-callable_functions}} \CE{}\L{\LB{\C{};}\Tab{8}{don\4t_pop_arguments_off_stack_(caller_does_this)}} \CE{}\L{\LB{\C{};}} \CE{}\L{\LB{\C{};_J_Leis}} \CE{}\L{\LB{\C{};_24_May_1994}} \CE{}\L{\LB{\C{};\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*}} \CE{}\L{\LB{}} \L{\LB{\K{TITLE}}\Tab{8}{\V{vgac}.\V{asm}_\-_\V{vga}_\V{assembler}_\V{program},_\V{callable}_\V{from}_\V{C}}} \L{\LB{.\K{MODEL}}\Tab{8}{\K{LARGE}}} \L{\LB{.\N{286}}} \L{\LB{.\K{DOSSEG}}} \L{\LB{}} \L{\LB{\C{};_stack_segment_directive}} \CE{}\L{\LB{.\K{STACK}}} \L{\LB{}} \L{\LB{\C{};_data_segment_directive}} \CE{}\L{\LB{.\K{DATA}}} \L{\LB{}} \L{\LB{\C{};_code_segment_directive}} \CE{}\L{\LB{.\K{CODE}}} \L{\LB{}} \L{\LB{}} \L{\LB{\V{\_VgaMode}}\Tab{16}{___\K{PROC}}} \L{\LB{}} \L{\LB{____\V{pusha}}} \L{\LB{____\V{mov}_\V{ah},_\N{0}}\Tab{16}{\C{};_function_0_=_set_video_mode}} \CE{}\L{\LB{____\V{mov}_\V{al},_\N{12h}_\C{};_mode_12_=_vga_graphics}} \CE{}\L{\LB{____\V{int}_\N{10h}}} \L{\LB{____\V{popa}}} \L{\LB{____\V{ret}}} \L{\LB{}} \L{\LB{\V{\_VgaMode}_____\K{ENDP}}} \L{\LB{}} \L{\LB{}} \L{\LB{\V{\_TextMode}___\K{PROC}}} \L{\LB{}} \L{\LB{____\V{pusha}}} \L{\LB{____\V{mov}_\V{ah},_\N{0}}\Tab{16}{\C{};_function_0_=_set_video}} \CE{}\L{\LB{____\V{mov}_\V{al},_\N{03h}_\C{};_mode_3_=_text}} \CE{}\L{\LB{____\V{int}_\N{10h}}} \L{\LB{____\V{popa}}} \L{\LB{____\V{ret}}} \L{\LB{}} \L{\LB{\V{\_TextMode}}\Tab{16}{___\K{ENDP}}} \L{\LB{}} \L{\LB{}} \L{\LB{\V{\_ShowMessage}}\Tab{16}{__\K{PROC}}} \L{\LB{}} \L{\LB{____\V{pusha}}\Tab{16}{\C{};_save_registers_if_necessary}} \CE{}\L{\LB{}} \L{\LB{____\C{};_call_DOS_interrupt_to_display_a_message}} \CE{}\L{\LB{____\V{mov}__\V{bx},_\N{01h}}} \L{\LB{____\V{lea}}\Tab{8}{\V{dx},_\V{mesg}}\Tab{24}{_\C{};_equivalent_to_mov_dx,_OFFSET_mesg}} \CE{}\L{\LB{____\V{mov}__\V{cx},_\V{l\_mesg}}} \L{\LB{____\V{mov}__\V{ah},_\N{040h}}} \L{\LB{____\V{int}__\N{021h}}} \L{\LB{}} \L{\LB{____\V{popa}}} \L{\LB{____\V{ret}}} \L{\LB{}} \L{\LB{\V{\_ShowMessage}}\Tab{16}{__\K{ENDP}}} \L{\LB{}} \L{\LB{}} \L{\LB{\V{\_ReadKey}}\Tab{16}{__\K{PROC}}} \L{\LB{}} \L{\LB{____\V{pusha}}\Tab{16}{\C{};_save_registers_if_necessary}} \CE{}\L{\LB{}} \L{\LB{____\V{mov}_\V{ah},_\N{00h}}\Tab{16}{\C{};_function_0_-_wait_for_key_\&_read_it}} \CE{}\L{\LB{____\V{int}_\N{16h}}\Tab{16}{\C{};_int_16h_=_keyboard_services}} \CE{}\L{\LB{____\C{};_al_now_equals_ascii_code_of_key}} \CE{}\L{\LB{}} \L{\LB{____\V{popa}}} \L{\LB{____\V{ret}}} \L{\LB{}} \L{\LB{\V{\_ReadKey}}\Tab{16}{__\K{ENDP}}} \L{\LB{}} \L{\LB{}} \L{\LB{\C{};_setpixel(_xc,_yc,_color_)}} \CE{}\L{\LB{\C{};_stacking_order:}} \CE{}\L{\LB{\C{};}\Tab{8}{______memory___near_call___far_call}} \CE{}\L{\LB{\C{};__color______highest}\Tab{24}{[bp+8]}\Tab{32}{____[bp+10]}} \CE{}\L{\LB{\C{};__y-coord}\Tab{24}{[bp+6]}\Tab{32}{____[bp+8]}} \CE{}\L{\LB{\C{};__x-coord____lowest}\Tab{24}{[bp+4]}\Tab{32}{____[bp+6]}} \CE{}\L{\LB{\C{};}} \CE{}\L{\LB{\V{\_SetPixel}}\Tab{16}{__\K{PROC}}} \L{\LB{}} \L{\LB{____\V{push}_\V{bp}}} \L{\LB{____\V{mov}_\V{bp},_\V{sp}}} \L{\LB{}} \L{\LB{____\V{pusha}}\Tab{16}{\C{};_save_registers_if_necessary}} \CE{}\L{\LB{}} \L{\LB{____\V{mov}_\V{dx},_\N{03CEh}}\Tab{32}{\C{};_graphics_controller_register}} \CE{}\L{\LB{}} \L{\LB{____\V{mov}_\V{ax},_\N{0205h}}\Tab{32}{\C{};_write_mode_2}} \CE{}\L{\LB{____\V{out}_\V{dx},_\V{ax}}} \L{\LB{}} \L{\LB{____\V{mov}_\V{ax},_\N{0003h}}\Tab{32}{\C{};_function}} \CE{}\L{\LB{____\V{out}_\V{dx},_\V{ax}}} \L{\LB{}} \L{\LB{____\V{mov}_\V{ax},_\N{0A000h}}\Tab{32}{\C{};_graphics_screen_segment}} \CE{}\L{\LB{____\V{mov}_\V{es},_\V{ax}}} \L{\LB{}} \L{\LB{____\V{mov}_\V{ax},_[\V{bp}+\N{8}]}\Tab{24}{_______\C{};_get_y_co-ord}} \CE{}\L{\LB{____\V{mov}_\V{bx},_\N{640}\1\N{8}}\Tab{32}{\C{};_80_bytes\1line}} \CE{}\L{\LB{____\V{mul}_\V{bx}}} \L{\LB{____\V{mov}_\V{bx},_[\V{bp}+\N{6}]}\Tab{24}{_______\C{};_get_x-coord}} \CE{}\L{\LB{____\V{mov}_\V{cl},_\N{3}}\Tab{32}{\C{};_divide_by_8_bits\1byte}} \CE{}\L{\LB{____\V{shr}_\V{bx},_\V{cl}}} \L{\LB{____\V{add}_\V{bx},_\V{ax}}} \L{\LB{}} \L{\LB{____\V{mov}_\V{al},_\V{es}:[\V{bx}]}\Tab{32}{\C{};_dummy_write_to_latch_data_in_screen_RAM}} \CE{}\L{\LB{____\V{mov}_\V{cx},_[\V{bp}+\N{6}]}\Tab{24}{_______\C{};_get_x-coord}} \CE{}\L{\LB{____\V{and}_\V{cx},_\N{0007h}}\Tab{32}{\C{};_get_bit_mask}} \CE{}\L{\LB{____\V{mov}_\V{al},_\N{07h}}} \L{\LB{____\V{sub}_\V{al},_\V{cl}}} \L{\LB{____\V{mov}_\V{ah},_\N{80h}}} \L{\LB{____\V{shr}_\V{ah},_\V{cl}}\Tab{32}{_\C{};_shift_to_bit_position}} \CE{}\L{\LB{____\V{mov}_\V{al},_\N{08h}}\Tab{32}{_\C{};_set_mask_register}} \CE{}\L{\LB{}} \L{\LB{____\V{mov}_\V{dx},_\N{03CEh}}\Tab{32}{_\C{};_dx_destroyed_by_mul}} \CE{}\L{\LB{____\V{out}_\V{dx},_\V{ax}}\Tab{32}{_\C{};_write_bit_mask}} \CE{}\L{\LB{}} \L{\LB{____\V{mov}_\V{cx},_[\V{bp}+\N{10}]\C{};_color}\Tab{32}{_;_write_the_color_value}} \CE{}\L{\LB{____\V{mov}_\V{es}:[\V{bx}],_\V{cl}}} \L{\LB{}} \L{\LB{____\V{popa}}} \L{\LB{}} \L{\LB{____\V{pop}_\V{bp}}} \L{\LB{____\V{ret}_}\Tab{16}{____\C{};_don\4t_pop_args_off_stack_-_C_does_this}} \CE{}\L{\LB{}} \L{\LB{\V{\_SetPixel}}\Tab{16}{__\K{ENDP}}} \L{\LB{}} \L{\LB{\C{};no__main_procedure_(main_in_C)}} \CE{}\L{\LB{}} \L{\LB{\C{};_end_of_file}} \CE{}\L{\LB{\K{END}}}