flat assembler
Message board for the users of flat assembler.

Index > DOS > new asssembler problem

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
I'm not picking at you,
but if you can't describe what your problem is, then noone can help you.

lets say for example :

i'don't know how to write a text to screen in green.
then rotate it twice counter clock-wise

now this is a problem, and if someone knows the answer, i'm sure he/she will help you.
regards
Post 22 Oct 2004, 17:46
View user's profile Send private message Visit poster's website Reply with quote
b



Joined: 15 Oct 2004
Posts: 11
b
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
Post 22 Oct 2004, 20:47
View user's profile Send private message MSN Messenger Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
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 Smile
  jge .start
  mov bl,10     ; using bx = 10 instead
  .start:
  xor cx,cx     ; cx = 0
  .new:
  xor dx,dx     ; dx = 0
  div bx        ; number / base
  push dx       ; push the remainder
  inc cx        ; increase the "digit-count"
  or ax,ax      ; if the quotient still is not 0, do it once more
  jnz .new
  .loop:
  pop ax        ; pop the remainder
cmp al,10
sbb al,69h
das
mov ah,$e
int 10h
  loop .loop
  pop dx cx bx ax
ret

bwritelongint:     ; EAX = signed number, BL = base
  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:
  push eax ebx ecx edx
  and ebx,$ff
  cmp bl,2 ; base can't be less than 2 Smile
  jge .start
  mov bl,10     ; using bx = 10 instead
  .start:
  xor ecx,ecx     ; cx = 0
  .new:
  xor edx,edx     ; dx = 0
  div ebx        ; number / base
  push dx       ; push the remainder
  inc ecx        ; increase the "digit-count"
  or eax,eax      ; if the quotient still is not 0, do it once more
  jnz .new
  .loop:
  pop ax        ; pop the remainder
cmp al,10
sbb al,69h
das
mov ah,$e
int 10h
  loop .loop
  pop edx ecx ebx eax
ret

bwriteword: ; AX = number, BL = base
  push ax bx cx dx
  and bx,$ff
  cmp bl,2 ; base can't be less than 2 Smile
  jge .start
  mov bl,10     ; using bx = 10 instead
  .start:
  xor cx,cx     ; cx = 0
  .new:
  xor dx,dx     ; dx = 0
  div bx        ; number / base
  push dx       ; push the remainder
  inc cx        ; increase the "digit-count"
  or ax,ax      ; if the quotient still is not 0, do it once more
  jnz .new
  .loop:
  pop ax        ; pop the remainder
cmp al,10
sbb al,69h
das
mov ah,$e
int 10h
  loop .loop
  pop dx cx bx ax
ret

bwritedword: ; EAX = number, BL = base
  push eax ebx ecx edx
  and ebx,$ff
  cmp bl,2 ; base can't be less than 2 Smile
  jge .start
  mov bl,10     ; using bx = 10 instead
  .start:
  xor ecx,ecx     ; cx = 0
  .new:
  xor edx,edx     ; dx = 0
  div ebx        ; number / base
  push dx       ; push the remainder
  inc ecx        ; increase the "digit-count"
  or eax,eax      ; if the quotient still is not 0, do it once more
  jnz .new
  .loop:
  pop ax        ; pop the remainder
cmp al,10
sbb al,69h
das
mov ah,$e
int 10h
  loop .loop
  pop edx ecx ebx eax
ret

bwritewordu: ; writes AX to screen @ x,y (at cursor)
mov bx,7    ; returns:  AX,CX,DX = undefined ; BX = 7
cmp ax,10000
jnb .down1
cmp ax,1000
jnb .down2
cmp ax,100
jnb .down3
cmp ax,10
jnb .down4
jmp .down5
.down1:
mov dx,0
mov cx,10000
div cx
add al,48
mov ah,0xE
int 10h
mov ax,dx
.down2:
xor dx,dx
mov cx,1000
div cx
add al,48
mov ah,0xE
int 10h
mov ax,dx
.down3:
mov cl,100
div cl
mov dl,ah
add al,48
mov ah,0xE
int 10h
mov al,dl
xor ah,ah
.down4:
mov cl,10
div cl
mov dl,ah
add al,48
mov ah,0xE
int 10h
mov al,dl
.down5:
add al,48
mov ah,0xE;
int 10h
ret

