This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
microgentambly/examples/rect.mga

39 lines
639 B
Plaintext
Raw Permalink Normal View History

2021-09-28 22:35:18 +02:00
OUT I will draw a rectangle\n
2021-09-28 22:57:03 +02:00
#show welcome message
2021-09-28 22:35:18 +02:00
INT w
2021-09-28 22:57:03 +02:00
#initialize width
2021-09-28 22:35:18 +02:00
INT h
2021-09-28 22:57:03 +02:00
#initialize height
2021-09-29 18:48:54 +02:00
IN INT w l
2021-09-28 22:57:03 +02:00
#input height as an int
2021-09-28 22:35:18 +02:00
IN INT h h
2021-09-28 22:57:03 +02:00
#input width as an int
2021-09-28 22:35:18 +02:00
INT wr
2021-09-28 22:57:03 +02:00
#initialize width counter
2021-09-28 22:35:18 +02:00
INT hr
2021-09-28 22:57:03 +02:00
#initialize height counter
2021-09-28 22:35:18 +02:00
SET wr 0
2021-09-28 22:57:03 +02:00
#set width counter to 0
2021-09-28 22:35:18 +02:00
SET hr 0
2021-09-28 22:57:03 +02:00
# set height counter to 0
2021-09-28 22:35:18 +02:00
:wrc
2021-09-29 18:48:54 +02:00
#row label
:wf
#column label
OUT *
#put char
INC wr
#increment width counter
JL wf wr w
#loop until desired width
OUT \n
#put newline char
SET wr 0
# set width counter to 0
INC hr
2021-09-28 22:57:03 +02:00
#increment height counter
2021-09-28 22:35:18 +02:00
JL wrc hr h
2021-09-28 22:57:03 +02:00
#loop until desired height
2021-09-28 22:35:18 +02:00
END
2021-09-28 22:57:03 +02:00
#quit