flat assembler
Message board for the users of flat assembler.

Index > Heap > m3ntal's Diary: Code, Macros, Previews

Goto page Previous  1, 2, 3, 4
Author
Thread Post new topic Reply to topic
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
ZDS+Z-IDE EVOLUTION: Logical IDE design for maximum production.

Compare to Visual Studio/C++/VB and Eclipse: SLOW, MASSIVE (GIGABYTES!), WASTEFUL, takes FOREVER to SETUP, COMPILE, TEST!

Multiple CPU/VM/OS support: Intel, ARM, Java, MIPS, Motorola, MOS and more.

Fast! Only 60K .EXE! Draws to memory "VGA/buffer/matrix", way faster than Win32 API/GDI/FreshLib+IDE.

Image
Image
Post 05 Oct 2014, 03:48
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
[ Post removed by author. ]


Last edited by m3ntal on 23 Nov 2014, 04:33; edited 1 time in total
Post 05 Oct 2014, 04:05
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
New ML: Power-C+ASM 4 X86+ARM. True CPU portability with FASM!

Current Syntax. Implemented
Code:
; $$$$$$$$$$$$$$$$ POWER-C+ASM $$$$$$$$$$$$$$$$$$$
; ?????????????????? STRING ??????????????????????

; strend a        ; return end address (*p=0)
; strlen a        ; get # characters
; strcpy a, b     ; standard copy with 0
; strcpyn a, b, n ; copy with maximum size
; strcat a, b     ; attach b to a
; strcatc a, c    ; attach c/haracter
; strcmp a, b     ; compare lexical. <0>
; strequ a, b     ; equal? return 1/0
; strchr a, c     ; search for c. &/0
; strrchr a, c    ; search for c in reverse
; strup a         ; uppercase
; strlow a        ; lowercase
; strrev a        ; reverse

; strend a - return end address (*p=0)

function strend, a
  alias p=r0, c=r1
  . c=1, while c, (u8) c=*p++, endw, p--
endf

; strlen a - get string length, # characters

function strlen, a
  alias p=r0, s=r1, c=r2
  . p=a, s=p, c=1
  while c, (u8) c=*p++, endw, p-s, p--
endf

; strcpy a, b - standard copy with
; 0 after. return advanced address

function strcpy, a, b
  alias p=r0, s=r1, c=r2
  . p=a, s=b, c=1
  while c, (u8) c=*s++, (u8) *p++=c
  endw, p--
endf

; strcpyn a, b, n - copy with maximum
; size specified. return &

function strcpyn, a, b, n
  alias p=r0, s=r1, c=r2
  . p=a, s=b
  loop n, (u8) c=*s++, (u8) *p++=c
    if c=0, break, end
  endl, p--
endf

; strcat a, b - attach b to a. return &

function strcat, a, b
  strend a
  strcpy r0, b
endf

; strcatc a, c - attach c to a. return &

function strcatc, a, x
  alias p=r0, c=r1
  strend a
  . c=x, (u8) *p++=c, (u8) *p=0
endf

; strcmp a, b - lexical comparison.
; return <0>

function strcmp, a, b
  alias \
   p=r0, s=r1, c=r2, d=r3
   . p=a, s=b, c=1, d=c
  while c=d, (u8) c=*p++, (u8) d=*s++
    if c=0, break, end
    if d=0, break, end
  endw, p=c, p-d
endf

; strequ a, b - equal? return 1/0

function strequ, a, b
  strcmp a, b
  if false
    return 1
  end
endf 0

; strchr a, c - search for character:
; if a contains c. return &/0

function strchr, a, x
  alias p=r0,\
   c=r1, k=r2
  . p=a, k=x
  forever           ; loop
    . (u8) c=*p     ; get c
    if c=0          ; end
      return 0
    end
    if c=k          ; found
      return p
    end
    . p++           ; next
  endfv
endf    


Objective, Final Destination
Code:
function strlen a
  int n=0, while *a++, n++
endf n

function strcpy a, b
  while *b, *a++=*b++
endf --a

function memcpy a, b, n
  loop n, *a++=*b++
endf --a

function memcpy32 a, b, n
  let n/4, loop n, (u32) *a++=*b++
endf a-4

function draw.scanline x, y, n, s
  void *p
  get p=vga.xy x, y
  let n/4, loop n, (u32) *p++=*s++
endf    

Image

VISUAL MENUS

Example: Portable Menus+Toolbar:
Code:
; Visual Custom Menu + Icons

include 'z.inc'
use interface

text select.theme.t=\
 'Select Theme: Ctrl+LEFT/RIGHT'

;;;;;;;;;;;;;;;;; FONTS, CURSORS ;;;;;;;;;;;;;;;;;

FONT small.font='CODE2', main.font='CODE3'

CURSOR arrow.cursor='DEFAULT'

;;;;;;;;;;;;;;;;;;;;;; MENUS ;;;;;;;;;;;;;;;;;;;;;

; menu bar; array of pointers to text and menus

