Revision: 1751
Author: jsuijs
Date: Sat Mar 6 13:12:27 2010
Log: an other small step of the starters guide..
http://code.google.com/p/jallib/source/detail?r=1751
Modified:
/trunk/sample/16f877a_startersguide_serial.jal
/trunk/test/jal/test_startersguide_serial.jal
=======================================
--- /trunk/sample/16f877a_startersguide_serial.jal Sat Feb 27 02:35:28 2010
+++ /trunk/sample/16f877a_startersguide_serial.jal Sat Mar 6 13:12:27 2010
@@ -87,11 +87,6 @@
;
end procedure
-function sgd_transmit_byte(byte in data) return bit is
- ;
- data = 123
-end function
-
function sgd_receive_function() return byte is
var byte data = 0
;
@@ -103,6 +98,11 @@
;
end procedure
+-- warning: bad programming !!
+procedure find_the_bug(byte out alpha) is
+ alpha = alpha + 1
+end procedure
+
var byte alpha = 0b0100_0011 -- binary
;var byte*4 bravo = 0q203 -- octal
@@ -122,6 +122,10 @@
delay_100ms(20)
print_string(sg_output, str1)
+ sgd_initialize()
+ alpha = sgd_receive_function()
+
+
-- ----------------------------
test_header(1) -- print header
-- ----------------------------
@@ -160,9 +164,17 @@
sg_output = ")"
-- ----------------------------
- test_header(4) -- print header
+ test_header(4) -- print header
-- ----------------------------
+ alpha = 7
+ find_the_bug(alpha) -- waring: bad code!
+ print_byte_dec(sg_output, alpha)
+
+ -- ----------------------------
+ test_header(5) -- print header
+ -- ----------------------------
+
x = 2
if (x > 0) then
x = x - 1
@@ -174,7 +186,8 @@
x = x + 1
end if
- if (x == 1) then
+ x = 7
+ if (x == 7) then
x = x + 1
elsif (x > 7) then
x = x + 2
@@ -184,7 +197,7 @@
print_byte_dec(sg_output, x)
-- ----------------------------
- test_header(5) -- print header
+ test_header(6) -- print header
-- ----------------------------
x = 14
@@ -205,7 +218,7 @@
print_byte_dec(sg_output, x)
-- ----------------------------
- test_header(6) -- print header
+ test_header(7) -- print header
-- ----------------------------
x = 0
@@ -218,7 +231,7 @@
end loop
-- ----------------------------
- test_header(7) -- print header
+ test_header(8) -- print header
-- ----------------------------
for 7 loop
@@ -226,7 +239,7 @@
end loop
-- ----------------------------
- test_header(8) -- print header
+ test_header(9) -- print header
-- ----------------------------
var byte lc
@@ -236,7 +249,7 @@
end loop
-- ----------------------------
- test_header(9) -- print header
+ test_header(10) -- print header
-- ----------------------------
var byte x = 0
@@ -246,7 +259,7 @@
until (x == 0)
-- ----------------------------
- test_header(10) -- print header
+ test_header(11) -- print header
-- ----------------------------
x = 0
@@ -256,13 +269,16 @@
end loop
-- ----------------------------
- test_header(11) -- print header
+ test_header(12) -- print header
-- ----------------------------
x = 4
while (x > 0) loop
sg_output = "%"
- x = x - 1
+ x = x - 1
+ if (x == 14) then
+ exit loop
+ end if
end loop
-- ----------------------------
=======================================
--- /trunk/test/jal/test_startersguide_serial.jal Sat Feb 27 02:35:28 2010
+++ /trunk/test/jal/test_startersguide_serial.jal Sat Mar 6 13:12:27 2010
@@ -72,11 +72,6 @@
;
end procedure
-function sgd_transmit_byte(byte in data) return bit is
- ;
- data = 123
-end function
-
function sgd_receive_function() return byte is
var byte data = 0
;
@@ -88,6 +83,11 @@
;
end procedure
+-- warning: bad programming !!
+procedure find_the_bug(byte out alpha) is
+ alpha = alpha + 1
+end procedure
+
var byte alpha = 0b0100_0011 -- binary
;var byte*4 bravo = 0q203 -- octal
@@ -107,6 +107,10 @@
delay_100ms(20)
print_string(sg_output, str1)
+ sgd_initialize()
+ alpha = sgd_receive_function()
+
+
-- ----------------------------
test_header(1) -- print header
-- ----------------------------
@@ -145,9 +149,17 @@
sg_output = ")"
-- ----------------------------
- test_header(4) -- print header
+ test_header(4) -- print header
-- ----------------------------
+ alpha = 7
+ find_the_bug(alpha) -- waring: bad code!
+ print_byte_dec(sg_output, alpha)
+
+ -- ----------------------------
+ test_header(5) -- print header
+ -- ----------------------------
+
x = 2
if (x > 0) then
x = x - 1
@@ -159,7 +171,8 @@
x = x + 1
end if
- if (x == 1) then
+ x = 7
+ if (x == 7) then
x = x + 1
elsif (x > 7) then
x = x + 2
@@ -169,7 +182,7 @@
print_byte_dec(sg_output, x)
-- ----------------------------
- test_header(5) -- print header
+ test_header(6) -- print header
-- ----------------------------
x = 14
@@ -190,7 +203,7 @@
print_byte_dec(sg_output, x)
-- ----------------------------
- test_header(6) -- print header
+ test_header(7) -- print header
-- ----------------------------
x = 0
@@ -203,7 +216,7 @@
end loop
-- ----------------------------
- test_header(7) -- print header
+ test_header(8) -- print header
-- ----------------------------
for 7 loop
@@ -211,7 +224,7 @@
end loop
-- ----------------------------
- test_header(8) -- print header
+ test_header(9) -- print header
-- ----------------------------
var byte lc
@@ -221,7 +234,7 @@
end loop
-- ----------------------------
- test_header(9) -- print header
+ test_header(10) -- print header
-- ----------------------------
var byte x = 0
@@ -231,7 +244,7 @@
until (x == 0)
-- ----------------------------
- test_header(10) -- print header
+ test_header(11) -- print header
-- ----------------------------
x = 0
@@ -241,13 +254,16 @@
end loop
-- ----------------------------
- test_header(11) -- print header
+ test_header(12) -- print header
-- ----------------------------
x = 4
while (x > 0) loop
sg_output = "%"
- x = x - 1
+ x = x - 1
+ if (x == 14) then
+ exit loop
+ end if
end loop
-- ----------------------------
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.