flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > jmp loop until int 16h 8086

Author
Thread Post new topic Reply to topic
connor



Joined: 07 Jun 2016
Posts: 70
Location: sj ca
connor
im trying to figure out in 8086

how do i get my code to loop untill i press a key

loop:

jmp next if key pressed ;int 16h

jmp loop

next:

?????

and then profit

_________________
9518741
Post 05 Feb 2020, 04:17
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Hi connor,

My 16-bit code is a bit rusty.
However I wrote this for you. I've tried it on Emu8086 and Windows XP.
It's a com file so it won't run on 64-bit Windows without DosBox.
Code:

    org 100h

    _loop:

    ; check for a keystroke
    mov ah,1
    int 16h
    jz _loop

    ; a keystroke is present
    ; remove it from the keyboard buffer
    xor ah,ah
    int 16h

    ; AH = BIOS scan code
    ; AL = ASCII character

    ; check for ESC
    cmp al,27
    jne _loop

    ret
    
Post 06 Feb 2020, 08:26
View user's profile Send private message Reply with quote
connor



Joined: 07 Jun 2016
Posts: 70
Location: sj ca
connor
;face palm

thank you

what if i wanted to add other keys to do other stuff

and what about placing text onto a specific location

and what about boot straps, what about proctection and long mode

and nine million and nine other basic things i cant find a straignt answer for

_________________
9518741
Post 07 Feb 2020, 04:59
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Quote:
what if i wanted to add other keys to do other stuff

A small extension to the code.
Code:
    org 100h

    _loop:

    ; check for a keystroke
    mov ah,1
    int 16h
    jz .C

    ; a keystroke is present
    ; remove it from the keyboard buffer
    xor ah,ah
    int 16h

    ; AH = BIOS scan code
    ; AL = ASCII character

    ; check for ESC
    cmp al,27
    je .E

    ; check for A,D,W,S
    cmp al,'A'
    je .A
    cmp al,'D'
    je .D
    cmp al,'W'
    je .W
    cmp al,'S'
    je .S

    jmp .C

.A:
    ; do something
    jmp .C

.D:
    ; do something
    jmp .C

.W:
    ; do something
    jmp .C

.S:
    ; do something
    jmp .C

    ; code

.C:

    ; code

    jmp _loop

.E:
    ret
    


Quote:
and what about placing text onto a specific location

This code taken from the Emu8086 documentation. Remove 'offset' if you compile with fasm.
Code:
    org 100h

    ; INT 10h / AH = 2 - set cursor position.

    ; input:
    ; DH = row.
    ; DL = column.
    ; BH = page number (0..7).

    mov dh, 10
    mov dl, 20
    mov bh, 0
    mov ah, 2
    int 10h

    ; INT 21h / AH=9 - output of a string at DS:DX. String must be terminated by '$'. 

    mov dx, offset msg
    mov ah, 9
    int 21h

    ret

    msg db "hello world $"
    


Hope this helped.
Post 07 Feb 2020, 10:07
View user's profile Send private message Reply with quote
connor



Joined: 07 Jun 2016
Posts: 70
Location: sj ca
connor
at least it sets me in the right direction

much better than anything else

assembly i understand easy

verilog and vhdl, what are they smoking with tat sheat

_________________
9518741
Post 08 Feb 2020, 04:24
View user's profile Send private message Reply with quote
connor



Joined: 07 Jun 2016
Posts: 70
Location: sj ca
connor
let me bug you one more time,

what about

the PC speaker

and the sound blaster input and out put?

_________________
9518741
Post 09 Feb 2020, 16:34
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Try searching the forum. A quick search for "PC SPEAKER" gave me some results. The same goes for sound blaster (i guess).

https://board.flatassembler.net/topic.php?t=2432
https://board.flatassembler.net/topic.php?t=14049
https://board.flatassembler.net/topic.php?t=15222
Post 10 Feb 2020, 08:16
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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 GitHub, YouTube, Twitter.

Website powered by rwasa.