texts menu.bar.ta[]=\
 'File', 'Edit', 'Parse', 'Code', 'Utility',\
 'Control', 'View', 'Theme', 'Help'

align

MENU menu.bar,\
 file.menu, edit.menu, parse.menu,\
 code.menu, utility.menu, control.menu,\
 view.menu, theme.menu, help.menu

; menu; array of actions/events

MENU file.menu,\
 ID.FILE.RECENT, ID.FILE.NEW,\
 ID.FILE.OPEN, ID.FILE.CLOSE,\
 ID.FILE.SAVE, ID.FILE.SAVE.AS,\
 ID.FILE.PRINT, ID.FILE.EXIT

MENU edit.menu,\
 ID.EDIT.UNDO, ID.EDIT.REDO,\
 ID.EDIT.CUT, ID.EDIT.COPY, ID.EDIT.PASTE,\
 ID.EDIT.DELETE, ID.EDIT.SELECT,\
 ID.EDIT.SELECT.V, ID.EDIT.SEARCH,\
 ID.EDIT.REPLACE, ID.EDIT.DEFINITION,\
 ID.FONT, ID.EDIT.THEME, ID.EDIT.SETTINGS

MENU parse.menu,\
 ID.PARSE.BEAUTIFY,\
 ID.PARSE.COMMENT, ID.PARSE.UNCOMMENT,\
 ID.PARSE.SEPARATOR, ID.PARSE.INDENT.2,\
 ID.PARSE.INDENT.A, ID.PARSE.INDENT.S,\
 ID.PARSE.JUSTIFY.L,\
 ID.PARSE.UCASE, ID.PARSE.LCASE,\
 ID.PARSE.ESCAPE, ID.PARSE.CONVERT,\
 ID.PARSE.INSERT, ID.PARSE.REMOVE,\
 ID.PARSE.REPLACE, ID.PARSE.ENCLOSE,\
 ID.PARSE.DECLOSE, ID.PARSE.REPLACE.L,\
 ID.PARSE.REPLACE.R

MENU code.menu,\
 ID.CODE.EXECUTE, ID.CODE.BUILD,\
 ID.CODE.PROCESS, ID.CODE.DASM,\
 ID.CODE.DEBUG

MENU utility.menu,\
 ID.CALCULATOR, ID.CONVERT.N,\
 ID.SELECT.COLOR, ID.C.TABLE,\
 ID.IMAGE.EDIT, ID.FONT.VIEW,\
 ID.BOOK.CREATOR, ID.I.DESIGNER,\
 ID.CONVERT.R, ID.SPRITE.A,\
 ID.MAP.EDIT, ID.GAME.WIZARD,\
 ID.MOVIE.CREATOR, ID.EXECUTOR

MENU control.menu,\
 ID.CONTROL, ID.CONTROL.BOX, ID.CONTROL.T,\
 ID.CONTROL.B, ID.CONTROL.TB, ID.CONTROL.M,\
 ID.CONTROL.LB, ID.CONTROL.DB, ID.CONTROL.D

MENU view.menu,\
 ID.VIEW, ID.ZOOM.IN, ID.ZOOM.OUT,\
 ID.VIEW.ACTUAL, ID.VIEW.FIT, ID.VIEW.FULL,\
 ID.VIEW.TILE, ID.VIEW.CASCADE

MENU theme.menu,\
 ID.THEME.COLOR, ID.COLOR.F, ID.COLOR.P,\
 ID.COLOR.K, ID.COLOR.N, ID.COLOR.S,\
 ID.COLOR.T, ID.COLOR.C, ID.COLOR.SH

MENU help.menu,\
 ID.HELP, ID.HELPS, ID.HELP.LANGUAGE,\
 ID.HELP.LIBRARY, ID.HELP.ASM,\
 ID.HELP.EDITOR, ID.HELP.ABOUT

;;;;;;;;;;;;;;;;;;;; TOOL BARS ;;;;;;;;;;;;;;;;;;;

; tool bar; array of actions/events

TOOL.BAR tool.bar,\
 ID.VIEW, ID.CODE, ID.FILE.NEW,\
 ID.FILE.OPEN, ID.FILE.CLOSE,\
 ID.FILE.SAVE, ID.EDIT.UNDO,\
 ID.EDIT.REDO, ID.EDIT.CUT,\
 ID.EDIT.COPY, ID.EDIT.PASTE,\
 ID.EDIT.SEARCH, ID.EDIT.THEME,\
 ID.ZOOM.IN, ID.ZOOM.OUT,\
 ID.PARSE.INDENT.S, ID.PARSE.INDENT.A,\
 ID.EDIT.SETTINGS, ID.CODE.EXECUTE,\
 ID.CODE.BUILD, ID.CODE.PROCESS,\
 ID.CODE.DASM, ID.CODE.DEBUG,\
 ID.IMAGE, ID.BOOK.CREATOR,\
 ID.I.DESIGNER,\
 ID.VIEW.TILE, ID.VIEW.CASCADE,\
 ID.CONVERT.R, ID.SPRITE.A,\
 ID.MAP.EDIT, ID.GAME.WIZARD,\
 ID.MOVIE.CREATOR, ID.HELP

