Prev: masm linking from console
Next: NASM HelloWorld - DOS
From: Herbert Kleebauer on 18 Jul 2007 17:31 Have done a little bit code clean up and added some comments. It still requires a 24 bit true color screen but packet splitting should now be ok. Press any key or mouse button to exit the program. Most of the code is stolen from Frank (hope he doesn't mind, at least now he gets the code back in a readably assembler syntax). Here the binary (the source in a follow up): #!/bin/bash name=xdemo echo -n>$name x=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789123 for (( i=0; i<65; i++ )); do eval _$(( $i/62 ))${x:$i:1}=$(( $i&63 )); done n=0; m=0 (while read -n 1 c; do case $c in [A-Za-z0-9+/=]) if [ "$c" == "+" ]; then c=11; elif [ "$c" == "/" ]; then c=12; elif [ "$c" == "=" ]; then c=13; else c=0$c; fi e=$d; d=$c ; eval c=\$_$c; n=$(( $n*64+$c )); m=$(( $m+1 )) if [ "$m" == "4" ]; then echo -n -e \\$(( ($n>>22&7)*100+($n>>19&7)*10+($n>>16&7) ))>>$name if [ "$e" != "13" ]; then echo -n -e \\$(( ($n>>14&7)*100+($n>>11&7)*10+($n>>8&7) ))>>$name; fi if [ "$d" != "13" ]; then echo -n -e \\$(( ($n>>6&7) *100+($n>>3&7)*10+($n&7) ))>>$name; fi n=0; m=0 fi esac done)<<"---"; f0VMR gEBAQAAAAAAAAAAAAIAAwABAAA Ad IA ECDQAAAAAAAAAAAAAADQAIAACA AA AAAAAAAEA AAAAAA AAAIAECACABAhEBQAARAUAAA UAA AAA EAAAAQAAAEQFAABElQQIRJUE CIg AAAC07gMA BgAAAAA QAACJJcx9CAhqAGoBagGJ4 bsBA AAAu GYAAADNgIPEDIXAD4gHAgA Ao9B 9CAhoEwAA AGgwhQQI /zXQfQgIieG7AwAAALhm AAAAz YCDxA yFwA+I2QEAAIsd0H0ICL kDAAA AuDcAAADN gIXAD4i/A QAAix3QfQgIuQQAAAC JwoHKA AgAALg 3AAAAzYCFwA+InQEAA LhMlQQ IugwAAADo HwIAAA+CKA AAAGaJHVKVBAhmiT VUlQQI6 P0CAACJ yI1TA4Pi/OjwAgAA ieiNVgO D4vzo4wIA ADHtvvh/CAi /AAQAAInwifrop QMAAHT1g D34fwgIA Q+FNwEAAAHFAcY px4H9CAA AAHLaD7cd /n8ICI0cnQgA AAA53XLIvvh/ CAiLRgyLV hCJ0ffZIc qjXJUECKOIlQ QIo5SVBAi juJUECKOs lQQIAdCjkJUEC KO8lQQIAdA Pt0YYg8ArJ PwPtlYdweI DAcKLBBajY JUECItEFhS jaJUECC1A AcgA0egl/3///6 PElQQIuF iVBAi6LAAAA OgkAgAA6GgC AAB0CYA4 AA+EjAAAALi ElQQIuggA AADoBQIAAOhJAgA AdAmAO AAPhG0AAAC4j JUECLocAAAA6 OYBAAD oKgIAAHQJgDg AD4ROAAAA uKiVBAi6DAAAAOjH AQAA 6AsCAAB0CYA4A A+ELwAAAOiWAA AA6D EAAAC4tJUECLo Y6AMA6J4B AADo4gEAAHTlgDgAd Aq AOAJ0BYA4BHXWu wAAAAC4AQAAAM2 AY DHb/wXUfQgIuQD 6AAAx/4n4 MdK7QAEAAPfzLXgAAA CB6qAAAAB/Avfai cMPr9sB0PfoAcN0 CTHSuMAnCQD38wM F1H0ICMDo Ag+2wIsEhdh9CAiJBL 3 MlQQIR+KzYZDDY L7YfQgIuAAAAAC5 Q AAAAIkGg8YEBBB mBQAIBQAA BADi7mGQw1BSV4s9z H0I CIsHjXyHCIs3g 8cEhfYPhKoAAAC BPk hPTUV164B+BD1 15YPGBYPJ /0GAPA4AdfkJyQ+E hwAAA IH5AAEAAA+He wAAAL/YfggI86 S4Ly5 YYau4dXRob6u 4cml0eavG BwC72H4ICDHJuAU AAADNgI XAeE2Jw7n4f wgIugAEAAC4A wAAAM2A PQAEAAAPg9j +//+JxbgG AAAAzYCF7XQivv h/CAgB9TH AZq1mSHQWu QQAAABmrWbB yAgBxuL2O e5y5/nrKrk CAAAAictm rWbByAgBxuL2Z q1mwcgIifEP t9gB3matZ sHICIn1D7f w+F9aWMNgic WJ1on3gf8 AQAAAdgW/ AEAAAGoAV1X/ NdB9CAiJ4bsJA AAAuGYAA ADNgIPEED 31////dN6FwA+ IOv7//yn GdAQBxeu/ YZDDUVZXoUi VBAg9IAAAAHM7iz VElQQIv /h/CAiJP USVBAg593QICcB0 BInB86S 6AAQAACnC jYD4fwgI6F AAAAB1AutIAQVIlQQ I67mLN USVBAiA PiIPh9b9//+APgAPh M39//+ 6IAAAAIA+ AXUMA1YMA 1YMA1YMA1YMOdByk4nw KRVIl QQIARV ElQQIX15Zw1FTagBSUP 810H0 ICInhuwoA AAC4ZgAA AM2Ag8QQW1k99f///3QIh cAPi HP9// /DAAABAC90bXAvLlgxMS1 1bml 4L1gwAPh/ CAgAAAA AbAALAAAAAAAAAAAAAQALAA AAA AAAA AAAAAAAAIACkAEAAAAAAAAA AAI KAAAAAAAA AQAAAA UAAAAIAAIAAAAAADcABwAAAAA AA AAA AA0AAAADAAAA////AP+AAAAqA AM AAAAAAAAA AABIA gb6AAAAAAAAAABAAcgAoABkAAAY A AA= --- chmod +x $name #############################################################################
From: Herbert Kleebauer on 18 Jul 2007 17:33 Herbert Kleebauer wrote: > Have done a little bit code clean up and added some comments. > It still requires a 24 bit true color screen but packet > splitting should now be ok. Press any key or mouse button > to exit the program. Most of the code is stolen from Frank > (hope he doesn't mind, at least now he gets the code back > in a readably assembler syntax). Here the binary (the source > in a follow up): ;=========================================================================== seg32 @=$08048000 code_offset=@@ code_addr: ;--------------------------- ELF header ----------------------------------- dc.l $464c457f,$00010101,0,0,$00030002,1,main,$34,0,0,$00200034,2,0 dc.l 1,code_offset,code_addr,code_addr,code_filez,code_memsz,5,4096 dc.l 1,data_offset,data_addr,data_addr,data_filez,data_memsz,6,4096 ;--------------------------- code ------------------------------------------ main: move.l r7,stack_ptr ; save initial stack pointer ; ******************** get socket handle *************************** moveq.l #0,-(sp) ; no protocol specified moveq.l #1,-(sp) ; 1: SOCK_STREAM (/usr/include/linux/net.h) moveq.l #1,-(sp) ; 1: AF_UNIX, AF_LOCAL (/usr/include/linux/socket.h) move.l r7,r2 ; pointer to parameter for "socket" move.l #1,r3 ; "socket" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 addq.l #3*4,r7 ; free space for parameters tst.l r0,r0 ; ERROR bmi.l err move.l r0,x_handle ; ********** connect socket to /tmp/.X11-unix/X0" ****************** move.l #sockaddr_un_l,-(sp) move.l #sockaddr_un,-(sp) ; (/usr/include/linux/un.h) move.l x_handle,-(sp) ; socket handle move.l r7,r2 ; pointer to parameter for "connect" move.l #3,r3 ; "connect" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 addq.l #3*4,r7 ; free space for parameters tst.l r0,r0 ; ERROR bmi.l err ; *************** make socket read non blocking ******************* move.l x_handle,r3 ; socket handle move.l #3,r2 ; F_GETFL (/usr/include/asm/fcntl.h) move.l #55,r0 ; fcntl (/usr/include/asm/unistd.h) trap #$80 tst.l r0,r0 ; ERROR bmi.l err move.l x_handle,r3 ; socket handle move.l #4,r2 ; F_SETFL (/usr/include/asm/fcntl.h) move.l r0,r1 or.l #$800,r1 ; O_NONBLOCK (/usr/include/asm/fcntl.h) move.l #55,r0 ; fcntl (/usr/include/asm/unistd.h) trap #$80 tst.l r0,r0 ; ERROR bmi.l err ; ******************* send connect message ************************* move.l #send1,r0 ; pointer to connect message move.l #send1l,r1 bsr.l get_xauth ; try to read .Xauthority bcs.l _11 ; no success, let's try without auth. move.w r3,send1+6 ; insert name length move.w r5,send1+8 ; insert data length bsr.l x_send ; send header move.l r2,r0 ; pointer to name lea.l 3.b(r3),r1 ; pad to a multiple of 4 andq.l #$fffffffc,r1 bsr.l x_send ; send name move.l r4,r0 ; pointer to data lea.l 3.b(r5),r1 ; pad to a multiple of 4 andq.l #$fffffffc,r1 _11: bsr.l x_send ; send data eor.l r4,r4 ; number of total bytes read move.l #buf2,r5 ; pointer to buffer for next read move.l #buf2l,r6 ; max. bytes to read _10: move.l r5,r0 move.l r6,r1 bsr.l x_receive_raw beq.b _10 ; but we need a reply cmp.b #1,buf2 ; success bne.l err ; something went wrong add.l r0,r4 ; total read bytes add.l r0,r5 ; pointer to buffer for next read sub.l r0,r6 ; max. bytes to read cmp.l #8,r4 ; at least 8 bytes read? blo.b _10 ; no, get more movu.wl buf2+6,r3 ; additional data in 4 bytes lea.l 8(r3*4),r3 ; total size in bytes cmp.l r3,r4 ; all read blo.b _10 ; no, get more ; ******************* calculate id's ******************************* move.l #buf2,r5 move.l $0c.b(r5),r0 ; resource_id_base move.l $10.b(r5),r1 ; resource_id_mask move.l r1,r2 neg.l r2 and.l r2,r1 ; resource_id_incr move.l r0,s2a ; wid for CreateWindow move.l r0,s3a ; wid for MapWindow move.l r0,s4a ; wid for CreateDC move.l r0,s5a ; wid for CreateDC move.l r0,s6a ; wid for SetInputFocus add.l r1,r0 ; next id move.l r0,s4b ; cid for CreateDC move.l r0,s5b ; cid for CreateDC add.l r1,r0 ; next id ; move.l r0,resource_id_next ; move.l r1,resource_id_incr ; ******************* get root window id *************************** movu.wl $18.b(r5),r0 ; length of vendor string addq.l #$28+3,r0 ; const header length + round vendor length and.b #$fc,r0 ; round to 4 bytes movu.bl $1d.b(r5),r1 ; number of FORMATs lsl.l #3,r1 ; 8 byte for each FORMAT entry add.l r0,r1 ; offset to root WINDOW id move.l (r5,r1),r0 ; root window move.l r0,s2b ; CreateWindow needs root window id move.l 20.b(r5,r1),r0 ; width/hight of root window move.l r0,s2x ; create window full size sub.l #(200<<16)+320,r0 lsr.l #1,r0 and.l #$ffff7fff,r0 move.l r0,s5x ; center drawing ; ******************* send CreatWindow request ********************* move.l #send2,r0 move.l #send2l,r1 bsr.l x_send bsr.l x_receive beq.b _20 ; no message is a good message cmp.b #0,(r0) ; error message beq.l ende ; ******************* send MapWindow request *********************** _20: move.l #send3,r0 move.l #send3l,r1 bsr.l x_send bsr.l x_receive beq.b _30 ; no message is a good message cmp.b #0,(r0) ; error message beq.l ende ; ******************* send CreatDC request ************************* _30: move.l #send4,r0 move.l #send4l,r1 bsr.l x_send bsr.l x_receive beq.b _40 ; no message is a good message cmp.b #0,(r0) ; error message beq.l ende ; ******************* send SetInputFocust ************************* _40: move.l #send6,r0 move.l #send6l,r1 bsr.l x_send bsr.l x_receive beq.b _60 ; no message is a good message cmp.b #0,(r0) ; error message beq.l ende _60: bsr.l init_color ; init 64 VGA colors ; ******************** main loop *************************** _50: bsr.l annie ; generate next picture move.l #send5,r0 move.l #send5l,r1 bsr.l x_send ; display it bsr.l x_receive beq.b _50 ; no message is a good message cmp.b #0,(r0) ; error message beq.b ende cmp.b #2,(r0) ; key press beq.b ende cmp.b #4,(r0) ; button press bne.b _50 err: ende: move.l #0,r3 ; return code move.l #1,r0 ; exit trap #$80 ; ********* Annie's code to draw a heart **************** annie: movem.l r0-r7,-(sp) eor.l r3,r3 _10: inc.l annie1 move.l #320*200,r2 eor.l r6,r6 _20: move.l r6,r0 ; byte pos in screen eor.l r1,r1 move.l #320,r3 ; 320 lines divu.l r3,r1|r0 ; r0: line 0-199 r1: column 0-319 sub.l #120,r0 ; center y=120 (-120 .. +79) sub.l #160,r1 ; x=160 (-160 .. +159) bgt.b _30 neg.l r1 ; symmetric in x (0 .. 160) _30: move.l r0,r3 muls.l r3,r3,r3 ; r3 = x*x add.l r1,r0 ; r0 = x*x+y muls.l r0,r0,r1|r0 ; r0 = (x*x+y)**2 mod 2*16 add.l r0,r3 beq.b _40 eor.l r1,r1 move.l #600000,r0 divu.l r3,r1|r0 _40: add.l annie1,r0 ; change color lsr.b #2,r0 movu.bl r0,r0 move.l color(r0*4),r0 move.l r0,screen(r6*4) inc.l r6 dbf.l r2,_20 movem.l (sp)+,r0-r7 rts.l ; ****************** initialize 64 VGA colors ********************* init_color: movem.l r0-r7,-(sp) move.l #color,r5 move.l #0,r0 move.l #64,r2 _01: move.l r0,(r5) addq.l #4,r5 add.b #$10,r0 add.w #$000800,r0 add.l #$040000,r0 dbf.l r2,_01 movem.l (sp)+,r0-r7 rts.l ;********************************************************** ;******** read cookie from $home/.Xauthority ************** ;********************************************************** ; * ; input: stack_ptr: original sp at program start * ; output: C=0: cookie found in $home/.Xauthority * ; r2: pointer to protocol name * ; r3: length of protocol name * ; r4: pointer to protocol data * ; r5: length of protocol data * ; C=1: nothing found * ; r2/r3/r4/r5 undefined * ; * ; typedef struct xauth { * ; unsigned short family; * ; unsigned short address_length; * ; char *address; * ; unsigned short number_length; * ; char *number; * ; unsigned short name_length; * ; char *name; * ; unsigned short data_length; * ; char *data; * ; } Xauth; * ;********************************************************** get_xauth: move.l r0,-(sp) move.l r1,-(sp) move.l r6,-(sp) move.l stack_ptr,r6 ; original stack pointer at program start move.l (r6),r0 ; number of arguments lea.l 8.b(r6,r0*4),r6 ; skip arguments + trailing null pointer _20: move.l (r6),r5 ; pointer to next env variable addq.l #4,r6 tst.l r5,r5 ; no more env variables beq.l _notfound cmp.l #'EMOH',(r5) ; HOME found? bne.b _20 ; no, try next cmp.b #'=',4.b(r5) ; HOME= found? bne.b _20 ; no, try next addq.l #5,r5 ; start of HOME path orq.l #-1,r2 _30: inc.l r2 ; count length of HOME path cmp.b #0,(r5,r2) bne.b _30 or.l r2,r2 ; at least one char long? beq.l _notfound ; no, HOME is empty cmp.l #256,r2 ; more than 256 charcters bhi.l _notfound ; somebody tries a buffer overflow move.l #fname,r6 ; buffer for filename rep_r2 move.b (r5)+-,(r6)+-{s1} ; copy HOME path move.l #'aX./',r0 ; add .Xauthority move.l r0,(r6)+-{s1} move.l #'ohtu',r0 move.l r0,(r6)+-{s1} move.l #'ytir',r0 move.l r0,(r6)+-{s1} move.b #0,(r6) ; and a trailing 0 move.l #fname,r3 eor.l r2,r2 ; readonly move.l #5,r0 ; open trap #$80 tst.l r0,r0 ; file open error? bmi.b _notfound ; yes move.l r0,r3 ; file handle move.l #buf2,r2 move.l #buf2l,r1 ; read 1024 byte move.l #3,r0 ; read trap #$80 cmp.l #buf2l,r0 bhs.l err ; .Xauthority >= 1024 byte move.l r0,r4 ; bytes read move.l #6,r0 ; close trap #$80 tst.l r4,r4 ; file empty beq.b _notfound move.l #buf2,r5 add.l r5,r4 ; end of read data eor.l r0,r0 _60: move.w (r5)+-,r0 ; family dec.w r0 beq.b _40 ; 1=FamilyLocal move.l #4,r2 ; skip entry _50: move.w (r5)+-,r0 ror.w #8,r0 ; big -> little endian add.l r0,r5 dbf.l r2,_50 cmp.l r4,r5 ; more data blo.b _60 ; try next entry _notfound: bset.w #0,sr br.b _70 _40: move.l #2,r2 move.l r2,r3 _41: move.w (r5)+-,r0 ror.w #8,r0 add.l r0,r5 ; skip address/number dbf.l r2,_41 _42: move.w (r5)+-,r0 ror.w #8,r0 move.l r5,r2 movu.wl r0,r3 add.l r3,r5 move.w (r5)+-,r0 ror.w #8,r0 move.l r5,r4 movu.wl r0,r5 bclr.w #0,sr _70: move.l (sp)+,r6 move.l (sp)+,r1 move.l (sp)+,r0 rts.l ;********************************************************** ;******** send message to X server ************** ;********************************************************** ; input: r0: pointer to message * ; r1: length of message * ;********************************************************** x_send: movem.l r0-r7,-(sp) move.l r0,r4 ; pointer to next byte of message move.l r1,r5 ; remaining bytes to send _10: move.l r5,r6 cmp.l #16*1024,r6 ; any X server must handle 16k messages bls.b _20 move.l #16*1024,r6 _20: moveq.l #0,-(sp) ; flags move.l r6,-(sp) ; length move.l r4,-(sp) ; pointer to data move.l x_handle,-(sp) ; socket handle move.l r7,r2 ; pointer to parameter for "send" move.l #9,r3 ; "send" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 addq.l #4*4,r7 ; free space for parameters cmp.l #-11,r0 ; EAGAIN: beq.b _20 ; message couldn't be sent, try again tst.l r0,r0 ; ERROR bmi.l err sub.l r0,r5 ; remaining bytes to send beq.b _30 ; nothing, all sent add.l r0,r4 ; pointer to remaining message br.b _10 ; send rest of message _30: movem.l (sp)+,r0-r7 rts.l ;********************************************************** ;******** receive ONE message from X server ********** ;********************************************************** ; input: none * ; output: Z=1: no complete message available * ; r0/r1 undefined * ; Z=0: r0: pointer to message data * ; r1: size of data * ;********************************************************** x_receive: move.l r2,-(sp) move.l r5,-(sp) move.l r6,-(sp) _00: move.l buf2_rest,r0 ; still something in read buffer? cmp.l #32,r0 ; a message has at least 32 bytes bhs.b _10 ; maybe it is a complete message _30: move.l buf2_ptr,r5 ; start of message move.l #buf2,r6 ; start of buffer move.l r6,buf2_ptr ; we copy message to top of buffer cmp.l r5,r6 ; already at top of buffer beq.b _50 ; then nothing to copy or.l r0,r0 ; nothing in buffer beq.b _50 ; then also nothing to copy move.l r0,r2 ; copy to top of buffer rep_r2 move.b (r5)+-,(r6)+-{s1} _50: move.l #buf2l,r1 ; let's try to get some more data sub.l r0,r1 ; not more bytes than space is left in the buf lea.l buf2(r0),r0 ; append it here bsr.l x_receive_raw bne.b _20 ; we could read something br.b _100 ; return with Z=1 _20: add.l r0,buf2_rest ; now we have a few more bytes in the buffer br.b _00 ; let's try again _10: move.l buf2_ptr,r5 ; let's test if it is a complete meesage cmp.b #34,(r5) bhi.l err ; the last known message is nr 34 cmp.b #0,(r5) ; error message beq.l err ; currently we don't process error messages move.l #32,r1 ; reply/event length cmp.b #1,(r5) ; reply message bne.b _40 ; event message is always 32 byte add.l 12.b(r5),r1 ; + additional data for reply add.l 12.b(r5),r1 ; + additional data for reply add.l 12.b(r5),r1 ; + additional data for reply add.l 12.b(r5),r1 ; + additional data for reply _40: cmp.l r1,r0 ; complete reply in buffer blo.b _30 ; no, let's try to get more move.l r5,r0 ; pointer to data sub.l r1,buf2_rest ; new rest add.l r1,buf2_ptr ; pointer to next data; clear Z flag _100: move.l (sp)+,r6 move.l (sp)+,r5 move.l (sp)+,r2 rts.l ;********************************************************** ;******** read data from X server ********** ;********************************************************** ; input: r0: pointer to read buffer * ; r1: size of buffer * ; output: Z=1: nothing to read * ; Z=0: r0 bytes read * ;********************************************************** x_receive_raw: move.l r2,-(sp) move.l r3,-(sp) moveq.l #0,-(sp) ; flags move.l r1,-(sp) ; move.l r0,-(sp) ; move.l x_handle,-(sp) ; socket handle move.l r7,r2 ; pointer to parameter for "recv" move.l #10,r3 ; "recv" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 addq.l #4*4,r7 ; free space for parameters move.l (sp)+,r3 move.l (sp)+,r2 cmp.l #-11,r0 ; EAGAIN: no message available -> Z=1 beq.b _10 tst.l r0,r0 ; <0: ERROR 0: NULL message -> Z=1 bmi.l err _10: rts.l ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;--------------------------- constant data --------------------------------- even 4 sockaddr_un: dc.w 1 ; 1: AF_UNIX, AF_LOCAL (/usr/include/linux/socket.h) dc.b "/tmp/.X11-unix/X0" sockaddr_un_l= @-sockaddr_un even 4 ;--------------------------------------------------------------------------- code_filez=@@-code_offset code_memsz= @-code_addr even 4 @=(@+4095)/4096*4096+(@@\4096) data_offset=@@ data_addr: ;--------------------------- initialized data ------------------------------ buf2_ptr: dc.l buf2 buf2_rest: dc.l 0 ; Connection Setup send1: dc.b $6c,0 ; LSB first dc.w 11,0 ; major/minor version dc.w 0,0 ; length of protocol name/data dc.w 0 ; unused send1l=@-send1 ; Create Window send2: dc.b 1 ; opcode for Create Window dc.b 0 ; depth from parent dc.w send2l/4; request length s2a: dc.l 0 ; wid (has to be calculated) s2b: dc.l 0 ; parent (has to be calculated) dc.w 0 ; x dc.w 0 ; y s2x: dc.w 640 ; with s2y: dc.w 400 ; higth dc.w 0 ; border-width dc.w 0 ; class: CopyFromParent dc.l 0 ; visual: CopyFromParent dc.l $a02 ; value-mask: background-pixel 2 ; + override-redirect 200 ; + event-mask 800 dc.l $000000 ; background: black dc.b 1 ; override-redirect = true dc.b 0,0,0 ; pad dc.l $05 ; event_mask: KeyPress 1 ; +ButtenPress 4 ; +PointerMotion 40 send2l=((@-send2)+3) & $fffffffc ; Map Window send3: dc.b 8 ; opcode for Map Window dc.b 0 ; unused dc.w send3l/4; request length s3a: dc.l 0 ; wid (has to be calculated) send3l=@-send3 ; Create GC send4: dc.b 55 ; opcode for CreateGC dc.b 0 ; unused dc.w send4l/4; request length s4b: dc.l 0 ; cid (has to be calculated) s4a: dc.l 0 ; wid (has to be calculated) dc.l 1+4+8 ; function+foreground+background dc.l 3 ; function=copy dc.l $ffffff ; foreground: white dc.l $0080ff ; background: light blue send4l=@-send4 ; Set Input Focus send6: dc.b 42 ; opcode for SetInputFocus dc.b 0 ; revert-to None dc.w send6l/4; request length s6a: dc.l 0 ; wid (has to be calculated) dc.l 0 ; timestamp CurrentTime send6l=@-send6 ; Put Image send5: dc.b 72 ; opcode for PutImage dc.b 2 ; ZPixmap dc.w send5l/4; request length s5a: dc.l 0 ; wid (has to be calculated) s5b: dc.l 0 ; cid (has to be calculated) dc.w 320 ; width dc.w 200 ; hight s5x: dc.w 160 ; dest-x s5y: dc.w 100 ; dest-y dc.b 0 ; left-pad dc.b 24 ; depth dc.w 0 ; unused screen: blk.l 320*200 ; bitmap send5l=@-send5 ;--------------------------- uninitialized data ---------------------------- stack_ptr: blk.l 1 x_handle: blk.l 1 annie1: blk.l 1 color: blk.l 64 fname: blk.b 256+32 buf2: blk.b 1024 buf2l=@-buf2 ;--------------------------------------------------------------------------- data_filez=@@-data_offset data_memsz= @-data_addr ;===========================================================================
From: Herbert Kleebauer on 19 Jul 2007 02:15 Herbert Kleebauer wrote: Must have been very late. Wanted to split large messages into a sequence of 16k messages, but all I did was to send the large message in 16k chunks which isn't of any help. Leave it as a homework for the want-to-be low level Linux X programmer to correct the code. > ;********************************************************** > ;******** send message to X server ************** > ;********************************************************** > ; input: r0: pointer to message * > ; r1: length of message * > ;********************************************************** > x_send: movem.l r0-r7,-(sp) > move.l r0,r4 ; pointer to next byte of message > move.l r1,r5 ; remaining bytes to send > > _10: move.l r5,r6 > cmp.l #16*1024,r6 ; any X server must handle 16k messages > bls.b _20 > move.l #16*1024,r6
From: Rod Pemberton on 19 Jul 2007 03:43 "Herbert Kleebauer" <klee(a)unibwm.de> wrote in message news:469F016B.ED17442(a)unibwm.de... > > Leave it as a homework for the want-to-be low level Linux > X programmer to correct the code. > Herbert, You mean well, but I have to ask. Who's going to do that? Seriously, doesn't "move.l r1,r5", etc., guarantee that no x86 programmer will ever use the code you just posted... i.e., Does anyone want to learn another assembly language (yours) to do x86 assembly? How does one assemble it? How does one port it? Does anyone want to port it just to assemble it? If it's x86, why does it look like a mix of 68000, AT&T, and who knows what else? You're giving me flashbacks of Randall's teaching tool HLA: C collided with Pascal. After many surgeries and a jolt it lives... Grrr! Convert your assembler to AT&T syntax and it might be useful to others. Is your assembler even available to others? I don't recall ever seeing a link. Rod Pemberton
From: santosh on 19 Jul 2007 03:50
On Thursday 19 Jul 2007 1:13 pm, Rod Pemberton <do_not_have(a)nowhere.cmm> wrote in message <f7n4kc$lgc$1(a)aioe.org>: > > "Herbert Kleebauer" <klee(a)unibwm.de> wrote in message > news:469F016B.ED17442(a)unibwm.de... >> >> Leave it as a homework for the want-to-be low level Linux >> X programmer to correct the code. >> > > Herbert, > > You mean well, but I have to ask. Who's going to do that? > Seriously, > doesn't "move.l r1,r5", etc., guarantee that no x86 programmer > will ever use the code you just posted... > > i.e., Does anyone want to learn another assembly language (yours) > to do x86 > assembly? How does one assemble it? How does one port it? Does > anyone > want to port it just to assemble it? If it's x86, why does it look > like a mix of 68000, AT&T, and who knows what else? > > You're giving me flashbacks of Randall's teaching tool HLA: C > collided with > Pascal. After many surgeries and a jolt it lives... Grrr! Convert > your > assembler to AT&T syntax and it might be useful to others. Is your > assembler even available to others? I don't recall ever seeing a > link. <http://137.193.64.130/windela.zip> Or search the group for more links. IIRC instructions are implemented only uptil the 486, and the compile crashed for me on Linux. |