On Jun 9, 12:39 pm, "wolfgang kern" <
nowh...@never.at> wrote:
> Steve wrote:
>
> ...
> |Thanks for all the comments, informative to me.
>
> |Coincidently, this morning I found an app note AP-949 on the PAUSE
> |instruction for spin locks:
>
>
http://software.intel.com/en-us/articles/ap949-using-spin-loops-on-in...
>
> PAUSE (this new '66 90') is quite different to wait ...
>
> |which also mentions the use HLT for the similar purpose, and the
> |rational for it.
>
> HLT were also a vital instruction on Z-80, I actually connected
> a LED to this HALT-pin just to show that the system is ready and
> is waiting for somthing to occure ...
>
> __
> wolfgang
> remember now good old times when we were able to calculate speed easy :)
Oh, I remember the z-80 being seen as a huge improvement to the 8080,
with its block move instruction LDIR and the second set of registers.
About the difference in scale between the 32 bit pentium and the 32
bit multi-cores.
As to HLT on the pentium, here's a snippet of some sandbox code which
improved the polling loop count from approximately 0198h to 0002h.
;; I started with code by Chris Giese, fn; kbd:. Its purpose is to
wait
;; until 8042 keyboard controller is ready to accept a command or data
;; byte.
;; This is polling code, not an ISR. in al, 64h returns the status
byte
;; (bit 5 Aux Dev OBF, bit 3 C/D Flg, bit 1 inbufr, bit 0 outbufr).
;; Without hlt, the routine loops around about 0198h times on this
old
;; pentium mmx, 233mhz, machine, until both bit 0 and bit 1 become
clear,
;; indicating that the 8042 is ready to accept. With one hlt
instruction,
;; the loop count drops to 2, with two hlt instructions, the loop
count
;; drops to one. It seems like the hlt halts until a timer tick
interrupt.
;;
;; This is sandbox code, not fit for application, just for exploring
the
;; protocols for communicating with the 8042/keyboard. Currently the
Out-
;; put Buffer (in al,60h) isn't debouncing properly, a couple of
command
;; repeats are required to get the expected output returned (8042
self-
;; test, for example).
[SECTION .code]
clr_OBF: ;; read and discard
in al, 60h
clr_8042_busy: ;; get count, initially 0,
sti ;; entry state is cli, enable else hlt hangs.
hlt ;; -= test reducing loop count =- (~198h->2h)
hlt ;; (2->1)
cli
inc word [statCnt] ;; update it for looping count.
in al, 64h ;; get status, becomes
mov [stat8042], al ;; last recorded 'pass' value.
test al, 01h ;; bit 0 - Output Buffer Full @ 60h
jnz clr_OBF
test al, 02h ;; bit 1 - Input Buffer Full @ 64h, cmd write
;; or @ 60h, data write.
jnz clr_8042_busy ;; not clear yet, loop
;; --- test that Status Register's Command/Data Flag is Zero before
issuing commad ---
;- test al, 08h ;; bit 3 - C/D flag
;- jnz clr_8042_busy
;; --- test aux dev OBF ---
test al, 0010_0000b ;; bit 5
jnz clr_OBF
clc
mov [VidRow], byte 1
mov [VidCol], byte 40
Disp_Stat_byt:
mov al, [stat8042]
call Byte2_Ascii ;; al has byte, rets AH,AL ascii chrs
mov [msgStat8042], ah ;; of byte.
mov [msgStat8042 + 1], al
mov al, [statCnt+1] ;; hi byte of word
call Byte2_Ascii
mov [msgStatCnt], ah
mov [msgStatCnt+1], al
mov al, [statCnt] ;; lo byte of word
call Byte2_Ascii
mov [msgStatCnt+2], ah
mov [msgStatCnt+3], al
mov si, msgStat8042
call DisplayMessage ;; poke to vid mem at VidRow,VidCol
mov word [statCnt], 0 ;; reset for next call
RET
[SECTION .data]
stat8042: db 0
statCnt: dw 0
msgStat8042: db ' h :last stat ',
msgStatCnt: db ' h :loop cnt',0
-----
Steve