;;;;;;;;;;;;;;;;;;; LOAD MEDIA ;;;;;;;;;;;;;;;;;;;

function load.media
  set.media.folder
  set.font.folder
  try load.font main.font
  try load.font small.font
  up.directory
  set.cursor.folder
  try load.cursor arrow.cursor
  up.directory
  set.icon.folder
  set.folder icon32.folder
  try load.image.t mini.icon
  up.directory
  set.folder icon24.folder
  try load.icons
  up.directory
  set.folder icon48.folder
  try load.image.t theme.icon
  up.directory
  reset.directory
endf 1

;;;;;;;;;;;;;;;;;;;;; CREATE ;;;;;;;;;;;;;;;;;;;;;

; !on.create: when application begins...

!on create
  set.theme THEME.BLACK
  load.media
  set.cursor arrow.cursor
  set.timer !on.second, 1*SECOND
  call !on.second
  . [menu.id]=NONE, [item.id]=NONE
!end

;;;;;;;;;;;;;;;;;;;;;; DRAW ;;;;;;;;;;;;;;;;;;;;;;

; !on.draw: when screen is redrawn...

!on draw
  locals p, i, n, t,\
   x, y, w, h
  clear.screen
  copy.box box, s.box
  . r0=94, [box.y]+r0, r0++
  . [box.h]-r0, [box.w]-3
  copy.box client.box, box

  set.font.c main.font, WHITE
  draw.title.bar
  set.font small.font

  copy.box box, title.box
  move.box.d box
  draw.bar shade, box,\
   [theme.shade.color], [theme.color]
  move.box.d box
  . [box.h]=16
  draw.fade 'v', box,\
   [theme.glow.color], [screen.color]

  draw.tool.bar tool.bar, 0, 50
  draw.menu.bar menu.bar,\
   menu.bar.ta, 60, 0

  . [theme.select]=NO
  size.box box, 48, 48
  align.in box, client.box,\
   ALIGN.NE, -8, 50
  if.select box
    . [theme.select]=YES
    nudge.box box, -4, -4
    . [box.w]+8, [box.h]+8
    draw.bar shade, box, BLACK, WHITE
    nudge.box box, 4, 4
    set.font.color [theme.font.color]
    draw.caption.box select.theme.t,\
     ALIGN.NE, -8, 8,\
     [theme.shade.color], [theme.color]
  end

  draw.image.b theme.icon, box

  draw.time client.box,\
   ALIGN.SE, -8, -8,\
   [theme.shade.color], [theme.color]
!end

;;;;;;;;;;;;;;;;;;;;;; MOUSE ;;;;;;;;;;;;;;;;;;;;;

; !on.mouse: when a mouse event occurs...

!on mouse
  if [mouse.event]='c'
    if [menu.id]=ID.FILE
      if [item.id]=ID.FILE.EXIT
        exit
      end
    end
    if [theme.select]
      . [theme.select]=NO
      next.theme
      redraw
      return
    end
    . [menu.id]=NONE
    . [item.id]=NONE
  end
  title.bar.input
  redraw
!end

;;;;;;;;;;;;;;;;;;;;;;; KEY ;;;;;;;;;;;;;;;;;;;;;;

; !on.key: when a key event occurs...

!on key
  if.keys CONTROL
    if.keys LEFT
      previous.theme
      go .draw
    end
    if.keys RIGHT
      next.theme
      go .draw
    end
  end
  return
  .draw:
  redraw
!end

;;;;;;;;;;;;;;;;;;;;;; TIMER ;;;;;;;;;;;;;;;;;;;;;

!on second
  get.time
  redraw time.box
endf    


Result:

Image
Image
Post 14 Oct 2014, 12:38
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
UPDATES:

* Abakis: Improvements, language and library, TEXT, BIT and DRAW
* Visual Menus: 7 Themes
* My Site. New Code & Links. Under construction.

NEW "BIT STREAM" (ABAKIS > BIT.ASM+INC)

READ/WRITE TO/FROM BITSTREAM
Code:
;;;;;;;;;;;;;; CHARACTER BIT STREAM ;;;;;;;;;;;;;;

; "bit stream"; array of '1'/'0' bytes ending
; with 0. for variable compression schemes

; read/write 1-32BIT value to/from
; bit stream. read removes prefix and
; decreases size. write attaches suffix

; example: text bs='11110000'
; read.bs bs, 4 ; returns integer 1111b,
; BITs shifted out left, and after,
; bs = '0000', remaining BITs in stream

function read.bs, bs, size
  alias p=r0
  try verify.bs bs
  text.copy bs.t, bs
  . p=bs.t, p+size, *p=0
  text.shift.la bs, bs.t, size
  t2b bs.t
endf

; read as 'text' into t: '1111'

function read.bs.t, bs, t, size
  try read.bs bs, size
  b2t.a r0, t, size
endf

; example: write.bs bs, 11110011b, 8

