flat assembler
Message board for the users of flat assembler.

Index > Main > Executing input instructions after program code body

Author
Thread Post new topic Reply to topic
xidevel



Joined: 14 Jan 2013
Posts: 2
xidevel
After having been successful in MBR coding: program displayed ASCII which I typed (minimalistic editor) - I decided to improve it. Not only it shows the input, but also it should execute the sequence:
Code:
00000000  BB0000            mov bx,0x0 ; bx=0 (for the line #14) as BIOS haven't cleaned BX
00000003  31C0              xor ax,ax
00000005  CD16              int 0x16 ; how many times you reiterate symbol-input
00000007  B400              mov ah,0x0 ; preparing ax for one-byte XCHG (remove received):
00000009  2C30              sub al,0x30 ; key scancode from ah (=0) & al=ascii-30=num
0000000B  91                xchg ax,cx ; actual direct number to loop count
0000000C  6800B8            push word 0xb800
0000000F  1F                pop ds
00000010  31C0              xor ax,ax
00000012  CD16              int 0x16
00000014  8807              mov [bx],al ;after input ASCII-part you see on screen
00000016  2E88063200        mov [cs:0x32],al ; GOTO after main body in CS:
0000001B  43                inc bx
0000001C  43                inc bx ;1 symbol=2 bytes --> cycle bx X 2
0000001D  E2F1              loop 0x10 
?
;now after loop newly written code should run
    


The program is in CS code. That is why I used 2E (CS segment prefix) to write directly after main program body. As the program is 31 byte long, and I'm not sure I know how to use [IP] with the relative addressing then mov [cs:0x32],al - is the best solution. I input Alt+keypad EA0000FFFF (reboot)=alt.. 234 0 0 255 255 . (0 and 255 are not showing at all nor even an empty space).

Program doesn't work.

Whichever combination of instructions I used the program seems to behave the same, showing glitches on screen.

Before there also was not working example of the program, as I used jmp to execute videobuffer: EA0000B800 jmp word 0xb8:0000. But as it is interlaced (next but one/every second byte) - it seems it can't execute consecutive instructions.

It was just one of reasons I put interted symbols right after the programs body.
Post 14 Jan 2013, 14:02
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Is the stack (SS / SP) initialized ?
Post 14 Jan 2013, 14:30
View user's profile Send private message Send e-mail Reply with quote
SeproMan



Joined: 11 Oct 2009
Posts: 55
Location: Belgium
SeproMan
xidevel,

You are putting every byte of code at the same address!
Use an extra index register like "mov [cs:0x32+di],al"
Also make sure the 32nd byte is a "nop" instruction.

_________________
Real Address Mode.
Post 15 Jan 2013, 13:27
View user's profile Send private message Reply with quote
SeproMan



Joined: 11 Oct 2009
Posts: 55
Location: Belgium
SeproMan
xidevel,

You wrote: "Before there also was not working example of the program, as I used jmp to execute videobuffer: EA0000B800 jmp word 0xb8:0000."
This might still work considering the output on the text screen will not be readable anyway. Just "inc bx" only once.
Please note that the jump is actually to 0xB800:0000.

_________________
Real Address Mode.
Post 15 Jan 2013, 13:46
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.

Powered by rwasa.