bwritedwordu: ; writes EAX to screen @ x,y (at cursor)
mov bx,7    ; returns:  EAX,ECX,EDX = undefined ; BX = 7
cmp eax,1000000000
jnb .down1
cmp eax,100000000
jnb .down2
cmp eax,10000000
jnb .down3
cmp eax,1000000
jnb .down4
cmp eax,100000
jnb .down5
cmp eax,10000
jnb .down6
cmp eax,1000
jnb .down7
cmp eax,100
jnb .down8
cmp eax,10
jnb .down9
jmp .down10
.down1:
xor edx,edx
mov ecx,1000000000
div ecx
add al,48
mov ah,0xE
int 10h
mov eax,edx
.down2:
xor edx,edx
mov ecx,100000000
div ecx
add al,48
mov ah,0xE
int 10h
mov eax,edx
.down3:
xor edx,edx
mov ecx,10000000
div ecx
add al,48
mov ah,0xE
int 10h
mov eax,edx
.down4:
xor edx,edx
mov ecx,1000000
div ecx
add al,48
mov ah,0xE
int 10h
mov eax,edx
.down5:
xor edx,edx
mov ecx,100000
div ecx
add al,48
mov ah,0xE
int 10h
mov eax,edx
.down6:
xor edx,edx
mov ecx,10000
div ecx
add al,48
mov ah,0xE
int 10h
mov eax,edx
.down7:
xor dx,dx
mov cx,1000
div cx
add al,48
mov ah,0xE
int 10h
mov ax,dx
.down8:
xor dx,dx
mov cl,100
div cl
mov dl,ah
add al,48
mov ah,0xE
int 10h
mov al,dl
xor ah,ah
.down9:
mov cl,10
div cl
mov dl,ah
add al,48
mov ah,0xE
int 10h
mov al,dl
.down10:
add al,48
mov ah,0xE
int 10h
ret

bwritewordx: ; writes AX to screen @ x,y (at cursor) ( speed optimized )
mov bx,7     ; uses no stack, returns:  AX,CX,DX = undefined ; BX = 7
mov cx,10000
.sroll1:
cmp ax,cx
jae .sskip2
.divide:
push ax
mov ax,cx
mov cx,10
xor dx,dx
div cx
mov cx,ax
pop ax
jcxz .sskip
jmp .sroll1 ; remove leading zeroes
.rolldivide:
push ax
mov ax,cx
mov cx,10
xor dx,dx
div cx
mov cx,ax
pop ax
jcxz .extroll
.sskip2:
xor dx,dx
div cx
.sskip:
add al,48
mov ah,0xE
int 10h
mov ax,dx
jcxz .extroll
jmp .rolldivide
.extroll:
ret

bwritedwordx: ; writes EAX to screen @ x,y (at cursor) ( speed optimized )
mov bx,7      ; uses no stack, returns:  EAX,ECX,EDX = undefined ; BX = 7
mov ecx,1000000000 ; if bx= 0 then writes in graphic mode
.sroll1:
cmp eax,ecx
jae .sskip2
.divide:
push eax
mov eax,ecx
mov ecx,10
xor edx,edx
div ecx
mov ecx,eax
pop eax
 jecxz .sskip
  jmp .sroll1 ; remove leading zeroes
.rolldivide:
push eax
mov eax,ecx
mov ecx,10
xor edx,edx
div ecx
mov ecx,eax
pop eax
 jecxz .extroll
.sskip2:
xor edx,edx
div ecx
.sskip:
add al,48
mov ah,0xE
int 10h
mov eax,edx
 jecxz .extroll
  jmp .rolldivide
.extroll:
ret
;******** EOF Textmode Stuff ********

;******** Graphics Screen Stuff ********
set320x200x256:
mov ax,$13
int $10
ret

set80x25t: ;  ( fucks up screen on win98se if used first time from normal res, ok from graph mode )
mov ax,$07
int $10
ret
;******** EOF Graphics Screen Stuff ********

;EOF bios.inc
    
Post 24 Oct 2004, 00:13
View user's profile Send private message Visit poster's website Reply with quote
b



Joined: 15 Oct 2004
Posts: 11
b
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
Post 24 Oct 2004, 14:11
View user's profile Send private message MSN Messenger Reply with quote
b



Joined: 15 Oct 2004
Posts: 11
b
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
Post 24 Oct 2004, 14:14
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.