function write.bs, bs, v, size
  b2t.a v, bs.t, size
  text.attach bs, bs.t
endf

; align last byte, attach zeros

function align.bs, bs
  alias p=r0, i=r1, c=r2
  text.n bs
  . c=p, c&7, i=8, i-c, p+bs
  if i<0, return, end
  loop i, *p++='0', endl, *p=0
endf

; read/write individual BITs...

macro get.bs bs  { read.bs bs, 1 }
macro set.bs bs  { write.bs bs, 1, 1 }
macro zero.bs bs { write.bs bs, 0, 1 }

; conversions...

; convert binary data to 'bit stream'.
; b=address of binary bytes. example:

; b: db 11111111b, 00000000b,\
; 11110000b, 10100001b

; b2bs b, t, 27
; result: t='111111110000000011110000101'

function b2bs, b, bs, n
  locals i
  alias p=r7, x=r1, c=r2
  push p
  . p=b, i=n, i>>>3, c=n, c&7, n=c
  loop i, c=*p++
    write.bs bs, c, 8
  endl
  if n, c=*p, x=8, x-n, c>>>cl
    b2t.a c, bs.t, n
    text.attach bs, bs.t
  end
  pop p
endf

; convert 'bit stream' to binary data.
; b=address of binary bytes. example:

; text t='11111111001111001111000011111111'
        ; 111111110011110011110000111 (27)

; bs2b t, b, 27
; result: b = db 11111111b, 00111100b,\
; 11110000b, 11100000b (last byte)
;               XXXXX  (alignment)

; writes the last byte if n is not
; divisible by 8

function bs2b, bs, b, n
  locals i
  alias p=r7, c=r0, x=r1
  push p
  . p=b, i=n, i>>>3, c=n, c&7, n=c
  loop i
    read.bs bs, 8
    . *p++=c
  endl
  if n
    read.bs bs, 8
    . x=8, x-n, c>>>cl, c<<cl
    . x=*p, x|c, *p=x
  end
  pop p
endf

; with same parameters: bs, b

macro load.bs bs, b, n { b2bs b, bs, n }
macro save.bs bs, b, n { bs2b bs, b, n }    
EXAMPLE USAGE
Code:
; CHARACTER BIT STREAM

include 'a.inc'
use bit

text t(128), s(128)
text test.bs.t='Test Read/Write 1-32BITs...'
text test.bs2.t='Test Convert XBIT Stream...'

; write 11110011.00001111.00110011 to
; "bit stream" t then read from it

; read.bs/write.bs are for 1-32BIT values

; read.bs gets/returns an integer value.
; read.bs.t gets/returns binary 'text'
; in 2nd parameter with alignment

function test.bs
  log test.bs.t
  log.r
  reset.bs t
  write.bs t, 11110011b, 8
  write.bs t, 00001111b, 8
  write.bs t, 00110011b, 8

  log t        ; 11110011.00001111.00110011
  read.bs t, 7 ; 1111001, first 7BITs
  b2t r0, s
  log s
  read.bs.t \
   t, s, 11    ; 1.0000111100, next 11BITs
  log s
  log t        ; remaining, '110011'
  log.r
endf

; b2bs/bs2b; convert 'bit stream' to/from
; binary/files/images. aka, load.bs/save.bs

; example 64BIT binary:

binary: db \
 11111111b, 00000000b, 11110000b, 10111101b,\
 00000000b, 11001100b, 11111111b, 00001111b

; example 32BIT stream:

text bst='11111111001111001111000011111111'
        ; 111111110011110011110000111 (27)
                                   ; ALIGN 32
function test.bs2                  ; 00000
  alias p=r0
  log test.bs2.t
  log.r
  . p=binary       ; load; convert binary bytes
  b2bs p, t, 60    ; p to 'bit stream' t
  log t            ; 60BITs ending with 0000
  reset.bs t       ; reset *t=0
  bs2b bst, s, 27  ; save; convert 'bit stream'
  b2bs s, t, 27    ; t to binary bytes s then
  log t            ; back to 'bit stream' t
  align.bs t       ; align last byte with '0's
  log t
endf

function main
  test.bs
  test.bs2
  show.log
endf    
MY .IMAGE COMPRESSION
Quote:
Powerful variable BIT compression scheme. Lossless.

Supports all RGBs, component sizes 2-8BIT, RGB24/8.8.8, RGB21/7.7.7, RGB18/6.6.6, RGB15/5.5.5, RGB12/4.4.4, RGB9/3.3.3, RGB6/2.2.2, etc. An encoder can use custom RGBs like RRR.G.BBBBB (9BITs), if, for example, the image contains mostly blue (5BITs), some red (3BITs) and no green (1BIT).

