jump
This commit is contained in:
32
examples/conditional_jump.tasm
Normal file
32
examples/conditional_jump.tasm
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Example of behavior change depending on some condition
|
||||
*/
|
||||
|
||||
.main:
|
||||
movc ax 1
|
||||
movc bx 2
|
||||
gt cx ax bx
|
||||
jnz @true cx
|
||||
jz @false cx
|
||||
|
||||
.true:
|
||||
const8 true.msg "true\n"
|
||||
movc cx @true.msg
|
||||
movc dx #true.msg
|
||||
jmp @print
|
||||
|
||||
.false
|
||||
const8 false.msg "false\n"
|
||||
movc cx @false.msg
|
||||
movc dx #false.msg
|
||||
jmp @print
|
||||
|
||||
.print:
|
||||
movc ax 1
|
||||
movc bx 1
|
||||
sys
|
||||
jmp @end
|
||||
|
||||
.end:
|
||||
movc ax 0
|
||||
exit
|
||||
@@ -1,12 +1,7 @@
|
||||
/*
|
||||
Example of graphical application
|
||||
Example of self-repeating code section
|
||||
*/
|
||||
|
||||
.main:
|
||||
|
||||
le
|
||||
gt
|
||||
eq
|
||||
jif
|
||||
jel
|
||||
//TODO loop example
|
||||
exit
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
.data:
|
||||
// named array of 8-bit values
|
||||
const8 msg "Hello, World :3\n\0"
|
||||
const8 msg "Hello, World"
|
||||
|
||||
.main:
|
||||
movc ax 1; // sys_write
|
||||
|
||||
Reference in New Issue
Block a user