Difference between revisions of "Geshi"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(New page: <source lang="z80"> ld de,&4000 ld hl,&c000 ld bc,&FFFF ldir ret </source>)
 
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<source lang="z80">
+
[[Category:Programming]]
ld de,&4000
+
 
ld hl,&c000
+
Working now, isn't it? :) :) :)
ld bc,&FFFF
+
 
ldir
+
<geshi lang=MAXAM>
 +
;; A useful procedure to display a 8-bit number in binary
 +
;;
 +
 
 +
.txt_output equ &bb5a
 +
 
 +
;;------------------------------
 +
;; DISPLAY A BYTE IN BINARY FORM
 +
;;
 +
;; Enter:
 +
;; A = 8-bit value
 +
;;
 +
;; Exit:
 +
;; AF corrupt.
 +
;; B corrupt.
 +
;; All other registers preserved
 +
 
 +
.display_binary
 +
ld b ,8                    ;number of bits to display
 +
 
 +
.get_bit
 +
rlca                      ;rotate current top bit into carry
 +
 
 +
                          ;if the bit was 1, the carry is set. (i.e. carry=1)
 +
                          ;if the bit was 0, the carry is reset. (i.e carry=0)
 +
 
 +
push af
 +
ld a,"0"                  ;ASCII character for bit value
 +
adc a,0                  ;add carry, if carry is set A="1", otherwise A="0"
 +
call txt_output          ;display character onscreen
 +
pop af
 +
 
 +
djnz get_bit              ;loop, until all bits have been displayed
 
ret
 
ret
</source>
+
</geshi>
 +
 
 +
== GeSHi ==
 +
<php><?php
 +
  echo 'Hello, world!';
 +
  # What else?
 +
  $my_cnx = mysql_open('localhost', 'user', 'pass');
 +
  if ($my_cnx === false)
 +
    die('Unable to open connection with MySQL database engine');
 +
  mysql_select_db('database', $my_cnx) or die('Unable to select database');
 +
  $request = sprintf('UPDATE table SET column=data WHERE othercolumn=\'%s\'', $_SESSION['text']);
 +
  $my_success = mysql_query($request, $my_cnx);
 +
  if ($my_success === false) {
 +
    die('Error when trying to update table');
 +
  }
 +
  mysql_close($my_cnx);</php>
 +
 
 +
<geshi lang=sql>
 +
select * from lib.tbl where this=that
 +
</geshi>
 +
 
 +
<geshi lang=bash>
 +
#!/bin/ksh
 +
 
 +
HOST=host
 +
USER=username
 +
PASS=password
 +
FILE=bad.txt
 +
LOGFILE=log.txt
 +
 
 +
ftp -n -v -i ${HOST} > ${LOGFILE} 2>&1 << EOF
 +
quote USER ${USER}
 +
quote PASS ${PASS}
 +
binary
 +
put ${FILE}
 +
quit
 +
EOF
 +
 
 +
grep -q "Transfer complete." ${LOGFILE}
 +
 
 +
if [[ $? != 0 ]]; then
 +
  echo "ftp failed"
 +
else
 +
  echo "ftp succeeded"
 +
fi
 +
 
 +
rm ${LOGFILE}
 +
</geshi>

Latest revision as of 16:10, 17 December 2010


Working now, isn't it? :) :) :)

<geshi lang=MAXAM>

A useful procedure to display a 8-bit number in binary

.txt_output equ &bb5a

------------------------------
DISPLAY A BYTE IN BINARY FORM
Enter
A = 8-bit value
Exit
AF corrupt.
B corrupt.
All other registers preserved

.display_binary ld b ,8  ;number of bits to display

.get_bit rlca  ;rotate current top bit into carry

                         ;if the bit was 1, the carry is set. (i.e. carry=1)
                         ;if the bit was 0, the carry is reset. (i.e carry=0)

push af ld a,"0"  ;ASCII character for bit value adc a,0  ;add carry, if carry is set A="1", otherwise A="0" call txt_output  ;display character onscreen pop af

djnz get_bit  ;loop, until all bits have been displayed ret </geshi>

GeSHi

<php><?php

 echo 'Hello, world!';
 # What else?
 $my_cnx = mysql_open('localhost', 'user', 'pass');
 if ($my_cnx === false)
   die('Unable to open connection with MySQL database engine');
 mysql_select_db('database', $my_cnx) or die('Unable to select database');
 $request = sprintf('UPDATE table SET column=data WHERE othercolumn=\'%s\, $_SESSION['text']);
 $my_success = mysql_query($request, $my_cnx);
 if ($my_success === false) {
   die('Error when trying to update table');
 }
 mysql_close($my_cnx);</php>

<geshi lang=sql> select * from lib.tbl where this=that </geshi>

<geshi lang=bash>

  1. !/bin/ksh

HOST=host USER=username PASS=password FILE=bad.txt LOGFILE=log.txt

ftp -n -v -i ${HOST} > ${LOGFILE} 2>&1 << EOF quote USER ${USER} quote PASS ${PASS} binary put ${FILE} quit EOF

grep -q "Transfer complete." ${LOGFILE}

if $? != 0 ; then

  echo "ftp failed"

else

  echo "ftp succeeded"

fi

rm ${LOGFILE} </geshi>