True high 24BIT color. Dynamic modifyable palette holds 256 recent/common colors at once, with the ability to refer to them in variable sized XBIT (1/2/3/4/5/6/7/Cool indices.

COMPRESSION
Code:
* 00. RGB   ; Pixel color in current RGB format
* 110.      ; Repeat previous color
* 111...    ; XBIT indices follow until 0
* 100. IS   ; Set index size, 0-3 = 1/2/3/4BIT
* 101. IS   ; Set index size, 0-3 = 5/6/7/8BIT
* 0101. RGB ; Store color in palette[1]++

* 1101.00.XXX ; Set R component size, 1-7 = 2-8BIT
* 1101.01.XXX ; Set G component size, 1-7 = 2-8BIT
* 1101.10.XXX ; Set B component size, 1-7 = 2-8BIT

* 1101.11.NNN          ; Repeat 4-7 times, 3BIT
* 1101.11.000 I8       ; Repeat 8BIT (If N=0)
* 1101.11.000 I8=0 I16 ; Repeat 16BIT (If N=0 & I=0)    


Quote:
For 111..., XBIT color indices follow until 0/reset, go to start. Example: If index size is 2BIT (1-3), to encode 10 pixels: 111 XX XX XX XX XX XX XX XX XX XX 00... XX's = 1-3 each. Palette[1] is the first index.

Set R/G/B component size for pixel and store. An image should begin with set RGBs or the default is RGB 24BPP, 8 for each one. Internal palette is always 24BPP.

Repeat 3BIT must be 4-7 since 110. is repeat once or 3 times in 9BITs.


NEW ABAKIS FUNCTIONS: TEXT SHIFT, EXPAND, ALIGN
Code:
; shift all characters left

; before:    'abc123'
; after <<3: '123'

function text.shift.l, t, n
  alias p=r0, q=r1
  . p=t, q=p, q+n
  text.copy p, q
endf

; shift left and assign s to BITs
; copied out ('abc' in example above)

function text.shift.la, t, s, n
  alias p=r0, q=r1
  . p=t, q=p, q+n
  text.copy.n s, t, n
  text.shift.l t, n
endf

; expand; shift all characters right.
; example: 'abc123' becomes 'XXXabc123'
; after expand 3 where X is unknown

function text.expand, t, n
  locals x
  alias p=r0, q=r1, c=r2
  get x=text.n t
  . p+t, p--, q=p, p+n, *p=0
  loop x, *p--=*q--, endl
endf

; prefix text with '0's or ensure maximum n.
; example: before: t='7FAB'
; text.align t, 8 ; after: t='00007FAB'

function text.align, t, n
  locals tn
  alias n1=r0, n2=r1,\
   c=r1, p=r2
  get tn=text.n t
  . n2=n
  if n1=n2, return, end    ; same size
  if n1>n2, p=t, *(p+n1)=0 ; exceeds maximum
    return                 ; end at t+n
  end, n-n1                ; else, n2>n1
  text.expand t, n         ; expand t
  . p=t, c='0'             ; write '0's
  loop n, *p++=c, endl
endf    
ABAKIS .GIF LOADER PREVIEW

Based on FASM\EXAMPLES\DDRAW\.
Code:
  . p=0, image=0           ; initialize
  if lzw.table=0
    try create.lzw.table
  end
  try p=load.file name     ; load file
  . (u32) n=*(p+2)         ; verify
  if n<>'F87a', go .0, end ; signature
  . r0+30Dh, p=r0, q=p     ; advance
  . c=*p++                 ; tag
  if c<>',', go .0, end    ; image?
  . p+4, (u16) n=*p++, w=n ; width
  . (u16) n=*p++, h=n      ; height
  . p++, c=*p++            ; next
  if c<>8, go .0, end      ; must be 8
  . n=w, n*h, size=n       ; image size
  try image=allocate n     ; allocate
  . p=file.p, p+318h       ; advance to
  . r7=p, q=p, r0=1        ; lzw data
  while c, c=*p++          ; until 0
    loop c, *r7++=*p++     ; copy c size
    endl
  endw
  . r7=image, r3=q         ; destiny, source
  . lzw.bits=0
  .clear: . n=0            ; reset, ch=9-12
  .decode: . ch=9
    if n<=7F0h, go .read, end, ch++
    if n<=17F0h, go .read, end, ch++
    if n<=37F0h, go .read, end, ch++
  .read:
    . cl=lzw.bits, (u32) r0=*r3, r0>>>cl
    xchg cl, ch
    . r6=1, r6<<cl, r6--, r0&r6, cl+ch
  while cl>8, cl-8, r3++, endw
  . lzw.bits=cl
  if r0=100h, go .clear
  else.if r0<100h, go .single, end
  . r0-102h
  jc .e    
PORTABLE "HELLO, WORLD!" Smile
Code:
use arm rpi

say 'Hello!'    
Imagine if all you had to do is change "use arm rpi" to "use intel linux" or any system.
Post 27 Oct 2014, 10:35
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
In addition to its advanced data processing and pointer operations, Abakis now features FPU arithmetic:

DOWNLOAD ABAKIS EXAMPLE: FPU:

Code:
; ABAKIS EXAMPLE: MINIMAL FPU

include 'a.inc'

text t(256)

integer i=1024

float f, g, e
float a=1.234567, b=6.543210, c=6.300004
float d=270.0, r=4.7, z=7.654321

text f1.t='FPU EXAMPLE:',\
 f2.t='CONVERT:', f3.t='MATH:'

function test.i           ; constants
  log f1.t, 'r'
  % f=1.0, g=0.0, e=pi()
  log.fp f, g, e
  log.r
endf

function test.convert
  log f2.t, 'r'
  % f=i2f(i), i=f2i(f)    ; integer, float
  log.n i
  log.fp f
  % f=d2r(d), g=r2d(f)    ; degrees, radians
  log.fp f, g
  log.r
endf

function test.math
  log f3.t, 'r'
  % f=a+b, g=f-b, e=a*c   ; arithmetic
  log.fp f, g, e
  . i=8
  % e=i2f(i), f=sqrt(e)   ; square root
  log.fp f
  . i=120                 ; angle
  log.n i
  % e=i2f(i), e=d2r(e)    ; convert
  % f=sin(e), g=cos(e)    ; sine, cosine
  log.fp f, g
endf

function main
  test.i
  test.convert
  test.math
  show.log
endf    
Post 20 Nov 2014, 07:36
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
IDEA: EASY VARIANT: TYPE SAFETY

Finally, a solution to the problem of type safety at runtime AND at assembly time (load a dword from p:i).

"Easy variant" is a mini 32BIT structure that can represent different types with 28BIT remaining for immediate or relative address or offset of base (ex, 400000h) or 1-3 big memory registers, R0-R127 or pointer or Object. All this information is self-contained in one number then sent to a method: copy/assign, attach, compare, search, exchange, arrange, etc.

Variant: TT.AA.I28
Code:
; TT.AA.I28

TT = Type:

00 - Integer
01 - Float
10 - Text
11 - void or Object/Array/X
     or Registers if AA=11b

AA = Access: Something like this:

     Integer   | Float     | Text      |  Void
----------------------------------------------
00 - Immediate | Reserved  | 1-3 byte  | &void
01 - Memory    | Memory    | 'text'    | void *
10 - integer * | float *   | text *    | Object *
11 - Register  | &Object   | Object.X  | Reserved    
Registers (AA=11): NN*11*.XXXXXXX.A7.B7.C7
Code:
NN:  # operands. 0-3
Xs:  Types, sizes
ABC: Registers, R0-R127 each.    
Object.X: 11.**.O10.M10.RRRRR.TT.A
Code:
O10: Object index, 0-1023
M10: Member offset, 0-1023
RRRRR: Reserved
TT: Type
A: 1=Address or 0=Value    
Post 23 Nov 2014, 03:30
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
Image
Code:
; draw bit/byte

function draw.bit, n, x, y
  if n
    draw.image bit1.i, x, y
  else
    draw.image bit0.i, x, y
  end
endf

function draw.byte, n, x, y
  locals i
  . i=8
  loop i, r0=n, r1=i, r1--, r0>>cl, r0&1
    draw.bit r0, x, y
    . x+BIT.W
  endl
endf

; draw pixel

function draw.pixel, x, y, c
  alias p=r0, z=r1
  try clip.pixel x, y
  vga.xy x, y
  . z=c, (u32) *p=z
endf 1

; draw horizontal line

function draw.line.h, x, y, n, c
  alias p=r0, z=r1, w=r2
  . p=&x, z=&y, w=&n
  try clip.line 0, p, z, w
  vga.xy x, y
  . z=c
  loop n, (u32) *p++=z, endl
endf 1

; draw solid rectangle

function draw.box, x, y, w, h, c
  locals i
  try visible x, y, w, h
  . i=y, i--
  loop h, i++
    draw.line.h x, i, w, c
  endl
endf 1

; draw scanline

function draw.scanline, pixels, x, y, w
  alias p=r0, s=r1
  vga.xy x, y
  . s=pixels
  loop w, (u32) *p++=*s++, endl
endf 1

; draw 8BPP scanline/bitmap with palette

function draw.scanline.8, pixels, x, y, w
  alias p=r0, s=r1, c=r2, q=r3
  vga.xy x, y
  . s=pixels
  loop w, q=*s++, q*4, q+palette.p
    . (u32) c=*q, (u32) *p++=c
  endl
endf 1

function draw.bitmap.8, pixels, x, y, w, h
  locals i, p
  try visible x, y, w, h
  . i=y, i--, p=pixels
  loop h, i++
    draw.scanline.8 p, x, i, w
    . r0=w, p+r0
  endl
endf 1

function draw.my.numbers
  locals i, n, y
  . i=bits.h, y=404
  loop i, r0=my.numbers, r0+i, r0--
    . r0=*r0, n=r0
    draw.byte n, 4, y
    . y-BIT.H
  endl
endf

function draw.title.scene
  draw.text help.t, 16, 130
  draw.byte magic.n, 50, 300
endf

function draw.play.scene
  draw.board
  draw.my.numbers
endf

function draw.pause.scene
  draw.text pause.t, 16, 130
  draw.byte magic.n, 50, 300
endf

function draw.game.over
  print t, game.over.t, score
  draw.text t, 44, 170
  draw.byte magic.n, 50, 300
endf

; convert 32BIT binary number to text

function b2t, n, t
  alias p=r0, x=r1
  . p=t
  if n=0, *p++='0', *p=0
    return
  end
  while n, x=n, x&1, x+'0'
    . *p++=x, n>>>1
  endw, *p=0
  text.reverse t
endf

; text.copy a, b - standard copy with
; 0 after. return advanced address

function text.copy, a, b
  alias p=r0, s=r1, c=r2
  . p=a, s=b, c=1
  while c, c=*s++, *p++=c, endw, p--
endf

; text.copy.n a, b, n - copy with maximum
; size specified. return &

function text.copy.n, a, b, n
  alias p=r0, s=r1, c=r2
  . p=a, s=b
  loop n, c=*s++, *p++=c
    if c=0, break, end
  endl, p--
endf

; text.go t, n - advance to line #

function text.go, t, n
  loop n
    try t=text.find t, 0Dh
    . t+2
  endl
endf t

; text.skip.0 a - skip 0s, return address or 0

function text.skip.0, a
  alias p=r0, c=r1
  . p=a, c='0'
  while c='0', c=*p++, endw, p--
  if c=0, return 0, end
endf

; convert text to 32BIT binary

function t2b, t
  alias p=r0, c=r1, n=r2
  try text.skip.0 t
  . n=0
  loop, c=*p++
    if c=0, return n, end
    . n<<1, n-'0', n+c
  endl
endf

function draw.my.text, t, x, y
  locals p, n
  get n=text.n t
  . p=t
  loop n, r0=p, r0=*r0
    draw.my.c r0, x, y, WHITE
    . x+r0, x+4, p++
  endl
endf

function randomize.puzzle
  locals q, n
  alias p=r0, x=r1
  . q=puzzle, n=(MAP.W*MAP.H)
  loop n
    get x=get.random
    . p=q, (u32) *p=x, q+4
  endl
endf

function is.solved
  locals n
  alias p=r0, x=r1
  . p=puzzle, n=(MAP.W*MAP.H)
  loop n, (u32) x=*p++
    if x<>NORMAL, return 0, end
  endl
endf 1

function draw.puzzle
  locals x, y
  . y=0
  while y<8, x=0
    while x<8
      . r0=x, r0*TILE.W, r0+MAP.X
      . r1=y, r1*TILE.H, r1+MAP.Y
      draw.piece x, y, r0, r1
      . x++
    endw
    . y++
  endw
endf

function on.key
  if key.event='c'
    if scene=SCENE.TITLE
      . scene=SCENE.PLAY
      go .draw
    end
    if scene=SCENE.GAME.OVER
      go .reset
    end
    if key='r'
      .reset:
      reset.game
      go .draw
    end
    if key='p'
      .pause:
      if scene=SCENE.PLAY
        . scene=SCENE.PAUSE
      else.if scene=SCENE.PAUSE
        . scene=SCENE.PLAY
      end
      go .draw
    end
    .draw:
    render
  end
endf

function on.mouse
  locals r
  if mouse.event='c'
    . r0=&close.i.x
    if.select r0
      exit
    end
    if scene=SCENE.TITLE
      reset.game
      . scene=SCENE.PLAY
      go .draw
    end
    if scene=SCENE.PLAY
      if.select puzzle.box
        get.select.xy
        get r=get.piece.rotate \
         select.x, select.y
        . r++
        set.piece.rotate \
         select.x, select.y, r
        go .draw
      end
    end
    if scene=SCENE.SOLVED
      reset.game
      . scene=SCENE.TITLE
      go .draw
    end
    .draw:
    render
  end
endf    


Last edited by m3ntal on 23 Feb 2015, 21:04; edited 2 times in total
Post 19 Jan 2015, 00:24
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
PROFESSION: WHAT DO YOU DO?

Artist. I do contract work for business owners, people who have a personality like Jesse James or Mark Wahlberg; big tough characters who love art, own nightclubs, art galleries, vehicle shops, boxing gyms, etc. I respect their power.

They've always been good to me, giving me money, personal talks, hotels, women, boat rides, etc, all this while I was in/out homeless/shelters, and they never expected anything in return.

For personal reasons, I'm only able to work about 1-3 days per month and that's usually enough to survive. So, I don't make much money, can't work much anymore, but I make REAL FAST MONEY (ie, $400-$700+ a day).

I'm kind of famous, 100,000s of people have heard my name in radio advertisements and/or have seen me on TV, so much that I'm scared to leave the house anymore (except Walmart in the middle of the night, 3AM).

Everyone knows that I do art and they're always begging me to do what THEY want. This is MY life, MY talent and I do WHAT I WANT with it.

No one knows that I do programming except my roomates. I never talk about programming, just write about it and do it.

My only inspiration/support to do programming is seeing others who make contributions (example: ava, tthsqe, mbr, idle, fasmnewbie) and they generally leave me alone. Thanks.

NO TIME!

No time to view/reply YOUR messages. Rarely EVER do. Typed on PC, sent on PHONE.


Last edited by m3ntal on 23 Feb 2015, 21:06; edited 1 time in total
Post 20 Jan 2015, 13:06
View user's profile Send private message Reply with quote
badc0de02



Joined: 25 Nov 2013
Posts: 216
Location: %x
badc0de02
xD


Description:
Filesize: 93.59 KB
Viewed: 6562 Time(s)

url.jpg


Post 21 Jan 2015, 14:57
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
Abakis AI (Update 1-15, MM/YY) - Minimal ARM, examples

Application Template *.PUB (FASM Portable)

FASM.PUB: Editable Publisher Template. Design your own software. An adult's coloring book to relieve frustrations in a positive way.

Example: "FASM Portable", 800x480, standard for WinCE/Mobile GPS devices/phones.

Image
Post 23 Jan 2015, 10:55
View user's profile Send private message Reply with quote
m3ntal



Joined: 08 Dec 2013
Posts: 296
m3ntal
MY STORY (SUMMARIZED)
Quote:
* 3-7: Art, drawing, painting, sculptures, inventions
* 7-10: Art, animations, cartoons (with mom's VHS camcorder), inventions, designs for innovative vehicles
* 10-11: First computer, Commodore 64 with BASIC. Studying programming. Airbrushing and tattoos in school. Attracted "cool" friends and women.
* 12-13: Art. Programming in C/DOS, making text adventure games
* 14: Lost real father who was a robotics engineer. Moved with mother to "ghetto" (southside Chicago)
* 14: Airbrushing, programming. Mom has a new evil boyfriend
* 14-15: Airbrushing in malls, fairs, tattoos. Abuse from mom's boyfriend, bruises, scars. Why? "Because God said so". What did I do wrong? "Thou shall beat thy child with a rod". Never gave one reason. "You're going to Hell! God's gonna' get you!". He was jealous of me because I was talented and I had all the girls/women. His only ability was to convince employers that he has abilities (example: sleeps, JohnFounds, Benny Hinns, that kind of personality). Loved my mother but hated him. She was only with him for financial support
* 15: Started fighting back. Me and my friends attacked mom's boyfriend, "It's payback time, MF!". I hit him in the face with a steel bar and broke his nose and cheek bone. He lied to the police and told them, "This kid is a wild animal and a criminal. Look at what he did to me. Lock him up forever. All I ever did was try to help him". By beating me up?! He wouldn't stop attacking me and using Bible scriptures to justify evil actions
* 15-17: My anger against mom's boyfriend resulted in criminal activity: Stealing vehicles, breaking into houses in rich neighborhoods, opiate cultivation, heroin manufacture (learned by reading medical books; heroin = dia/morphine, primary alkaloid). As many times as I've been accused of being a "criminal", I might as well be, but never stole from friends or anyone who was poor, not even behind closed doors. Spent time in juvenile detention centers and mental institutions. What was the nicest thing her boyfriend ever said to me? "Do you realize how talented you are with all these inventions? We could make millions $ if you just do what I say". No matter how many beatings, I'll never "listen"/comply. I had guns that I had stolen from vehicles and houses and thought about killing him. Deep inside, I never wanted to hurt anyone, only wanted for him to leave me alone. "Stop getting in my face and telling me what to do. Mind your own damn business!". This is the real reason why I hate people like JohnFound and Benny Hinn and anyone who's like my mom's ex-boyfriend. Yes, John is definitely a fake - FreshLib+IDE is strictly copy and paste - who takes credit for everyone else's work, a biased hypocrite and obsessive control freak.
* 17: My mother kicked her boyfriend out and we finally had peace again. She said, "I'd rather be poor than be with you. My son can help me, I don't need your support"
* 17-19: Airbrushing murals in bars, night clubs, churches, multiple women everyday, drinking (most dangerous), cocaine (most expensive, never paid for it, offered by business owners), marijuana (safest)
* 20-26: Homeless, shelters. While walking the streets downtown at night, I've been attacked and robbed more times than I can remember, scars, stab wounds, permanently broken bones (jaw, ribs, fractured skull). In my freetime, I did programming whenever I had a place to live and electricity. On several occasions, worked for Chicago mafia as artist, muralist, tattooist, custom vehicle designer (body shops), architect (construction), business plans, substance science
* 27-33: Artist, fun exciting experiences everyday, women, parties, motorcycle rides. Famous on TV and radio but I only "worked" for about 2-3 days per week. Low income and no residence, where I lay my head is "home"
* 34-35: Art, programming
* 35-37: Mostly programming and development for fun and recreation. Some airbrushing. Never been paid for programming. In this world, only the fakest ones who claim to have abilities - sleeps, Johns, Gurus, Marios - get paid to convince employers that they know how. They take the money and credit for what real creative individuals do.
Post 29 Apr 2015, 15:42
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Lol. Chi town.
Post 28 Jun 2015, 11:23
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.