flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
b 22 Oct 2004, 20:47
iy's ok sir but problem is that i dont know how to express my problem1!!!
i know & i'm very sure all guys here are very helpful!!! i visited the site u told me about and it's good too1!! thank u all for ur time and and sorrry if i bothered u bodour |
|||
![]() |
|
Matrix 24 Oct 2004, 00:13
Hello newbies i have code snipplets for you
using bios. ; Code: org 100h mov si,question1 call bwritestring ; Writes a 0 terminated string to screen ( string is at ds:si ) mainloop: call breadkey ; this gets keyhit in al (extended scancodes in ah) cmp al,'0' jae lowaerok ; if above or equal 0 jmp error123 ; not number lowaerok: cmp al,'9' jbe number ; if below or equal 9 error123: mov si,eror1 call bwritestring ; Writes a 0 terminated string to screen ( string is at ds:si ) mov ah,0xe int 10h jmp mainloop ; go back and enter again number: mov si,exit1 call bwritestring ; Writes a 0 terminated string to screen ( string is at ds:si ) mov ah,0xe int 10h int 20h ; exit breadkey: ;returns: AH = BIOS scan code AL = ASCII character note: enhanced mov ah,$10 int $16 ret bwritestring: ; Writes a 0 terminated string to screen ( string is at ds:si ) push ax bx mov bx,7 ; use video page 0, normal white mov ah,$e localloop: lodsb or al,al jnz next_char pop bx ax ret next_char: int 10h jmp localloop question1: db 'Press a number',0 eror1: db 13,10,'Not a number:',0 exit1: db 13,10,'Button pressed was:',0 ; i give you some bios routines: you put the registers the valuie you want, then call proc-name te ret means go back where the cal was made Code: ;Procedures list: ; note: transparency is not guaranteed due to interrupt calls. ;******** Keyboard Stuff ******** ; keypressed ;Beware! Don't call INT 16h with high transmission rates, it won't work! ; bradkeystandard ;returns: AH = BIOS scan code AL = ASCII character ; this function discards any extended keystrokes, ; returning only when a non-extended keystroke is available ; breadkey ;returns: AH = BIOS scan code AL = ASCII character note: enhanced ; bkeycheck ;returns: AH = BIOS scan code AL = ASCII character note: enhanced ; only checks buffer without removing key ; bkeycheck ;returns: AH = BIOS scan code AL = ASCII character note: enhanced ; Return: ZF set if no keystroke available, ZF clear if keystroke available ; only checks buffer without removing key ; bpushkey ;cx = code to store, in keyboard buffer (AT/PS w enh keybd only) ; CH = BIOS scan code, CL = ASCII character note: enhanced ; Return: AL = status: 00h if successful, 01h if keyboard buffer full ; bshift ;GET SHIFT FLAGS, Return: AL = shift flags, AH destroyed by many BIOSes ; shift flags: ; Bit(s) Descriptin ; 7 Insert active ; 6 CapsLock active ; 5 NumLock active ; 4 ScrollLock active ; 3 Alt key pressed (either Alt on 101/102-key keyboards) ; 2 Ctrl key pressed (either Ctrl on 101/102-key keyboards) ; 1 left shift key pressed ; 0 right shift key pressed ; bshiftextended ;GET EXTENDED SHIFT STATES (enh kbd support only) ; Return: AL = shift flags 1 (same as returned by AH=02h) ; AH = shift flags 2 ; Notes: AL bit 3 set only for left Alt key on many machines ; INT 16/AH=09h can be used to determine whether this function is ; supported, but only on later model PS/2s ; shift flags 1: ; Bit(s) Description ; 7 Insert active ; 6 CapsLock active ; 5 NumLock active ; 4 ScrollLock active ; 3 Alt key pressed (either Alt on 101/102-key keyboards) ; 2 Ctrl key pressed (either Ctrl on 101/102-key keyboards) ; 1 left shift key pressed ; 0 right shift key pressed ; shift flags 2: ; Bit(s) Description ; 7 SysReq key pressed (SysReq is often labeled SysRq) ; 6 CapsLock pressed ; 5 NumLock pressed ; 4 ScrollLock pressed ; 3 right Alt key pressed ; 2 right Ctrl key pressed ; 1 left Alt key pressed ; 0 left Ctrl key pressed ;******** EOF Keyboard Stuff ******** ;******** Textmode Stuff ******** ; cursoron ; Turns CURSOR ON. ; cursoroff ; Turns CURSOR OFF. ; cursorhidden ; Returns 1 if cursorhidden, 0 otherwise. ; bgotoxy ; dl=x, dh=y ( 0,0 = upper left ) RETURNS: AX,BX,DX = undefined. ; transparent ; bendline ; ends the line ( adds y loc = 1 x loc = 0 ) ; transparent (could return: AX = 0xE0A ; BX = 7) ; bwritestring ; Writes a 0 terminated string to screen ( string is at ds:si ) ; transparent, uses video page 0, normal white ; bwritestr ; ax = address of string, writes 0 terminated string via bios @ x,y ; transparent, writes at cursor, returns :AX = undefined ; BX = 7 ; display_character ; al = character bl = color ; display_text ; ds:si - text, bl = color ; bscroll ; scrolls text window ; bwriteintn ; AX = signed number, BX = base, nested ; bwritelongintn; EAX = signed number, EBX = base, nested ; bwriteint ; AX = signed number, BX = base ; bwritelongint ; EAX = signed number, EBX = base ; bwriteword ; AX = number, BX = base ; bwritedword ; EAX = number, EBX = base ; bwritewordu ; writes AX to screen @ x,y (at cursor) ; unrolled, returns: AX,CX,DX = undefined ; BX = 7 ; bwritedwordu ; writes EAX to screen @ x,y (at cursor) ; unrolled, returns: EAX,ECX,EDX = undefined ; BX = 7 ; bwritedwordx ; writes EAX to screen @ x,y (at cursor) ( speed optimized ) ; uses no stack, returns: EAX,ECX,EDX = undefined ; BX = 7 ; bwritewordx ; writes AX to screen @ x,y (at cursor) ( speed optimized ) ; uses no stack, returns: AX,CX,DX = undefined ; BX = 7 ;******** EOF Textmode Stuff ******** ;******** Graphic Screen Stuff ******** ; set320x200x256: ; set80x25t: ( fucks up screen on win98se if used first time from normal res, ok from graph mode ) ;******** EOF Graphic Screen Stuff ******** ;-begining of code- ;******** Keyboard Stuff ******** bkeypressed: ;Beware! Don't call INT 16h with high transmission rates, it won't work! mov ah,1 ;Return: ZF set if no keystroke available int 16h ;ZF clear if keystroke available, AH = BIOS scan code, AL = ASCII character ret ;note: no extended keys bradkeystandard: ;returns: AH = BIOS scan code AL = ASCII character xor ax,ax ; this function discards any extended keystrokes, int 16h ; returning only when a non-extended keystroke is available ret breadkey: ;returns: AH = BIOS scan code AL = ASCII character note: enhanced mov ah,$10 int $16 ret bkeycheck: ;returns: AH = BIOS scan code AL = ASCII character note: enhanced mov ah,0x11 ;Return: ZF set if no keystroke available, ZF clear if keystroke available int 0x16 ;only checks buffer without removing key ret bpushkey: ;cx = code to store, in keyboard buffer (AT/PS w enh keybd only) mov ah,5 ;CH = BIOS scan code, CL = ASCII character note: enhanced int 16h ;Return: AL = status: 00h if successful, 01h if keyboard buffer full ret bshift: ;GET SHIFT FLAGS, Return: AL = shift flags, AH destroyed by many BIOSes mov ah,2 int 16h ret bshiftextended: ; GET EXTENDED SHIFT STATES (enh kbd support only) mov ah,12h int 16h ret ;******** EOF Keyboard Stuff ******** ;******** Textmode Stuff ******** cursoron: ; Turns CURSOR ON. mov ah,1 mov cx,0x0607 int 10h ret cursoroff: ; Turns CURSOR OFF. mov ah,1 mov cx,0x1400 int 10h ret cursorhidden: ; Returns 1 if cursorhidden, 0 otherwise. mov ah,0x03 int 10h xor al,al cmp ch,$20 jne .skip mov al,1 .skip: ret bgotoxy: ; dl=x, dh=y ( 0,0 = upper left ) RETURNS: AX,BX,DX = undefined. push ax dx ; transparency mov ah,2 xor bh,bh int 10h pop dx ax ret bendline: ; ends the line ( adds y loc = 1 x loc = 0 ) push ax bx ; returns: AX = 0xE0A ; BX = 7 mov bx,7 mov ax,$E0D int 10h mov al,$A int 10h pop bx ax ret bwritestring: ; Writes a 0 terminated string to screen ( string is at ds:si ) push ax bx mov bx,7 ; use video page 0, normal white mov ah,$e localloop: lodsb or al,al jnz next_char pop bx ax ret next_char: int 10h jmp localloop bwritestr: ; ax = address of string, writes 0 terminated string via bios @ x,y push bx si ; writes at cursor, saves si, returns :AX = undefined ; BX = 7 mov bx,7 mov si,ax mov ah,$e .up: lodsb or al,al jz .down int 10h jmp .up .down: pop si bx ret display_character: ; al = character bl = color xor bh,bh mov cx,1 mov ah,9 int 10h mov ah,0Eh int 10h ret display_text: ; ds:si - text, bl = color xor bh,bh mov cx,1 .display: lodsb or al,al jz .end cmp al,0Dh je .type cmp al,0Ah je .type mov ah,9 int 10h .type: mov ah,0Eh int 10h jmp .display .end: ret bscroll: ; scrolls text window mov ax,0600h ; scroll up window, AL=0 means: clear entire window mov bh,4Ch ; attribute used to fill the window mov cx,0000h ; row and column of upper left corner mov dx,184Fh ; row and column of lower right corner int 10h ret bwriteintn: ; AX = signed number, BX = base, nested or ax,ax jns .printit ; if it's not negative, we don't print any signs push ax mov ax,$e2d int 10h pop ax neg ax ; do the number positive .printit: jmp bwriteword ; now we can print the number... ret bwritelongintn: ; EAX = signed number, EBX = base, nested or eax,eax jns .printit ; if it's not negative, we don't print any signs push ax mov ax,$e2d int 10h pop ax neg eax ; do the number positive .printit: jmp bwritedword ; now we can print the number... ret bwriteint: ; AX = signed number, BL = base or ax,ax jns .printit ; if it's not negative, we don't print any signs push ax mov ax,$e2d int 10h pop ax neg ax ; do the number positive .printit: push ax bx cx dx and bx,$ff cmp bl,2 ; base can't be less than 2 |
|||
![]() |
|
b 24 Oct 2004, 14:11
is this code for me!!
if yes then i didnt know!! i didnt undersatdn it!! and sir, i ahve a problem dealing with the jumps they are excuted whether there's an error or not!!! i guess i cant write a jum condition lol i defined my problem , it's a progress i guess! lol |
|||
![]() |
|
b 24 Oct 2004, 14:14
u know i read it again
yeh i realized what u r doing but i need to study it again thx no really thx i got it u r the best sir |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.