flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Boot loader....w/o the...boot loader?

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



Joined: 28 Jul 2005
Posts: 72
Night Rider
tom tobias, i think that in this code (string output) no difference between OR or TEST (test is boolean operator too). They both put ZF...
Post 04 Aug 2005, 13:39
View user's profile Send private message ICQ Number Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
smiddy wrote:


In my opinion this reads pretty straight forward to me.


Yup, excellent in my opinion. I absolutely agree. Your solution is perfect, my suggestion, to use TEST, as Night Rider pointed out, is silly.
CMP is the correct instruction to use. Very clear writing Smiddy!
Post 04 Aug 2005, 17:39
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
PrintMsg:
        mov ah, 0x0E                                 ; teletype output
        mov bh, 0x00                                 ; we are writing on page number 0
        jmp .loadChar

.printChar:
        int 0x10                                     ; call bios video function

.loadChar:
        lodsb                                        ; load [si] to al and increment si
        test al, al                                  ; set zero flag if al = 0
        jnz .printChar                               ; if zero flag is not set, jump to printChar
        ret                                          ; return    


It's only a silly modification I know but I think it could be better. If the Opcodes help of MASM (by hutch) is right "test reg, reg" is one clock faster than "cmp reg, immed" and "or reg, reg" on a 386.
Post 04 Aug 2005, 19:43
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Thanks locodelassembly, Well Done! Smile
Post 05 Aug 2005, 15:08
View user's profile Send private message Reply with quote
Night Rider



Joined: 28 Jul 2005
Posts: 72
Night Rider
What the difference - use test/or + jf or cmp... or is just nice solution.
Post 05 Aug 2005, 18:37
View user's profile Send private message ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
The difference is this loop is one instruction less than the original code and "test reg, reg" takes only one clock on 386. "cmp reg, immed" and "or reg, immed" takes two clocks on 386.
Post 05 Aug 2005, 19:20
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
See attachment for timings, I took this from MASM by hutch, good Docs, bad assembler Razz


Description: Opcodes help
Download
Filename: OPCODES.zip
Filesize: 65.4 KB
Downloaded: 279 Time(s)

Post 05 Aug 2005, 23:48
View user's profile Send private message Reply with quote
Night Rider



Joined: 28 Jul 2005
Posts: 72
Night Rider
Ok, i have been searching for such document for a long time...
Post 06 Aug 2005, 19:11
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
According to Intel's 80386 Manual from 1986 (I once posted a copy here) "test reg,reg" takes two clocks, too.
Post 06 Aug 2005, 21:22
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Tomasz: I thought it's not an error of the docs because "test" don't save the result but I was wrong, the doc has a mistake. Thank you.

Night Rider: The new code now it's just "a nice solution" with one instruction less in the loop.
Post 06 Aug 2005, 23:53
View user's profile Send private message 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 GitHub, YouTube, Twitter.

Website powered by rwasa.